Bug 1359733 - (pt. 5) Pull out indicator.js badges
See also pt. 4. We are moving app menu notification state
into a jsm since it is not specific to one window and this
simplifies work for the new app update UI.
MozReview-Commit-ID: InEp5b0y2n0
--- a/browser/components/downloads/DownloadsCommon.jsm
+++ b/browser/components/downloads/DownloadsCommon.jsm
@@ -36,16 +36,20 @@ const { classes: Cc, interfaces: Ci, uti
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "AppMenuNotifications",
+ "resource://gre/modules/AppMenuNotifications.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
+ "resource:///modules/CustomizableUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
"resource://gre/modules/Downloads.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DownloadUIHelper",
"resource://gre/modules/DownloadUIHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DownloadUtils",
"resource://gre/modules/DownloadUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
@@ -1198,16 +1202,28 @@ DownloadsIndicatorDataCtor.prototype = {
*/
_updateViews() {
// Do not update the status indicators during batch loads of download items.
if (this._loading) {
return;
}
this._refreshProperties();
+
+ let widgetGroup = CustomizableUI.getWidget("downloads-button");
+ let inMenu = widgetGroup.areaType == CustomizableUI.TYPE_MENU_PANEL;
+ if (inMenu) {
+ if (this._attention == DownloadsCommon.ATTENTION_NONE) {
+ AppMenuNotifications.removeNotification(/^download-/);
+ } else {
+ let badgeClass = "download-" + this._attention;
+ AppMenuNotifications.showBadgeOnlyNotification(badgeClass);
+ }
+ }
+
this._views.forEach(this._updateView, this);
},
/**
* Updates the specified view with the current aggregate values.
*
* @param aView
* DownloadsIndicatorView object to be updated.
--- a/browser/components/downloads/content/indicator.js
+++ b/browser/components/downloads/content/indicator.js
@@ -436,25 +436,18 @@ const DownloadsIndicatorView = {
// For arrow-Styled indicator, suppress success attention if we have
// progress in toolbar
let suppressAttention = !inMenu &&
this._attention == DownloadsCommon.ATTENTION_SUCCESS &&
this._percentComplete >= 0;
if (suppressAttention || this._attention == DownloadsCommon.ATTENTION_NONE) {
this.indicator.removeAttribute("attention");
- if (inMenu) {
- PanelUI.removeNotification(/^download-/);
- }
} else {
this.indicator.setAttribute("attention", this._attention);
- if (inMenu) {
- let badgeClass = "download-" + this._attention;
- PanelUI.showBadgeOnlyNotification(badgeClass);
- }
}
},
_attention: DownloadsCommon.ATTENTION_NONE,
// User interface event functions
onWindowUnload() {
// This function is registered as an event listener, we can't use "this".