Bug 760290 - The update UI needs to be aware of the possibility that the update cannot be staged in the background; r=rstrong
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 31 May 2012 20:28:32 -0400
changeset 97734 f24ce56de72f08504fdd7ba7390ada0b398164d7
parent 97733 1a28fcd25143cc6382d03d7db6396597e1c3a467
child 97735 68abc86fde1c736611ea09db5099d2363cc1c24e
child 97849 629ecea60f1b3883a6f09fe1fb01d8b63339ee09
push id1439
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 20:19:22 +0000
treeherdermozilla-aurora@ea74834dccd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs760290
milestone15.0a1
Bug 760290 - The update UI needs to be aware of the possibility that the update cannot be staged in the background; r=rstrong
browser/base/content/aboutDialog.js
toolkit/mozapps/update/content/updates.js
toolkit/mozapps/update/nsIUpdateService.idl
toolkit/mozapps/update/nsUpdateService.js
--- a/browser/base/content/aboutDialog.js
+++ b/browser/base/content/aboutDialog.js
@@ -189,17 +189,17 @@ appUpdater.prototype =
     }
     catch (e) { }
     return true; // Firefox default is true
   },
 
   // true when updating in background is enabled.
   get backgroundUpdateEnabled() {
     return this.updateEnabled &&
-           Services.prefs.getBoolPref("app.update.stage.enabled");
+           gAppUpdater.aus.canStageUpdates;
   },
 
   // true when updating is automatic.
   get updateAuto() {
     try {
       return Services.prefs.getBoolPref("app.update.auto");
     }
     catch (e) { }
--- a/toolkit/mozapps/update/content/updates.js
+++ b/toolkit/mozapps/update/content/updates.js
@@ -10,17 +10,16 @@ Components.utils.import("resource://gre/
 // Firefox's macBrowserOverlay.xul includes scripts that define Cc, Ci, and Cr
 // so we have to use different names.
 const CoC = Components.classes;
 const CoI = Components.interfaces;
 const CoR = Components.results;
 
 const XMLNS_XUL               = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
-const PREF_APP_UPDATE_BACKGROUND         = "app.update.stage.enabled";
 const PREF_APP_UPDATE_BACKGROUNDERRORS   = "app.update.backgroundErrors";
 const PREF_APP_UPDATE_BILLBOARD_TEST_URL = "app.update.billboard.test_url";
 const PREF_APP_UPDATE_CERT_ERRORS        = "app.update.cert.errors";
 const PREF_APP_UPDATE_ENABLED            = "app.update.enabled";
 const PREF_APP_UPDATE_LOG                = "app.update.log";
 const PREF_APP_UPDATE_MANUAL_URL         = "app.update.url.manual";
 const PREF_APP_UPDATE_NEVER_BRANCH       = "app.update.never.";
 const PREF_APP_UPDATE_TEST_LOOP          = "app.update.test.loop";
@@ -1576,17 +1575,19 @@ var gDownloadingPage = {
     case CoR.NS_BINDING_ABORTED:
       LOG("gDownloadingPage", "onStopRequest - pausing download");
       // Do not remove UI listener since the user may resume downloading again.
       break;
     case CoR.NS_OK:
       LOG("gDownloadingPage", "onStopRequest - patch verification succeeded");
       // If the background update pref is set, we should wait until the update
       // is actually staged in the background.
-      if (getPref("getBoolPref", PREF_APP_UPDATE_BACKGROUND, false)) {
+      var aus = CoC["@mozilla.org/updates/update-service;1"].
+                getService(CoI.nsIApplicationUpdateService);
+      if (aus.canStageUpdates) {
         this._setUpdateApplying();
       } else {
         this.cleanUp();
         gUpdates.wiz.goTo("finished");
       }
       break;
     default:
       LOG("gDownloadingPage", "onStopRequest - transfer failed");
--- a/toolkit/mozapps/update/nsIUpdateService.idl
+++ b/toolkit/mozapps/update/nsIUpdateService.idl
@@ -347,17 +347,17 @@ interface nsIUpdateChecker : nsISupports
   void stopChecking(in unsigned short duration);
 };
 
 /**
  * An interface describing a global application service that handles performing
  * background update checks and provides utilities for selecting and
  * downloading update patches.
  */
-[scriptable, uuid(7bd62f69-f604-484b-b97c-e7229d7a3ee8)]
+[scriptable, uuid(900b4a18-3bef-4f3e-bcf5-84dce0021c6d)]
 interface nsIApplicationUpdateService : nsISupports
 {
   /**
    * The Update Checker used for background update checking.
    */
   readonly attribute nsIUpdateChecker backgroundChecker;
 
   /**
@@ -417,16 +417,21 @@ interface nsIApplicationUpdateService : 
   readonly attribute boolean canCheckForUpdates;
 
   /**
    * Whether or not the Update Service can download and install updates.
    * This is a function of whether or not the current user has access
    * privileges to the install directory.
    */
   readonly attribute boolean canApplyUpdates;
+
+  /**
+   * Whether the Update Service is able to stage updates.
+   */
+  readonly attribute boolean canStageUpdates;
 };
 
 /**
  * An interface describing a component which handles the job of processing
  * an update after it's been downloaded.
  */
 [scriptable, uuid(74439497-d796-4915-8cef-3dfe43027e4d)]
 interface nsIUpdateProcessor : nsISupports
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -2044,16 +2044,23 @@ UpdateService.prototype = {
    */
   get canApplyUpdates() {
     return gCanApplyUpdates;
   },
 
   /**
    * See nsIUpdateService.idl
    */
+  get canStageUpdates() {
+    return gCanStageUpdates;
+  },
+
+  /**
+   * See nsIUpdateService.idl
+   */
   addDownloadListener: function AUS_addDownloadListener(listener) {
     if (!this._downloader) {
       LOG("UpdateService:addDownloadListener - no downloader!");
       return;
     }
     this._downloader.addDownloadListener(listener);
   },