mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 835892 - Provide No Video & No Audio options when both camera and microphone access are requested. r=gavin
This commit is contained in:
parent
88df194b4b
commit
d76b2f5904
@ -426,6 +426,8 @@ identity.loggedIn.signOut.accessKey = O
|
||||
getUserMedia.shareCamera.message = Would you like to share your camera with %S?
|
||||
getUserMedia.shareMicrophone.message = Would you like to share your microphone with %S?
|
||||
getUserMedia.shareCameraAndMicrophone.message = Would you like to share your camera and microphone with %S?
|
||||
getUserMedia.noVideo.label = No Video
|
||||
getUserMedia.noAudio.label = No Audio
|
||||
getUserMedia.shareSelectedDevices.label = Share Selected Device;Share Selected Devices
|
||||
getUserMedia.shareSelectedDevices.accesskey = S
|
||||
getUserMedia.denyRequest.label = Don't Share
|
||||
|
@ -118,19 +118,30 @@ function prompt(aBrowser, aCallID, aAudioRequested, aVideoRequested, aDevices) {
|
||||
|
||||
let deviceIndex = 0;
|
||||
for (let device of devices) {
|
||||
let menuitem = chromeDoc.createElement("menuitem");
|
||||
menuitem.setAttribute("value", deviceIndex);
|
||||
menuitem.setAttribute("label", device.name);
|
||||
menuitem.setAttribute("tooltiptext", device.name);
|
||||
menupopup.appendChild(menuitem);
|
||||
addDeviceToList(menupopup, device.name, deviceIndex);
|
||||
deviceIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
function addDeviceToList(menupopup, deviceName, deviceIndex) {
|
||||
let menuitem = chromeDoc.createElement("menuitem");
|
||||
menuitem.setAttribute("value", deviceIndex);
|
||||
menuitem.setAttribute("label", deviceName);
|
||||
menuitem.setAttribute("tooltiptext", deviceName);
|
||||
menupopup.appendChild(menuitem);
|
||||
}
|
||||
|
||||
chromeDoc.getElementById("webRTC-selectCamera").hidden = !videoDevices.length;
|
||||
chromeDoc.getElementById("webRTC-selectMicrophone").hidden = !audioDevices.length;
|
||||
listDevices(chromeDoc.getElementById("webRTC-selectCamera-menupopup"), videoDevices);
|
||||
listDevices(chromeDoc.getElementById("webRTC-selectMicrophone-menupopup"), audioDevices);
|
||||
|
||||
let camMenupopup = chromeDoc.getElementById("webRTC-selectCamera-menupopup");
|
||||
let micMenupopup = chromeDoc.getElementById("webRTC-selectMicrophone-menupopup");
|
||||
listDevices(camMenupopup, videoDevices);
|
||||
listDevices(micMenupopup, audioDevices);
|
||||
if (requestType == "CameraAndMicrophone") {
|
||||
addDeviceToList(camMenupopup, stringBundle.getString("getUserMedia.noVideo.label"), "-1");
|
||||
addDeviceToList(micMenupopup, stringBundle.getString("getUserMedia.noAudio.label"), "-1");
|
||||
}
|
||||
|
||||
let mainAction = {
|
||||
label: PluralForm.get(requestType == "CameraAndMicrophone" ? 2 : 1,
|
||||
@ -141,12 +152,20 @@ function prompt(aBrowser, aCallID, aAudioRequested, aVideoRequested, aDevices) {
|
||||
.createInstance(Ci.nsISupportsArray);
|
||||
if (videoDevices.length) {
|
||||
let videoDeviceIndex = chromeDoc.getElementById("webRTC-selectCamera-menulist").value;
|
||||
allowedDevices.AppendElement(videoDevices[videoDeviceIndex]);
|
||||
if (videoDeviceIndex != "-1")
|
||||
allowedDevices.AppendElement(videoDevices[videoDeviceIndex]);
|
||||
}
|
||||
if (audioDevices.length) {
|
||||
let audioDeviceIndex = chromeDoc.getElementById("webRTC-selectMicrophone-menulist").value;
|
||||
allowedDevices.AppendElement(audioDevices[audioDeviceIndex]);
|
||||
if (audioDeviceIndex != "-1")
|
||||
allowedDevices.AppendElement(audioDevices[audioDeviceIndex]);
|
||||
}
|
||||
|
||||
if (allowedDevices.Count() == 0) {
|
||||
Services.obs.notifyObservers(null, "getUserMedia:response:deny", aCallID);
|
||||
return;
|
||||
}
|
||||
|
||||
Services.obs.notifyObservers(allowedDevices, "getUserMedia:response:allow", aCallID);
|
||||
|
||||
// Show browser-specific indicator for the active camera/mic access.
|
||||
|
Loading…
Reference in New Issue
Block a user