--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2566,26 +2566,24 @@ let gMenuButtonUpdateBadge = {
if (this.enabled) {
try {
this.badgeWaitTime = Services.prefs.getIntPref("app.update.badgeWaitTime");
} catch (e) {
this.badgeWaitTime = 345600; // 4 days
}
PanelUI.menuButton.classList.add("badged-button");
Services.obs.addObserver(this, "update-staged", false);
- Services.obs.addObserver(this, "update-downloaded", false);
}
},
uninit: function () {
if (this.timer)
this.timer.cancel();
if (this.enabled) {
Services.obs.removeObserver(this, "update-staged");
- Services.obs.removeObserver(this, "update-downloaded");
PanelUI.panel.removeEventListener("popupshowing", this, true);
this.enabled = false;
}
},
onMenuPanelCommand: function(event) {
if (event.originalTarget.getAttribute("update-status") === "succeeded") {
// restart the app
@@ -2599,65 +2597,82 @@ let gMenuButtonUpdateBadge = {
} else {
// open the page for manual update
let url = Services.urlFormatter.formatURLPref("app.update.url.manual");
openUILinkIn(url, "tab");
}
},
observe: function (subject, topic, status) {
- if (status == "failed") {
- // Background update has failed, let's show the UI responsible for
- // prompting the user to update manually.
- this.displayBadge(false);
- this.uninit();
- return;
- }
-
- // Give the user badgeWaitTime seconds to react before prompting.
- this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- this.timer.initWithCallback(this, this.badgeWaitTime * 1000,
- this.timer.TYPE_ONE_SHOT);
- // The timer callback will call uninit() when it completes.
+ const STATE_DOWNLOADING = "downloading";
+ const STATE_PENDING = "pending";
+ const STATE_PENDING_SVC = "pending-service";
+ const STATE_APPLIED = "applied";
+ const STATE_APPLIED_SVC = "applied-service";
+ const STATE_FAILED = "failed";
+
+ let updateButton = document.getElementById("PanelUI-update-status");
+
+ let updateButtonText;
+ let stringId;
+
+ // Update the UI when the background updater is finished.
+ switch (status) {
+ case STATE_APPLIED:
+ case STATE_APPLIED_SVC:
+ case STATE_PENDING:
+ case STATE_PENDING_SVC:
+ if (this.timer) {
+ return;
+ }
+ // Give the user badgeWaitTime seconds to react before prompting.
+ this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
+ this.timer.initWithCallback(this, this.badgeWaitTime * 1000,
+ this.timer.TYPE_ONE_SHOT);
+ // The timer callback will call uninit() when it completes.
+ break;
+ case STATE_FAILED:
+ // Background update has failed, let's show the UI responsible for
+ // prompting the user to update manually.
+ PanelUI.menuButton.setAttribute("update-status", "failed");
+ PanelUI.menuButton.setAttribute("badge", "!");
+
+ stringId = "appmenu.updateFailed.description";
+ updateButtonText = gNavigatorBundle.getString(stringId);
+
+ updateButton.setAttribute("label", updateButtonText);
+ updateButton.setAttribute("update-status", "failed");
+ updateButton.hidden = false;
+
+ PanelUI.panel.addEventListener("popupshowing", this, true);
+
+ this.uninit();
+ break;
+ }
},
notify: function () {
// If the update is successfully applied, or if the updater has fallen back
// to non-staged updates, add a badge to the hamburger menu to indicate an
// update will be applied once the browser restarts.
- this.displayBadge(true);
- this.uninit();
- },
-
- displayBadge: function (succeeded) {
- let status = succeeded ? "succeeded" : "failed";
- PanelUI.menuButton.setAttribute("update-status", status);
- if (!succeeded) {
- PanelUI.menuButton.setAttribute("badge", "!");
- }
-
- let stringId;
- let updateButtonText;
- if (succeeded) {
- let brandBundle = document.getElementById("bundle_brand");
- let brandShortName = brandBundle.getString("brandShortName");
- stringId = "appmenu.restartNeeded.description";
- updateButtonText = gNavigatorBundle.getFormattedString(stringId,
- [brandShortName]);
- } else {
- stringId = "appmenu.updateFailed.description";
- updateButtonText = gNavigatorBundle.getString(stringId);
- }
+ PanelUI.menuButton.setAttribute("update-status", "succeeded");
+
+ let brandBundle = document.getElementById("bundle_brand");
+ let brandShortName = brandBundle.getString("brandShortName");
+ stringId = "appmenu.restartNeeded.description";
+ updateButtonText = gNavigatorBundle.getFormattedString(stringId,
+ [brandShortName]);
let updateButton = document.getElementById("PanelUI-update-status");
updateButton.setAttribute("label", updateButtonText);
- updateButton.setAttribute("update-status", status);
+ updateButton.setAttribute("update-status", "succeeded");
updateButton.hidden = false;
PanelUI.panel.addEventListener("popupshowing", this, true);
+ this.uninit();
},
handleEvent: function(e) {
if (e.type === "popupshowing") {
PanelUI.menuButton.removeAttribute("badge");
PanelUI.panel.removeEventListener("popupshowing", this, true);
}
}
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -4563,26 +4563,23 @@ UpdatePrompt.prototype = {
UPDATE_WINDOW_NAME, "updatesavailable", update,
title, text, imageUrl);
},
/**
* See nsIUpdateService.idl
*/
showUpdateDownloaded: function UP_showUpdateDownloaded(update, background) {
- if (background && getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false))
- return;
- }
- // Trigger the display of the hamburger menu badge.
- Services.obs.notifyObservers(null, "update-downloaded", update.state);
-
if (this._getAltUpdateWindow())
return;
if (background) {
+ if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false))
+ return;
+
var stringsPrefix = "updateDownloaded_" + update.type + ".";
var title = gUpdateBundle.formatStringFromName(stringsPrefix + "title",
[update.name], 1);
var text = gUpdateBundle.GetStringFromName(stringsPrefix + "text");
var imageUrl = "";
this._showUnobtrusiveUI(null, URI_UPDATE_PROMPT_DIALOG, null,
UPDATE_WINDOW_NAME, "finishedBackground", update,
title, text, imageUrl);