Bug 1359733 - (pt. 3) Pull out browser-addons.js badges r=aswan

We are moving app menu doorhangers and badges out from window-
specific code into a jsm, in order to simplify the work that
the new app udpate UI has to do. Since browser-addons.js also
consumes the badge system, this ensures that it also uses the
jsm store.

MozReview-Commit-ID: Fb5Fsja0RcA

--HG--
extra : rebase_source : c979e361aba54692f89e79317e4958b65c8b4722
This commit is contained in:
Doug Thayer 2017-05-15 10:38:33 -07:00
parent 6ef545c191
commit 26f8bae28d
2 changed files with 16 additions and 10 deletions

View File

@ -515,11 +515,6 @@ const gExtensionsNotifications = {
updateAlerts() {
let sideloaded = ExtensionsUI.sideloaded;
let updates = ExtensionsUI.updates;
if (sideloaded.size + updates.size == 0) {
PanelUI.removeNotification("addon-alert");
} else {
PanelUI.showBadgeOnlyNotification("addon-alert");
}
let container = PanelUI.addonNotificationContainer;

View File

@ -14,6 +14,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManagerPrivate",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppMenuNotifications",
"resource://gre/modules/AppMenuNotifications.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
@ -71,7 +73,7 @@ this.ExtensionsUI = {
}
this.sideloaded.delete(addon);
this.emit("change");
this._updateNotifications();
if (this.sideloaded.size == 0) {
AddonManager.removeAddonListener(this.sideloadListener);
@ -85,7 +87,7 @@ this.ExtensionsUI = {
for (let addon of sideloaded) {
this.sideloaded.add(addon);
}
this.emit("change");
this._updateNotifications();
} else {
// This and all the accompanying about:newaddon code can eventually
// be removed. See bug 1331521.
@ -96,6 +98,15 @@ this.ExtensionsUI = {
}
},
_updateNotifications() {
if (this.sideloaded.size + this.updates.size == 0) {
AppMenuNotifications.removeNotification("addon-alert");
} else {
AppMenuNotifications.showBadgeOnlyNotification("addon-alert");
}
this.emit("change");
},
showAddonsManager(browser, strings, icon, histkey) {
let global = browser.selectedBrowser.ownerGlobal;
return global.BrowserOpenAddonsMgr("addons://list/extension").then(aomWin => {
@ -109,7 +120,7 @@ this.ExtensionsUI = {
showSideloaded(browser, addon) {
addon.markAsSeen();
this.sideloaded.delete(addon);
this.emit("change");
this._updateNotifications();
let strings = this._buildStrings({
addon,
@ -133,7 +144,7 @@ this.ExtensionsUI = {
// At the moment, this prompt will re-appear next time we do an update
// check. See bug 1332360 for proposal to avoid this.
this.updates.delete(info);
this.emit("change");
this._updateNotifications();
});
},
@ -205,7 +216,7 @@ this.ExtensionsUI = {
};
this.updates.add(update);
this.emit("change");
this._updateNotifications();
} else if (topic == "webextension-install-notify") {
let {target, addon, callback} = subject.wrappedJSObject;
this.showInstallNotification(target, addon).then(() => {