зеркало из https://github.com/mozilla/gecko-dev.git
Bug 802421 - Allow specifying a mic and a camera in the doorhanger UI when audio and video are both requested through gUM. r=gavin
This commit is contained in:
Родитель
2b5cf2df81
Коммит
446803387b
|
@ -443,6 +443,27 @@
|
|||
<label class="tooltip-label" value="&backForwardButtonMenu.tooltip;"/>
|
||||
#endif
|
||||
</tooltip>
|
||||
|
||||
<popupnotification id="webRTC-shareDevices-notification" hidden="true">
|
||||
<popupnotificationcontent id="webRTC-selectCamera" orient="vertical">
|
||||
<separator class="thin"/>
|
||||
<label value="&getUserMedia.selectCamera.label;"
|
||||
accesskey="&getUserMedia.selectCamera.accesskey;"
|
||||
control="webRTC-selectCamera-menulist"/>
|
||||
<menulist id="webRTC-selectCamera-menulist">
|
||||
<menupopup id="webRTC-selectCamera-menupopup"/>
|
||||
</menulist>
|
||||
</popupnotificationcontent>
|
||||
<popupnotificationcontent id="webRTC-selectMicrophone" orient="vertical">
|
||||
<separator class="thin"/>
|
||||
<label value="&getUserMedia.selectMicrophone.label;"
|
||||
accesskey="&getUserMedia.selectMicrophone.accesskey;"
|
||||
control="webRTC-selectMicrophone-menulist"/>
|
||||
<menulist id="webRTC-selectMicrophone-menulist">
|
||||
<menupopup id="webRTC-selectMicrophone-menupopup"/>
|
||||
</menulist>
|
||||
</popupnotificationcontent>
|
||||
</popupnotification>
|
||||
</popupset>
|
||||
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
|
|
|
@ -623,3 +623,8 @@ just addresses the organization to follow, e.g. "This site is run by " -->
|
|||
<!ENTITY social.chatBar.commandkey "c">
|
||||
<!ENTITY social.chatBar.label "Focus chats">
|
||||
<!ENTITY social.chatBar.accesskey "c">
|
||||
|
||||
<!ENTITY getUserMedia.selectCamera.label "Camera to share:">
|
||||
<!ENTITY getUserMedia.selectCamera.accesskey "C">
|
||||
<!ENTITY getUserMedia.selectMicrophone.label "Microphone to share:">
|
||||
<!ENTITY getUserMedia.selectMicrophone.accesskey "M">
|
||||
|
|
|
@ -442,17 +442,15 @@ identity.loggedIn.signOut.label = Sign Out
|
|||
identity.loggedIn.signOut.accessKey = O
|
||||
|
||||
# LOCALIZATION NOTE (getUserMedia.shareCamera.message, getUserMedia.shareMicrophone.message, getUserMedia.shareCameraAndMicrophone.message): %S is the website origin (e.g. www.mozilla.org)
|
||||
# LOCALIZATION NOTE (getUserMedia.shareMicrophone.message, getUserMedia.shareSpecificMicrophone.label): %S is the website origin (e.g. www.mozilla.org)
|
||||
# LOCALIZATION NOTE (getUserMedia.shareMicrophone.message): %S is the website origin (e.g. www.mozilla.org)
|
||||
# LOCALIZATION NOTE (getUserMedia.shareSelectedDevices.label):
|
||||
# Semi-colon list of plural forms. See:
|
||||
# http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# The number of devices can be either one or two.
|
||||
getUserMedia.shareCamera.message = Would you like to share your camera with %S?
|
||||
getUserMedia.shareCamera.label = Share Camera
|
||||
getUserMedia.shareCamera.accesskey = S
|
||||
getUserMedia.shareSpecificCamera.label = Share Camera: %S
|
||||
getUserMedia.shareMicrophone.message = Would you like to share your microphone with %S?
|
||||
getUserMedia.shareMicrophone.label = Share Microphone
|
||||
getUserMedia.shareMicrophone.accesskey = S
|
||||
getUserMedia.shareSpecificMicrophone.label = Share Microphone: %S
|
||||
getUserMedia.shareCameraAndMicrophone.message = Would you like to share your camera and microphone with %S?
|
||||
getUserMedia.shareCameraAndMicrophone.label = Share Camera and Microphone
|
||||
getUserMedia.shareCameraAndMicrophone.accesskey = S
|
||||
getUserMedia.shareSelectedDevices.label = Share Selected Device;Share Selected Devices
|
||||
getUserMedia.shareSelectedDevices.accesskey = S
|
||||
getUserMedia.denyRequest.label = Don't Share
|
||||
getUserMedia.denyRequest.accesskey = D
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
this.EXPORTED_SYMBOLS = ["webrtcUI"];
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
this.webrtcUI = {
|
||||
init: function () {
|
||||
|
@ -72,47 +74,58 @@ function prompt(aBrowser, aCallID, aAudioRequested, aVideoRequested, aDevices) {
|
|||
return;
|
||||
|
||||
let host = aBrowser.contentDocument.documentURIObject.asciiHost;
|
||||
let chromeWin = aBrowser.ownerDocument.defaultView;
|
||||
let chromeDoc = aBrowser.ownerDocument;
|
||||
let chromeWin = chromeDoc.defaultView;
|
||||
let stringBundle = chromeWin.gNavigatorBundle;
|
||||
let message = stringBundle.getFormattedString("getUserMedia." + requestType + ".message",
|
||||
[ host ]);
|
||||
|
||||
function listDevices(menupopup, devices) {
|
||||
while (menupopup.lastChild)
|
||||
menupopup.removeChild(menupopup.lastChild);
|
||||
|
||||
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);
|
||||
deviceIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
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 mainAction = {
|
||||
label: stringBundle.getString("getUserMedia." + requestType + ".label"),
|
||||
accessKey: stringBundle.getString("getUserMedia." + requestType + ".accesskey"),
|
||||
label: PluralForm.get(requestType == "shareCameraAndMicrophone" ? 2 : 1,
|
||||
stringBundle.getString("getUserMedia.shareSelectedDevices.label")),
|
||||
accessKey: stringBundle.getString("getUserMedia.shareSelectedDevices.accesskey"),
|
||||
callback: function () {
|
||||
Services.obs.notifyObservers(null, "getUserMedia:response:allow", aCallID);
|
||||
let allowedDevices = Cc["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Ci.nsISupportsArray);
|
||||
if (videoDevices.length) {
|
||||
let videoDeviceIndex = chromeDoc.getElementById("webRTC-selectCamera-menulist").value;
|
||||
allowedDevices.AppendElement(videoDevices[videoDeviceIndex]);
|
||||
}
|
||||
if (audioDevices.length) {
|
||||
let audioDeviceIndex = chromeDoc.getElementById("webRTC-selectMicrophone-menulist").value;
|
||||
allowedDevices.AppendElement(audioDevices[audioDeviceIndex]);
|
||||
}
|
||||
Services.obs.notifyObservers(allowedDevices, "getUserMedia:response:allow", aCallID);
|
||||
}
|
||||
};
|
||||
|
||||
let secondaryActions = [];
|
||||
let selectableDevices = videoDevices.length ? videoDevices : audioDevices;
|
||||
if (selectableDevices.length > 1) {
|
||||
let selectableDeviceNumber = 0;
|
||||
for (let device of selectableDevices) {
|
||||
// See bug 449811 for why we do this
|
||||
let actual_device = device;
|
||||
selectableDeviceNumber++;
|
||||
secondaryActions.push({
|
||||
label: stringBundle.getFormattedString(
|
||||
device.type == "audio" ?
|
||||
"getUserMedia.shareSpecificMicrophone.label" :
|
||||
"getUserMedia.shareSpecificCamera.label",
|
||||
[ device.name ]),
|
||||
accessKey: selectableDeviceNumber,
|
||||
callback: function () {
|
||||
Services.obs.notifyObservers(actual_device, "getUserMedia:response:allow", aCallID);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
secondaryActions.push({
|
||||
let secondaryActions = [{
|
||||
label: stringBundle.getString("getUserMedia.denyRequest.label"),
|
||||
accessKey: stringBundle.getString("getUserMedia.denyRequest.accesskey"),
|
||||
callback: function () {
|
||||
Services.obs.notifyObservers(null, "getUserMedia:response:deny", aCallID);
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
let options = {
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче