Bug 1037408 - add booleans to webrtcUI indicating which sharing indicators should be shown, r=dolske.
☠☠ backed out by 876659559bd8 ☠ ☠
authorFlorian Quèze <florian@queze.net>
Sat, 19 Jul 2014 02:49:18 +0200
changeset 217029 f875dc5e0df7ff0e95a6d0a7fc5527d260315749
parent 217028 356c0e9159457142755ab166338f07458f6dc6b0
child 217030 c9cfdc0bbfbce5cd4b4fc0a2d876d71ce86400de
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs1037408
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1037408 - add booleans to webrtcUI indicating which sharing indicators should be shown, r=dolske.
browser/modules/webrtcUI.jsm
--- a/browser/modules/webrtcUI.jsm
+++ b/browser/modules/webrtcUI.jsm
@@ -29,16 +29,19 @@ this.webrtcUI = {
 
   uninit: function () {
     Services.obs.removeObserver(handleRequest, "getUserMedia:request");
     Services.obs.removeObserver(updateIndicators, "recording-device-events");
     Services.obs.removeObserver(removeBrowserSpecificIndicator, "recording-window-ended");
   },
 
   showGlobalIndicator: false,
+  showCameraIndicator: false,
+  showMicrophoneIndicator: false,
+  showScreenSharingIndicator: "", // either "Screen" or "Window"
 
   get activeStreams() {
     let contentWindowSupportsArray = MediaManagerService.activeMediaCaptureWindows;
     let count = contentWindowSupportsArray.Count();
     let activeStreams = [];
     for (let i = 0; i < count; i++) {
       let contentWindow = contentWindowSupportsArray.GetElementAt(i);
       let browser = getBrowserForWindow(contentWindow);
@@ -385,25 +388,45 @@ function prompt(aContentWindow, aCallID,
     anchorId = "webRTC-shareMicrophone-notification-icon";
   if (requestTypes.indexOf("Screen") != -1)
     anchorId = "webRTC-shareScreen-notification-icon";
   chromeWin.PopupNotifications.show(browser, "webRTC-shareDevices", message,
                                     anchorId, mainAction, secondaryActions, options);
 }
 
 function updateIndicators() {
-  webrtcUI.showGlobalIndicator =
-    MediaManagerService.activeMediaCaptureWindows.Count() > 0;
+  let contentWindowSupportsArray = MediaManagerService.activeMediaCaptureWindows;
+  let count = contentWindowSupportsArray.Count();
+
+  webrtcUI.showGlobalIndicator = count > 0;
 
   let e = Services.wm.getEnumerator("navigator:browser");
   while (e.hasMoreElements())
     e.getNext().WebrtcIndicator.updateButton();
 
-  for (let {browser: browser} of webrtcUI.activeStreams)
-    showBrowserSpecificIndicator(browser);
+  webrtcUI.showCameraIndicator = false;
+  webrtcUI.showMicrophoneIndicator = false;
+  webrtcUI.showScreenSharingIndicator = "";
+
+  for (let i = 0; i < count; ++i) {
+    let contentWindow = contentWindowSupportsArray.GetElementAt(i);
+    let camera = {}, microphone = {}, screen = {}, window = {};
+    MediaManagerService.mediaCaptureWindowState(contentWindow, camera,
+                                                microphone, screen, window);
+    if (camera.value)
+      webrtcUI.showCameraIndicator = true;
+    if (microphone.value)
+      webrtcUI.showMicrophoneIndicator = true;
+    if (screen.value)
+      webrtcUI.showScreenSharingIndicator = "Screen";
+    else if (window.value && !webrtcUI.showScreenSharingIndicator)
+      webrtcUI.showScreenSharingIndicator = "Window";
+
+    showBrowserSpecificIndicator(getBrowserForWindow(contentWindow));
+  }
 }
 
 function showBrowserSpecificIndicator(aBrowser) {
   let camera = {}, microphone = {}, screen = {}, window = {};
   MediaManagerService.mediaCaptureWindowState(aBrowser.contentWindow,
                                               camera, microphone, screen, window);
   let captureState;
   if (camera.value && microphone.value) {