Bug 1331918 - Make addon install failure messages non-persistent. r=past
MozReview-Commit-ID: BO00gCCzT7f
--- a/browser/base/content/browser-addons.js
+++ b/browser/base/content/browser-addons.js
@@ -233,39 +233,49 @@ const gXPInstallObserver = {
persistent: true,
hideClose: true,
timeout: Date.now() + 30000,
};
switch (aTopic) {
case "addon-install-disabled": {
notificationID = "xpinstall-disabled";
+ let secondaryActions = null;
if (gPrefService.prefIsLocked("xpinstall.enabled")) {
messageString = gNavigatorBundle.getString("xpinstallDisabledMessageLocked");
buttons = [];
} else {
messageString = gNavigatorBundle.getString("xpinstallDisabledMessage");
action = {
label: gNavigatorBundle.getString("xpinstallDisabledButton"),
accessKey: gNavigatorBundle.getString("xpinstallDisabledButton.accesskey"),
callback: function editPrefs() {
gPrefService.setBoolPref("xpinstall.enabled", true);
}
};
+
+ secondaryActions = [{
+ label: gNavigatorBundle.getString("addonInstall.cancelButton.label"),
+ accessKey: gNavigatorBundle.getString("addonInstall.cancelButton.accesskey"),
+ callback: () => {},
+ }];
}
PopupNotifications.show(browser, notificationID, messageString, anchorID,
- action, null, options);
+ action, secondaryActions, options);
break; }
case "addon-install-origin-blocked": {
messageString = gNavigatorBundle.getFormattedString("xpinstallPromptMessage",
[brandShortName]);
+ options.removeOnDismissal = true;
+ options.persistent = false;
+
let secHistogram = Components.classes["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry).getHistogramById("SECURITY_UI");
secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_ADDON_ASKING_PREVENTED);
let popup = PopupNotifications.show(browser, notificationID,
messageString, anchorID,
null, null, options);
removeNotificationOnEnd(popup, installInfo.installs);
break; }
case "addon-install-blocked": {
@@ -345,16 +355,19 @@ const gXPInstallObserver = {
};
let notification = PopupNotifications.show(browser, notificationID, messageString,
anchorID, action,
[secondaryAction], options);
notification._startTime = Date.now();
break; }
case "addon-install-failed": {
+ options.removeOnDismissal = true;
+ options.persistent = false;
+
// TODO This isn't terribly ideal for the multiple failure case
for (let install of installInfo.installs) {
let host;
try {
host = options.displayURI.host;
} catch (e) {
// displayURI might be missing or 'host' might throw for non-nsStandardURL nsIURIs.
}
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -886,16 +886,24 @@ PopupNotifications.prototype = {
anchorElement = this.tabbrowser.selectedTab;
}
}
if (this.isPanelOpen && this._currentAnchorElement == anchorElement) {
notificationsToShow.forEach(function(n) {
this._fireCallback(n, NOTIFICATION_EVENT_SHOWN);
}, this);
+
+ // Make sure we update the noautohide attribute on the panel, in case it changed.
+ if (notificationsToShow.some(n => n.options.persistent)) {
+ this.panel.setAttribute("noautohide", "true");
+ } else {
+ this.panel.removeAttribute("noautohide");
+ }
+
// Let tests know that the panel was updated and what notifications it was
// updated with so that tests can wait for the correct notifications to be
// added.
let event = new this.window.CustomEvent("PanelUpdated",
{"detail": notificationIds});
this.panel.dispatchEvent(event);
return;
}