followup to Bug 407875 - prevent multiple update prompts for manual update notification. r=dtownsend, a=beltzner
authorRobert Strong <robert.bugzilla@gmail.com>
Thu, 19 Nov 2009 11:47:46 -0800
changeset 33072 9d93308bf08fed496e128c40cb175df2ec9484cd
parent 33071 4b183cb27cc166403554a1e645eecde0a63ed4ef
child 33073 71678ba20f932e9496cb10494c3bba2ff1d31486
push id750
push userrstrong@mozilla.com
push dateThu, 19 Nov 2009 19:47:57 +0000
reviewersdtownsend, beltzner
bugs407875
milestone1.9.2b4pre
followup to Bug 407875 - prevent multiple update prompts for manual update notification. r=dtownsend, a=beltzner
toolkit/mozapps/update/content/updates.js
toolkit/mozapps/update/src/nsUpdateService.js.in
--- a/toolkit/mozapps/update/content/updates.js
+++ b/toolkit/mozapps/update/content/updates.js
@@ -218,17 +218,17 @@ var gUpdates = {
   never: function () {
     // If the user clicks "Never", we should not prompt them about updating to
     // this major update version again, unless they manually do
     // "Check for Updates..." which will clear the "never" pref for the version
     // presented and remind them later about this available update.
     //
     // Encode version since it could be a non-ascii string (bug 359093)
     var neverPrefName = PREF_UPDATE_NEVER_BRANCH +
-                       encodeURIComponent(gUpdates.update.version);
+                        encodeURIComponent(gUpdates.update.version);
     gPref.setBoolPref(neverPrefName, true);
     this.wiz.cancel();
   },
 
   later: function () {
     // The user said "Later", so close the wizard
     this.wiz.cancel();
   },
@@ -759,16 +759,23 @@ var gManualUpdatePage = {
   onPageShow: function() {
     var formatter = CoC["@mozilla.org/toolkit/URLFormatterService;1"].
                     getService(CoI.nsIURLFormatter);
     var manualURL = formatter.formatURLPref(PREF_UPDATE_MANUAL_URL);
     var manualUpdateLinkLabel = document.getElementById("manualUpdateLinkLabel");
     manualUpdateLinkLabel.value = manualURL;
     manualUpdateLinkLabel.setAttribute("url", manualURL);
 
+    // Prevent multiple notifications for the same update when the user is
+    // unable to apply updates.
+    // Encode version since it could be a non-ascii string (bug 359093)
+    var neverPrefName = PREF_UPDATE_NEVER_BRANCH +
+                        encodeURIComponent(gUpdates.update.version);
+    gPref.setBoolPref(neverPrefName, true);
+
     gUpdates.setButtons(null, null, "okButton", true);
     gUpdates.wiz.getButton("finish").focus();
   }
 };
 
 /**
  * The "Updates Are Available" page. Provides the user information about the
  * available update.
--- a/toolkit/mozapps/update/src/nsUpdateService.js.in
+++ b/toolkit/mozapps/update/src/nsUpdateService.js.in
@@ -1320,16 +1320,31 @@ UpdateService.prototype = {
 #         never receive the minor update or the minor update they notification.
 #      b) the never decision only applies to major updates. See bug 350636 for
 #         a scenario where this could potentially be an issue.
      */
 
     // Encode version since it could be a non-ascii string (bug 359093)
     var neverPrefName = PREF_UPDATE_NEVER_BRANCH +
                         encodeURIComponent(update.version);
+
+    if (!gCanApplyUpdates) {
+      if (getPref("getBoolPref", neverPrefName, false)) {
+        LOG("Checker:_selectAndInstallUpdate - the user is unable to apply " +
+            "updates. Not prompting because the preference " + neverPrefName + 
+            " is true");
+      }
+      else {
+        LOG("Checker:_selectAndInstallUpdate - the user is unable to apply " +
+            "updates... prompting");
+        this._showPrompt(update);
+      }
+      return;
+    }
+
     if (update.type == "major" &&
         getPref("getBoolPref", neverPrefName, false)) {
       LOG("Checker:_selectAndInstallUpdate - not prompting because this is a " +
           "major update and the preference " + neverPrefName + " is true");
       return;
     }
 
     /**
@@ -1352,23 +1367,16 @@ UpdateService.prototype = {
      */
     if (update.type == "major") {
       LOG("Checker:_selectAndInstallUpdate - prompting because it is a major " +
           "update");
       this._showPrompt(update);
       return;
     }
 
-    if (!gCanApplyUpdates) {
-      LOG("Checker:_selectAndInstallUpdate - prompting because the user is " +
-          "unable to apply updates");
-      this._showPrompt(update);
-      return;
-    }
-
     if (!getPref("getBoolPref", PREF_APP_UPDATE_AUTO, true)) {
       LOG("Checker:_selectAndInstallUpdate - prompting because silent " +
           "install is disabled");
       this._showPrompt(update);
       return;
     }
 
     if (getPref("getIntPref", PREF_APP_UPDATE_MODE, 1) == 0) {