Backed out changeset 77b01f2bda7f (bug 1320375)

This commit is contained in:
Carsten "Tomcat" Book 2016-11-28 15:56:41 +01:00
Родитель a76f886d3b
Коммит e402c17a68
3 изменённых файлов: 29 добавлений и 7 удалений

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

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

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

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

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

@ -136,7 +136,7 @@ this.webrtcUI = {
this._streams = this._streams.filter(stream => stream.browser != aBrowser);
},
showSharingDoorhanger: function(aActiveStream) {
showSharingDoorhanger: function(aActiveStream, aType) {
let browserWindow = aActiveStream.browser.ownerGlobal;
if (aActiveStream.tab) {
browserWindow.gBrowser.selectedTab = aActiveStream.tab;
@ -697,7 +697,12 @@ function getGlobalIndicator() {
.getService(Ci.nsISystemStatusBar),
_command: function(aEvent) {
webrtcUI.showSharingDoorhanger(aEvent.target.stream);
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);
},
_popupShowing: function(aEvent) {
@ -730,6 +735,7 @@ function getGlobalIndicator() {
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);
@ -751,6 +757,7 @@ function getGlobalIndicator() {
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);
@ -825,6 +832,17 @@ function onTabSharingMenuPopupShowing(e) {
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);
}
@ -836,7 +854,8 @@ function onTabSharingMenuPopupHiding(e) {
}
function onTabSharingMenuPopupCommand(e) {
webrtcUI.showSharingDoorhanger(e.target.stream);
let type = e.target.getAttribute("doorhangertype");
webrtcUI.showSharingDoorhanger(e.target.stream, type);
}
function showOrCreateMenuForWindow(aWindow) {