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:38:56 -0800
changeset 35142 904fd580c972e49305dc61ddaefc83ea6ce96502
parent 35141 30c2cf6bdf2f93c9af9fa0039b76911679c02267
child 35143 4a0bf3ffd767d43551955762e1111afa12f4580c
push id10436
push userrstrong@mozilla.com
push dateThu, 19 Nov 2009 19:39:09 +0000
treeherdermozilla-central@904fd580c972 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdtownsend, beltzner
bugs407875
milestone1.9.3a1pre
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();
   },
@@ -757,16 +757,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) {