Bug 1320375 - Remove webrtcUI.showSharingDoorhanger's obsolete aType parameter, r=johannh.
authorFlorian Quèze <florian@queze.net>
Mon, 28 Nov 2016 12:29:31 +0100
changeset 324650 4d13fd025112b2e9da6433815bc2fc2abe0f883c
parent 324649 6992281f395d344cf6921297ecf83fe8df071188
child 324651 7636e8dc84d63a73436a9f7c5142a2db9c9e06da
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjohannh
bugs1320375
milestone53.0a1
Bug 1320375 - Remove webrtcUI.showSharingDoorhanger's obsolete aType parameter, r=johannh.
browser/base/content/test/webrtc/browser_devices_get_user_media.js
browser/base/content/webrtcIndicator.js
browser/modules/webrtcUI.jsm
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media.js
@@ -450,17 +450,17 @@ var gTests = [
     is((yield getMediaCaptureState()), "Camera", "expected camera to be shared");
 
     yield indicator;
     yield checkSharingUI({video: true});
 
     ok(gIdentityHandler._identityPopup.hidden, "control center should be hidden");
     if ("nsISystemStatusBar" in Ci) {
       let activeStreams = webrtcUI.getActiveStreams(true, false, false);
-      webrtcUI.showSharingDoorhanger(activeStreams[0], "Devices");
+      webrtcUI.showSharingDoorhanger(activeStreams[0]);
     }
     else {
       let win =
         Services.wm.getMostRecentWindow("Browser:WebRTCGlobalIndicator");
       let elt = win.document.getElementById("audioVideoButton");
       EventUtils.synthesizeMouseAtCenter(elt, {}, win);
       yield promiseWaitForCondition(() => !gIdentityHandler._identityPopup.hidden);
     }
--- a/browser/base/content/webrtcIndicator.js
+++ b/browser/base/content/webrtcIndicator.js
@@ -83,26 +83,25 @@ function updateWindowAttr(attr, value) {
   if (value)
     docEl.setAttribute(attr, "true");
   else
     docEl.removeAttribute(attr);
 }
 
 function onPopupMenuShowing(event) {
   let popup = event.target;
-  let type = popup.getAttribute("type");
 
   let activeStreams;
-  if (type == "Devices")
+  if (popup.getAttribute("type") == "Devices")
     activeStreams = webrtcUI.getActiveStreams(true, true, false);
   else
     activeStreams = webrtcUI.getActiveStreams(false, false, true);
 
   if (activeStreams.length == 1) {
-    webrtcUI.showSharingDoorhanger(activeStreams[0], type);
+    webrtcUI.showSharingDoorhanger(activeStreams[0]);
     event.preventDefault();
     return;
   }
 
   for (let stream of activeStreams) {
     let item = document.createElement("menuitem");
     item.setAttribute("label", stream.browser.contentTitle || stream.uri);
     item.setAttribute("tooltiptext", stream.uri);
@@ -113,19 +112,17 @@ function onPopupMenuShowing(event) {
 
 function onPopupMenuHiding(event) {
   let popup = event.target;
   while (popup.firstChild)
     popup.firstChild.remove();
 }
 
 function onPopupMenuCommand(event) {
-  let item = event.target;
-  webrtcUI.showSharingDoorhanger(item.stream,
-                                 item.parentNode.getAttribute("type"));
+  webrtcUI.showSharingDoorhanger(event.target.stream);
 }
 
 function onFirefoxButtonClick(event) {
   event.target.blur();
   let activeStreams = webrtcUI.getActiveStreams(true, true, true);
   activeStreams[0].browser.ownerGlobal.focus();
 }
 
--- a/browser/modules/webrtcUI.jsm
+++ b/browser/modules/webrtcUI.jsm
@@ -131,17 +131,17 @@ this.webrtcUI = {
         stream.browser = aNewBrowser;
     }
   },
 
   forgetStreamsFromBrowser: function(aBrowser) {
     this._streams = this._streams.filter(stream => stream.browser != aBrowser);
   },
 
-  showSharingDoorhanger: function(aActiveStream, aType) {
+  showSharingDoorhanger: function(aActiveStream) {
     let browserWindow = aActiveStream.browser.ownerGlobal;
     if (aActiveStream.tab) {
       browserWindow.gBrowser.selectedTab = aActiveStream.tab;
     } else {
       aActiveStream.browser.focus();
     }
     browserWindow.focus();
     let identityBox = browserWindow.document.getElementById("identity-box");
@@ -692,22 +692,17 @@ function getGlobalIndicator() {
 
     _hiddenDoc: Cc["@mozilla.org/appshell/appShellService;1"]
                   .getService(Ci.nsIAppShellService)
                   .hiddenDOMWindow.document,
     _statusBar: Cc["@mozilla.org/widget/macsystemstatusbar;1"]
                   .getService(Ci.nsISystemStatusBar),
 
     _command: function(aEvent) {
-      let type = this.getAttribute("type");
-      if (type == "Camera" || type == "Microphone")
-        type = "Devices";
-      else if (type == "Window" || type == "Application" || type == "Browser")
-        type = "Screen";
-      webrtcUI.showSharingDoorhanger(aEvent.target.stream, type);
+      webrtcUI.showSharingDoorhanger(aEvent.target.stream);
     },
 
     _popupShowing: function(aEvent) {
       let type = this.getAttribute("type");
       let activeStreams;
       if (type == "Camera") {
         activeStreams = webrtcUI.getActiveStreams(true, false, false);
       }
@@ -730,17 +725,16 @@ function getGlobalIndicator() {
         let label = stream.browser.contentTitle || stream.uri;
         menuitem.setAttribute("label", bundle.formatStringFromName(labelId, [label], 1));
         menuitem.setAttribute("disabled", "true");
         this.appendChild(menuitem);
 
         menuitem = this.ownerDocument.createElement("menuitem");
         menuitem.setAttribute("label",
                               bundle.GetStringFromName("webrtcIndicator.controlSharing.menuitem"));
-        menuitem.setAttribute("type", type);
         menuitem.stream = stream;
         menuitem.addEventListener("command", indicator._command);
 
         this.appendChild(menuitem);
         return true;
       }
 
       // We show a different menu when there are several active streams.
@@ -752,17 +746,16 @@ function getGlobalIndicator() {
       menuitem.setAttribute("disabled", "true");
       this.appendChild(menuitem);
 
       for (let stream of activeStreams) {
         let item = this.ownerDocument.createElement("menuitem");
         labelId = "webrtcIndicator.controlSharingOn.menuitem";
         label = stream.browser.contentTitle || stream.uri;
         item.setAttribute("label", bundle.formatStringFromName(labelId, [label], 1));
-        item.setAttribute("type", type);
         item.stream = stream;
         item.addEventListener("command", indicator._command);
         this.appendChild(item);
       }
 
       return true;
     },
 
@@ -827,40 +820,28 @@ function onTabSharingMenuPopupShowing(e)
 
     let doc = e.target.ownerDocument;
     let bundle = doc.defaultView.gNavigatorBundle;
 
     let origin = getHost(null, streamInfo.uri);
     let menuitem = doc.createElement("menuitem");
     menuitem.setAttribute("label", bundle.getFormattedString(stringName, [origin]));
     menuitem.stream = streamInfo;
-
-    // We can only open 1 doorhanger at a time. Guessing that users would be
-    // 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|Application/).test(stringName)) {
-      doorhangerType = "Screen";
-    } else {
-      doorhangerType = "Devices";
-    }
-    menuitem.setAttribute("doorhangertype", doorhangerType);
     menuitem.addEventListener("command", onTabSharingMenuPopupCommand);
     e.target.appendChild(menuitem);
   }
 }
 
 function onTabSharingMenuPopupHiding(e) {
   while (this.lastChild)
     this.lastChild.remove();
 }
 
 function onTabSharingMenuPopupCommand(e) {
-  let type = e.target.getAttribute("doorhangertype");
-  webrtcUI.showSharingDoorhanger(e.target.stream, type);
+  webrtcUI.showSharingDoorhanger(e.target.stream);
 }
 
 function showOrCreateMenuForWindow(aWindow) {
   let document = aWindow.document;
   let menu = document.getElementById("tabSharingMenu");
   if (!menu) {
     let stringBundle = aWindow.gNavigatorBundle;
     menu = document.createElement("menu");