Bug 1057006 - Implement UI for app sharing, r=Gijs.

This commit is contained in:
Florian Quèze 2014-08-27 16:52:22 +02:00
parent 4ea3a104aa
commit 62156f6da6
5 changed files with 82 additions and 55 deletions

View File

@ -21,8 +21,7 @@
<popupnotificationcontent id="webRTC-selectWindowOrScreen" orient="vertical">
<separator class="thin"/>
<label value="&getUserMedia.selectWindowOrScreen.label;"
accesskey="&getUserMedia.selectWindowOrScreen.accesskey;"
<label id="webRTC-selectWindow-label"
control="webRTC-selectWindow-menulist"/>
<menulist id="webRTC-selectWindow-menulist"
oncommand="gWebRTCUI.updateMainActionLabel(this);">

View File

@ -718,8 +718,6 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!ENTITY getUserMedia.selectCamera.label "Camera to share:">
<!ENTITY getUserMedia.selectCamera.accesskey "C">
<!ENTITY getUserMedia.selectWindowOrScreen.label "Window or screen to share:">
<!ENTITY getUserMedia.selectWindowOrScreen.accesskey "W">
<!ENTITY getUserMedia.selectMicrophone.label "Microphone to share:">
<!ENTITY getUserMedia.selectMicrophone.accesskey "M">
<!ENTITY getUserMedia.allWindowsShared.message "All visible windows on your screen will be shared.">

View File

@ -515,8 +515,16 @@ getUserMedia.shareMicrophone.message = Would you like to share your microphone w
getUserMedia.shareScreen.message = Would you like to share your screen with %S?
getUserMedia.shareCameraAndMicrophone.message = Would you like to share your camera and microphone with %S?
getUserMedia.shareScreenAndMicrophone.message = Would you like to share your microphone and screen with %S?
getUserMedia.selectWindow.label=Window to share:
getUserMedia.selectWindow.accesskey=W
getUserMedia.selectScreen.label=Screen to share:
getUserMedia.selectScreen.accesskey=S
getUserMedia.selectApplication.label=Application to share:
getUserMedia.selectApplication.accesskey=A
getUserMedia.noVideo.label = No Video
getUserMedia.noWindowOrScreen.label = No Window or Screen
getUserMedia.noApplication.label = No Application
getUserMedia.noScreen.label = No Screen
getUserMedia.noWindow.label = No Window
getUserMedia.noAudio.label = No Audio
getUserMedia.shareEntireScreen.label = Entire screen
# LOCALIZATION NOTE (getUserMedia.shareSelectedDevices.label):
@ -526,6 +534,7 @@ getUserMedia.shareEntireScreen.label = Entire screen
getUserMedia.shareSelectedDevices.label = Share Selected Device;Share Selected Devices
getUserMedia.shareSelectedDevices.accesskey = S
getUserMedia.shareScreen.label = Share Screen
getUserMedia.shareApplication.label = Share Selected Application
getUserMedia.shareWindow.label = Share Selected Window
getUserMedia.shareSelectedItems.label = Share Selected Items
getUserMedia.always.label = Always Share
@ -537,6 +546,7 @@ getUserMedia.never.accesskey = N
getUserMedia.sharingCamera.message2 = You are currently sharing your camera with this page.
getUserMedia.sharingMicrophone.message2 = You are currently sharing your microphone with this page.
getUserMedia.sharingCameraAndMicrophone.message2 = You are currently sharing your camera and microphone with this page.
getUserMedia.sharingApplication.message = You are currently sharing an application with this page.
getUserMedia.sharingScreen.message = You are currently sharing your screen with this page.
getUserMedia.sharingWindow.message = You are currently sharing a window with this page.
getUserMedia.continueSharing.label = Continue Sharing
@ -547,20 +557,26 @@ getUserMedia.stopSharing.accesskey = S
getUserMedia.sharingMenu.label = Tabs sharing devices
getUserMedia.sharingMenu.accesskey = d
# LOCALIZATION NOTE (getUserMedia.sharingMenuCamera, getUserMedia.sharingMenuCamera,
# getUserMedia.sharingMenuMicrophone, getUserMedia.sharingMenuScreen,
# getUserMedia.sharingMenuWindow, getUserMedia.sharingMenuCameraMicrophone,
# getUserMedia.sharingMenuMicrophone, getUserMedia.sharingMenuApplication,
# getUserMedia.sharingMenuScreen, getUserMedia.sharingMenuWindow,
# getUserMedia.sharingMenuCameraMicrophone,
# getUserMedia.sharingMenuCameraMicrophoneApplication,
# getUserMedia.sharingMenuCameraMicrophoneScreen,
# getUserMedia.sharingMenuCameraMicrophoneWindow,
# getUserMedia.sharingMenuMicrophoneApplication,
# getUserMedia.sharingMenuMicrophoneScreen,
# getUserMedia.sharingMenuMicrophoneWindow):
# %S is the website origin (e.g. www.mozilla.org)
getUserMedia.sharingMenuCamera = %S (camera)
getUserMedia.sharingMenuMicrophone = %S (microphone)
getUserMedia.sharingMenuApplication = %S (application)
getUserMedia.sharingMenuScreen = %S (screen)
getUserMedia.sharingMenuWindow = %S (window)
getUserMedia.sharingMenuCameraMicrophone = %S (camera and microphone)
getUserMedia.sharingMenuCameraMicrophoneApplication = %S (camera, microphone and application)
getUserMedia.sharingMenuCameraMicrophoneScreen = %S (camera, microphone and screen)
getUserMedia.sharingMenuCameraMicrophoneWindow = %S (camera, microphone and window)
getUserMedia.sharingMenuMicrophoneApplication = %S (microphone and application)
getUserMedia.sharingMenuMicrophoneScreen = %S (microphone and screen)
getUserMedia.sharingMenuMicrophoneWindow = %S (microphone and window)
# LOCALIZATION NOTE(getUserMedia.sharingMenuUnknownHost): this is used for the website

View File

@ -12,6 +12,7 @@ webrtcIndicator.windowtitle = %S - Sharing Indicator
webrtcIndicator.sharingCameraAndMicrophone.tooltip = Your camera and microphone are being shared. Click to control sharing.
webrtcIndicator.sharingCamera.tooltip = Your camera is being shared. Click to control sharing.
webrtcIndicator.sharingMicrophone.tooltip = Your microphone is being shared. Click to control sharing.
webrtcIndicator.sharingApplication.tooltip = An application is being shared. Click to control sharing.
webrtcIndicator.sharingScreen.tooltip = Your screen is being shared. Click to control sharing.
webrtcIndicator.sharingWindow.tooltip = A window is being shared. Click to control sharing.
@ -23,6 +24,7 @@ webrtcIndicator.sharingWindow.tooltip = A window is being shared. Click to contr
# %S is the title of the tab using the share.
webrtcIndicator.sharingCameraWith.menuitem = Sharing Camera with "%S"
webrtcIndicator.sharingMicrophoneWith.menuitem = Sharing Microphone with "%S"
webrtcIndicator.sharingApplicationWith.menuitem = Sharing an Application with "%S"
webrtcIndicator.sharingScreenWith.menuitem = Sharing Screen with "%S"
webrtcIndicator.sharingWindowWith.menuitem = Sharing a Window with "%S"
webrtcIndicator.controlSharing.menuitem = Control Sharing
@ -30,6 +32,7 @@ webrtcIndicator.controlSharing.menuitem = Control Sharing
# Semicolon-separated list of plural forms.
webrtcIndicator.sharingCameraWithNTabs.menuitem = Sharing Camera with #1 tab;Sharing Camera with #1 tabs
webrtcIndicator.sharingMicrophoneWithNTabs.menuitem = Sharing Microphone with #1 tab;Sharing Microphone with #1 tabs
webrtcIndicator.sharingApplicationWithNTabs.menuitem = Sharing an Application with #1 tab;Sharing Applications with #1 tabs
webrtcIndicator.sharingScreenWithNTabs.menuitem = Sharing Screen with #1 tab;Sharing Screen with #1 tabs
webrtcIndicator.sharingWindowWithNTabs.menuitem = Sharing a Window with #1 tab;Sharing Windows with #1 tabs
# LOCALIZATION NOTE (webrtcIndicator.controlSharingOn.menuitem):

View File

@ -38,7 +38,7 @@ this.webrtcUI = {
showGlobalIndicator: false,
showCameraIndicator: false,
showMicrophoneIndicator: false,
showScreenSharingIndicator: "", // either "Screen" or "Window"
showScreenSharingIndicator: "", // either "Application", "Screen" or "Window"
// The boolean parameters indicate which streams should be included in the result.
getActiveStreams: function(aCamera, aMicrophone, aScreen) {
@ -53,13 +53,15 @@ this.webrtcUI = {
Microphone: {},
Window: {},
Screen: {},
Application: {}
};
MediaManagerService.mediaCaptureWindowState(contentWindow, info.Camera,
info.Microphone, info.Screen,
info.Window);
info.Window, info.Application);
if (!(aCamera && info.Camera.value ||
aMicrophone && info.Microphone.value ||
aScreen && (info.Screen.value || info.Window.value)))
aScreen && (info.Screen.value || info.Window.value ||
info.Application.value)))
continue;
let browser = getBrowserForWindow(contentWindow);
@ -329,38 +331,36 @@ function prompt(aContentWindow, aCallID, aAudio, aVideo, aDevices, aSecure) {
while (menupopup.lastChild)
menupopup.removeChild(menupopup.lastChild);
// "No Window or Screen" is the default because we can't pick a
let type = devices[0].mediaSource;
let typeName = type.charAt(0).toUpperCase() + type.substr(1);
let label = chromeDoc.getElementById("webRTC-selectWindow-label");
let stringId = "getUserMedia.select" + typeName;
label.setAttribute("value",
stringBundle.getString(stringId + ".label"));
label.setAttribute("accesskey",
stringBundle.getString(stringId + ".accesskey"));
// "No <type>" is the default because we can't pick a
// 'default' window to share.
addDeviceToList(menupopup,
stringBundle.getString("getUserMedia.noWindowOrScreen.label"),
stringBundle.getString("getUserMedia.no" + typeName + ".label"),
"-1");
menupopup.appendChild(chromeDoc.createElement("menuseparator"));
// Then add the 'Entire screen' item if mozGetUserMediaDevices returned it.
// Build the list of 'devices'.
for (let i = 0; i < devices.length; ++i) {
if (devices[i].mediaSource == "screen") {
menupopup.appendChild(chromeDoc.createElement("menuseparator"));
addDeviceToList(menupopup,
stringBundle.getString("getUserMedia.shareEntireScreen.label"),
i, "Screen");
break;
}
let name;
// Screen has a special treatment because we currently only support
// sharing the primary screen and want to display a localized string.
if (type == "screen")
name = stringBundle.getString("getUserMedia.shareEntireScreen.label");
else
name = devices[i].name;
addDeviceToList(menupopup, name, i, typeName);
}
// Finally add all the window names.
let separatorNeeded = true;
for (let i = 0; i < devices.length; ++i) {
// treat window and application as the same for UI purposes
let deviceMediaSource = devices[i].mediaSource;
if (deviceMediaSource == "window" || deviceMediaSource == "application") {
if (separatorNeeded) {
menupopup.appendChild(chromeDoc.createElement("menuseparator"));
separatorNeeded = false;
}
addDeviceToList(menupopup, devices[i].name, i, "Window");
}
}
// Always re-select the "No Window or Screen" item.
// Always re-select the "No <type>" item.
chromeDoc.getElementById("webRTC-selectWindow-menulist").removeAttribute("value");
chromeDoc.getElementById("webRTC-all-windows-shared").hidden = true;
}
@ -462,7 +462,7 @@ function getGlobalIndicator() {
let type = this.getAttribute("type");
if (type == "Camera" || type == "Microphone")
type = "Devices";
else if (type == "Window")
else if (type == "Window" || type == "Application")
type = "Screen";
webrtcUI.showSharingDoorhanger(aEvent.target.stream, type);
},
@ -580,15 +580,17 @@ function onTabSharingMenuPopupShowing(e) {
let streams = webrtcUI.getActiveStreams(true, true, true);
for (let streamInfo of streams) {
let stringName = "getUserMedia.sharingMenu";
// Guarantee sorting order here or bad things will happen if
// the not-specced-but-implemented-everywhere object key sorting changes:
let types = Object.keys(streamInfo.types).sort();
// Then construct a string ID out of these types:
for (let type of types) {
if (streamInfo.types[type].value) {
stringName += type;
}
}
let types = streamInfo.types;
if (types.Camera.value)
stringName += "Camera";
if (types.Microphone.value)
stringName += "Microphone";
if (types.Screen.value)
stringName += "Screen";
else if (types.Application.value)
stringName += "Application";
else if (types.Window.value)
stringName += "Window";
let doc = e.target.ownerDocument;
let bundle = doc.defaultView.gNavigatorBundle;
@ -615,10 +617,10 @@ function onTabSharingMenuPopupShowing(e) {
menuitem.stream = streamInfo;
// We can only open 1 doorhanger at a time. Guessing that users would be
// most eager to control screen/window sharing, and only then
// most eager to control screen/window/app sharing, and only then
// camera/microphone sharing, in that (decreasing) order of priority.
let doorhangerType;
if ((/Screen|Window/).test(stringName)) {
if ((/Screen|Window|Application/).test(stringName)) {
doorhangerType = "Screen";
} else {
doorhangerType = "Devices";
@ -693,17 +695,19 @@ function updateIndicators() {
for (let i = 0; i < count; ++i) {
let contentWindow = contentWindowSupportsArray.GetElementAt(i);
let camera = {}, microphone = {}, screen = {}, window = {};
let camera = {}, microphone = {}, screen = {}, window = {}, app = {};
MediaManagerService.mediaCaptureWindowState(contentWindow, camera,
microphone, screen, window);
microphone, screen, window, app);
if (camera.value)
webrtcUI.showCameraIndicator = true;
if (microphone.value)
webrtcUI.showMicrophoneIndicator = true;
if (screen.value)
webrtcUI.showScreenSharingIndicator = "Screen";
else if (window.value && !webrtcUI.showScreenSharingIndicator)
else if (window.value && webrtcUI.showScreenSharingIndicator != "Screen")
webrtcUI.showScreenSharingIndicator = "Window";
else if (app.value && !webrtcUI.showScreenSharingIndicator)
webrtcUI.showScreenSharingIndicator = "Application";
updateBrowserSpecificIndicator(getBrowserForWindow(contentWindow));
}
@ -740,9 +744,10 @@ function updateIndicators() {
}
function updateBrowserSpecificIndicator(aBrowser) {
let camera = {}, microphone = {}, screen = {}, window = {};
let camera = {}, microphone = {}, screen = {}, window = {}, app = {};
MediaManagerService.mediaCaptureWindowState(aBrowser.contentWindow,
camera, microphone, screen, window);
camera, microphone, screen,
window, app);
let captureState;
if (camera.value && microphone.value) {
captureState = "CameraAndMicrophone";
@ -805,7 +810,7 @@ function updateBrowserSpecificIndicator(aBrowser) {
}
// Now handle the screen sharing indicator.
if (!screen.value && !window.value) {
if (!screen.value && !window.value && !app.value) {
removeBrowserNotification(aBrowser,"webRTC-sharingScreen");
return;
}
@ -829,9 +834,15 @@ function updateBrowserSpecificIndicator(aBrowser) {
}
}];
// If we are sharing both a window and the screen, show 'Screen'.
let stringId = "getUserMedia.sharing" + (screen.value ? "Screen" : "Window") + ".message";
let stringId = "getUserMedia.sharing";
if (screen.value)
stringId += "Screen";
else if (app.value)
stringId += "Application";
else
stringId += "Window";
chromeWin.PopupNotifications.show(aBrowser, "webRTC-sharingScreen",
stringBundle.getString(stringId),
stringBundle.getString(stringId + ".message"),
"webRTC-sharingScreen-notification-icon",
mainAction, secondaryActions, options);
}