Bug 552617 - A paused update can't be resumed when closing the window using a window manager control. r=dolske, a=LegNeato
authorRobert Strong <robert.bugzilla@gmail.com>
Thu, 24 Jun 2010 22:13:23 -0700
changeset 34375 7dca7be78aad3eac42f1b42126a4d29de8cbc5ae
parent 34374 db21370ca1cccec4d1df6d28704723347e31051f
child 34376 f3c27935cb6be3189b6b071d62ca743ae9c9c3e4
push id1425
push userrstrong@mozilla.com
push dateFri, 25 Jun 2010 05:13:35 +0000
reviewersdolske, LegNeato
bugs552617
milestone1.9.2.6pre
Bug 552617 - A paused update can't be resumed when closing the window using a window manager control. r=dolske, a=LegNeato
toolkit/mozapps/update/content/updates.js
--- a/toolkit/mozapps/update/content/updates.js
+++ b/toolkit/mozapps/update/content/updates.js
@@ -1093,16 +1093,18 @@ var gDownloadingPage = {
 
   /**
    * Member variables for updating download status
    */
   _lastSec: Infinity,
   _startTime: Date.now(),
   _pausedStatus: "",
 
+  _hiding: false,
+
   /**
    * Initialize
    */
   onPageShow: function() {
     this._downloadName = document.getElementById("downloadName");
     this._downloadStatus = document.getElementById("downloadStatus");
     this._downloadProgress = document.getElementById("downloadProgress");
     this._downloadProgress.hidden = false;
@@ -1258,19 +1260,34 @@ var gDownloadingPage = {
     }
     this._paused = !this._paused;
 
     // Update the UI
     this._setUIState(this._paused);
   },
 
   /**
+   * When the user has closed the window using a Window Manager control (this
+   * page doesn't have a cancel button) cancel the update in progress.
+   */
+  onWizardCancel: function() {
+    if (this._hiding)
+      return;
+
+    this.removeDownloadListener();
+ },
+
+  /**
    * When the user closes the Wizard UI by clicking the Hide button
    */
   onHide: function() {
+    // Set _hiding to true to prevent onWizardCancel from cancelling the update
+    // that is in progress.
+    this._hiding = true;
+
     // Remove ourself as a download listener so that we don't continue to be
     // fed progress and state notifications after the UI we're updating has
     // gone away.
     var aus = CoC["@mozilla.org/updates/update-service;1"].
               getService(CoI.nsIApplicationUpdateService);
     aus.removeDownloadListener(this);
 
     var um = CoC["@mozilla.org/updates/update-manager;1"].