[tbb-commits] [torbutton/master] Bug 16639: Check for Updates menu item can cause update failure.

mikeperry at torproject.org mikeperry at torproject.org
Mon Jul 27 15:55:37 UTC 2015


commit 84497608ae13239b67d2b656647c64a70badd72c
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Thu Jul 23 15:30:51 2015 -0400

    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.
---
 src/chrome/content/torbutton.js |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 6539ea9..1d81960 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -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.



More information about the tbb-commits mailing list