Bug 1232707 - Import the latest version of the Loop system add-on. r=me for import of already reviewed code.
This commit is contained in:
59
browser/extensions/loop/bootstrap.js
vendored
59
browser/extensions/loop/bootstrap.js
vendored
@@ -3,6 +3,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
/* exported startup, shutdown, install, uninstall */
|
||||
|
||||
const { interfaces: Ci, utils: Cu, classes: Cc } = Components;
|
||||
|
||||
const kNSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
@@ -426,7 +428,7 @@ var WindowListener = {
|
||||
}
|
||||
|
||||
let notification = new window.Notification(options.title, notificationOptions);
|
||||
notification.addEventListener("click", e => {
|
||||
notification.addEventListener("click", () => {
|
||||
if (window.closed) {
|
||||
return;
|
||||
}
|
||||
@@ -483,6 +485,7 @@ var WindowListener = {
|
||||
// Watch for title changes as opposed to location changes as more
|
||||
// metadata about the page is available when this event fires.
|
||||
gBrowser.addEventListener("DOMTitleChanged", this);
|
||||
this._browserSharePaused = false;
|
||||
}
|
||||
|
||||
this._maybeShowBrowserSharingInfoBar();
|
||||
@@ -504,6 +507,7 @@ var WindowListener = {
|
||||
gBrowser.tabContainer.removeEventListener("TabSelect", this);
|
||||
gBrowser.removeEventListener("DOMTitleChanged", this);
|
||||
this._listeningToTabSelect = false;
|
||||
this._browserSharePaused = false;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -535,26 +539,37 @@ var WindowListener = {
|
||||
}
|
||||
|
||||
let box = gBrowser.getNotificationBox();
|
||||
let paused = false;
|
||||
let pauseButtonLabel = this._getString(this._browserSharePaused ?
|
||||
"infobar_button_resume_label" :
|
||||
"infobar_button_pause_label");
|
||||
let pauseButtonAccessKey = this._getString(this._browserSharePaused ?
|
||||
"infobar_button_resume_accesskey" :
|
||||
"infobar_button_pause_accesskey");
|
||||
let barLabel = this._getString(this._browserSharePaused ?
|
||||
"infobar_screenshare_paused_browser_message" :
|
||||
"infobar_screenshare_browser_message2");
|
||||
let bar = box.appendNotification(
|
||||
this._getString("infobar_screenshare_browser_message2"),
|
||||
barLabel,
|
||||
kBrowserSharingNotificationId,
|
||||
// Icon is defined in browser theme CSS.
|
||||
null,
|
||||
box.PRIORITY_WARNING_LOW,
|
||||
[{
|
||||
label: this._getString("infobar_button_pause_label"),
|
||||
accessKey: this._getString("infobar_button_pause_accesskey"),
|
||||
label: pauseButtonLabel,
|
||||
accessKey: pauseButtonAccessKey,
|
||||
isDefault: false,
|
||||
callback: (event, buttonInfo, buttonNode) => {
|
||||
paused = !paused;
|
||||
bar.label = paused ? this._getString("infobar_screenshare_paused_browser_message") :
|
||||
this._getString("infobar_screenshare_browser_message2");
|
||||
bar.classList.toggle("paused", paused);
|
||||
buttonNode.label = paused ? this._getString("infobar_button_resume_label") :
|
||||
this._getString("infobar_button_pause_label");
|
||||
buttonNode.accessKey = paused ? this._getString("infobar_button_resume_accesskey") :
|
||||
this._getString("infobar_button_pause_accesskey");
|
||||
this._browserSharePaused = !this._browserSharePaused;
|
||||
bar.label = this._getString(this._browserSharePaused ?
|
||||
"infobar_screenshare_paused_browser_message" :
|
||||
"infobar_screenshare_browser_message2");
|
||||
bar.classList.toggle("paused", this._browserSharePaused);
|
||||
buttonNode.label = this._getString(this._browserSharePaused ?
|
||||
"infobar_button_resume_label" :
|
||||
"infobar_button_pause_label");
|
||||
buttonNode.accessKey = this._getString(this._browserSharePaused ?
|
||||
"infobar_button_resume_accesskey" :
|
||||
"infobar_button_pause_accesskey");
|
||||
return true;
|
||||
},
|
||||
type: "pause"
|
||||
@@ -571,6 +586,9 @@ var WindowListener = {
|
||||
}]
|
||||
);
|
||||
|
||||
// Sets 'paused' class if needed.
|
||||
bar.classList.toggle("paused", !!this._browserSharePaused);
|
||||
|
||||
// Keep showing the notification bar until the user explicitly closes it.
|
||||
bar.persistence = -1;
|
||||
},
|
||||
@@ -612,7 +630,7 @@ var WindowListener = {
|
||||
* Handles events from gBrowser.
|
||||
*/
|
||||
handleEvent: function(event) {
|
||||
switch(event.type) {
|
||||
switch (event.type) {
|
||||
case "DOMTitleChanged":
|
||||
// Get the new title of the shared tab
|
||||
this._notifyBrowserSwitch();
|
||||
@@ -689,15 +707,10 @@ var WindowListener = {
|
||||
window.LoopUI = LoopUI;
|
||||
},
|
||||
|
||||
tearDownBrowserUI: function(window) {
|
||||
let document = window.document;
|
||||
|
||||
tearDownBrowserUI: function() {
|
||||
// Take any steps to remove UI or anything from the browser window
|
||||
// document.getElementById() etc. will work here
|
||||
if (window.LoopUI) {
|
||||
window.LoopUI.removeMenuItem();
|
||||
// XXX Add in tear-down of the panel.
|
||||
}
|
||||
// XXX Add in tear-down of the panel.
|
||||
},
|
||||
|
||||
// nsIWindowMediatorListener functions.
|
||||
@@ -717,10 +730,10 @@ var WindowListener = {
|
||||
}, false);
|
||||
},
|
||||
|
||||
onCloseWindow: function(xulWindow) {
|
||||
onCloseWindow: function() {
|
||||
},
|
||||
|
||||
onWindowTitleChange: function(xulWindow, newTitle) {
|
||||
onWindowTitleChange: function() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user