Commit 84497608 authored by Kathleen Brade's avatar Kathleen Brade
Browse files

Bug 16639: Check for Updates menu item can cause update failure.

Check the state of the active update (if any) and open the update prompt
in the correct mode.
parent 3df4216b
......@@ -893,9 +893,23 @@ function torbutton_notify_if_update_needed() {
}
function torbutton_check_for_update() {
// Open the update prompt in the correct mode. The update state
// checks used here were adapted from isPending() and isApplied() in
// Mozilla's browser/base/content/aboutDialog.js code.
let updateMgr = Cc["@mozilla.org/updates/update-manager;1"]
.getService(Ci.nsIUpdateManager);
let update = updateMgr.activeUpdate;
let updateState = (update) ? update.state : undefined;
let pendingStates = [ "pending", "pending-service",
"applied", "applied-service" ];
let isPending = (updateState && (pendingStates.indexOf(updateState) >= 0));
let prompter = Cc["@mozilla.org/updates/update-prompt;1"]
.createInstance(Ci.nsIUpdatePrompt);
prompter.checkForUpdates();
if (isPending)
prompter.showUpdateDownloaded(update, false);
else
prompter.checkForUpdates();
}
// Pass undefined for a parameter to have this function determine it.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment