mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
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:
parent
2b5cf2df81
commit
446803387b
@ -443,6 +443,27 @@
|
|||||||
<label class="tooltip-label" value="&backForwardButtonMenu.tooltip;"/>
|
<label class="tooltip-label" value="&backForwardButtonMenu.tooltip;"/>
|
||||||
#endif
|
#endif
|
||||||
</tooltip>
|
</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>
|
</popupset>
|
||||||
|
|
||||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
#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.commandkey "c">
|
||||||
<!ENTITY social.chatBar.label "Focus chats">
|
<!ENTITY social.chatBar.label "Focus chats">
|
||||||
<!ENTITY social.chatBar.accesskey "c">
|
<!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
|
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.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.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.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.message = Would you like to share your camera and microphone with %S?
|
||||||
getUserMedia.shareCameraAndMicrophone.label = Share Camera and Microphone
|
getUserMedia.shareSelectedDevices.label = Share Selected Device;Share Selected Devices
|
||||||
getUserMedia.shareCameraAndMicrophone.accesskey = S
|
getUserMedia.shareSelectedDevices.accesskey = S
|
||||||
getUserMedia.denyRequest.label = Don't Share
|
getUserMedia.denyRequest.label = Don't Share
|
||||||
getUserMedia.denyRequest.accesskey = D
|
getUserMedia.denyRequest.accesskey = D
|
||||||
|
@ -7,9 +7,11 @@
|
|||||||
this.EXPORTED_SYMBOLS = ["webrtcUI"];
|
this.EXPORTED_SYMBOLS = ["webrtcUI"];
|
||||||
|
|
||||||
const Cu = Components.utils;
|
const Cu = Components.utils;
|
||||||
|
const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
Cu.import("resource://gre/modules/PluralForm.jsm");
|
||||||
|
|
||||||
this.webrtcUI = {
|
this.webrtcUI = {
|
||||||
init: function () {
|
init: function () {
|
||||||
@ -72,47 +74,58 @@ function prompt(aBrowser, aCallID, aAudioRequested, aVideoRequested, aDevices) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
let host = aBrowser.contentDocument.documentURIObject.asciiHost;
|
let host = aBrowser.contentDocument.documentURIObject.asciiHost;
|
||||||
let chromeWin = aBrowser.ownerDocument.defaultView;
|
let chromeDoc = aBrowser.ownerDocument;
|
||||||
|
let chromeWin = chromeDoc.defaultView;
|
||||||
let stringBundle = chromeWin.gNavigatorBundle;
|
let stringBundle = chromeWin.gNavigatorBundle;
|
||||||
let message = stringBundle.getFormattedString("getUserMedia." + requestType + ".message",
|
let message = stringBundle.getFormattedString("getUserMedia." + requestType + ".message",
|
||||||
[ host ]);
|
[ 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 = {
|
let mainAction = {
|
||||||
label: stringBundle.getString("getUserMedia." + requestType + ".label"),
|
label: PluralForm.get(requestType == "shareCameraAndMicrophone" ? 2 : 1,
|
||||||
accessKey: stringBundle.getString("getUserMedia." + requestType + ".accesskey"),
|
stringBundle.getString("getUserMedia.shareSelectedDevices.label")),
|
||||||
|
accessKey: stringBundle.getString("getUserMedia.shareSelectedDevices.accesskey"),
|
||||||
callback: function () {
|
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 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({
|
|
||||||
label: stringBundle.getString("getUserMedia.denyRequest.label"),
|
label: stringBundle.getString("getUserMedia.denyRequest.label"),
|
||||||
accessKey: stringBundle.getString("getUserMedia.denyRequest.accesskey"),
|
accessKey: stringBundle.getString("getUserMedia.denyRequest.accesskey"),
|
||||||
callback: function () {
|
callback: function () {
|
||||||
Services.obs.notifyObservers(null, "getUserMedia:response:deny", aCallID);
|
Services.obs.notifyObservers(null, "getUserMedia:response:deny", aCallID);
|
||||||
}
|
}
|
||||||
});
|
}];
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user