Bug 1320375 - Remove webrtcUI.showSharingDoorhanger's obsolete aType parameter, r=johannh.

This commit is contained in:
Florian Quèze 2016-11-28 12:29:31 +01:00
Родитель 10d60535cc
Коммит fc3cc50546
3 изменённых файлов: 7 добавлений и 29 удалений

Просмотреть файл

@ -455,7 +455,7 @@ var gTests = [
ok(gIdentityHandler._identityPopup.hidden, "control center should be hidden"); ok(gIdentityHandler._identityPopup.hidden, "control center should be hidden");
if ("nsISystemStatusBar" in Ci) { if ("nsISystemStatusBar" in Ci) {
let activeStreams = webrtcUI.getActiveStreams(true, false, false); let activeStreams = webrtcUI.getActiveStreams(true, false, false);
webrtcUI.showSharingDoorhanger(activeStreams[0], "Devices"); webrtcUI.showSharingDoorhanger(activeStreams[0]);
} }
else { else {
let win = let win =

Просмотреть файл

@ -88,16 +88,15 @@ function updateWindowAttr(attr, value) {
function onPopupMenuShowing(event) { function onPopupMenuShowing(event) {
let popup = event.target; let popup = event.target;
let type = popup.getAttribute("type");
let activeStreams; let activeStreams;
if (type == "Devices") if (popup.getAttribute("type") == "Devices")
activeStreams = webrtcUI.getActiveStreams(true, true, false); activeStreams = webrtcUI.getActiveStreams(true, true, false);
else else
activeStreams = webrtcUI.getActiveStreams(false, false, true); activeStreams = webrtcUI.getActiveStreams(false, false, true);
if (activeStreams.length == 1) { if (activeStreams.length == 1) {
webrtcUI.showSharingDoorhanger(activeStreams[0], type); webrtcUI.showSharingDoorhanger(activeStreams[0]);
event.preventDefault(); event.preventDefault();
return; return;
} }
@ -118,9 +117,7 @@ function onPopupMenuHiding(event) {
} }
function onPopupMenuCommand(event) { function onPopupMenuCommand(event) {
let item = event.target; webrtcUI.showSharingDoorhanger(event.target.stream);
webrtcUI.showSharingDoorhanger(item.stream,
item.parentNode.getAttribute("type"));
} }
function onFirefoxButtonClick(event) { function onFirefoxButtonClick(event) {

Просмотреть файл

@ -136,7 +136,7 @@ this.webrtcUI = {
this._streams = this._streams.filter(stream => stream.browser != aBrowser); this._streams = this._streams.filter(stream => stream.browser != aBrowser);
}, },
showSharingDoorhanger: function(aActiveStream, aType) { showSharingDoorhanger: function(aActiveStream) {
let browserWindow = aActiveStream.browser.ownerGlobal; let browserWindow = aActiveStream.browser.ownerGlobal;
if (aActiveStream.tab) { if (aActiveStream.tab) {
browserWindow.gBrowser.selectedTab = aActiveStream.tab; browserWindow.gBrowser.selectedTab = aActiveStream.tab;
@ -697,12 +697,7 @@ function getGlobalIndicator() {
.getService(Ci.nsISystemStatusBar), .getService(Ci.nsISystemStatusBar),
_command: function(aEvent) { _command: function(aEvent) {
let type = this.getAttribute("type"); webrtcUI.showSharingDoorhanger(aEvent.target.stream);
if (type == "Camera" || type == "Microphone")
type = "Devices";
else if (type == "Window" || type == "Application" || type == "Browser")
type = "Screen";
webrtcUI.showSharingDoorhanger(aEvent.target.stream, type);
}, },
_popupShowing: function(aEvent) { _popupShowing: function(aEvent) {
@ -735,7 +730,6 @@ function getGlobalIndicator() {
menuitem = this.ownerDocument.createElement("menuitem"); menuitem = this.ownerDocument.createElement("menuitem");
menuitem.setAttribute("label", menuitem.setAttribute("label",
bundle.GetStringFromName("webrtcIndicator.controlSharing.menuitem")); bundle.GetStringFromName("webrtcIndicator.controlSharing.menuitem"));
menuitem.setAttribute("type", type);
menuitem.stream = stream; menuitem.stream = stream;
menuitem.addEventListener("command", indicator._command); menuitem.addEventListener("command", indicator._command);
@ -757,7 +751,6 @@ function getGlobalIndicator() {
labelId = "webrtcIndicator.controlSharingOn.menuitem"; labelId = "webrtcIndicator.controlSharingOn.menuitem";
label = stream.browser.contentTitle || stream.uri; label = stream.browser.contentTitle || stream.uri;
item.setAttribute("label", bundle.formatStringFromName(labelId, [label], 1)); item.setAttribute("label", bundle.formatStringFromName(labelId, [label], 1));
item.setAttribute("type", type);
item.stream = stream; item.stream = stream;
item.addEventListener("command", indicator._command); item.addEventListener("command", indicator._command);
this.appendChild(item); this.appendChild(item);
@ -832,17 +825,6 @@ function onTabSharingMenuPopupShowing(e) {
let menuitem = doc.createElement("menuitem"); let menuitem = doc.createElement("menuitem");
menuitem.setAttribute("label", bundle.getFormattedString(stringName, [origin])); menuitem.setAttribute("label", bundle.getFormattedString(stringName, [origin]));
menuitem.stream = streamInfo; 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); menuitem.addEventListener("command", onTabSharingMenuPopupCommand);
e.target.appendChild(menuitem); e.target.appendChild(menuitem);
} }
@ -854,8 +836,7 @@ function onTabSharingMenuPopupHiding(e) {
} }
function onTabSharingMenuPopupCommand(e) { function onTabSharingMenuPopupCommand(e) {
let type = e.target.getAttribute("doorhangertype"); webrtcUI.showSharingDoorhanger(e.target.stream);
webrtcUI.showSharingDoorhanger(e.target.stream, type);
} }
function showOrCreateMenuForWindow(aWindow) { function showOrCreateMenuForWindow(aWindow) {