diff --git a/embedding/components/ui/progressDlg/locale/en-US/nsProgressDialog.dtd b/embedding/components/ui/progressDlg/locale/en-US/nsProgressDialog.dtd index c16121b32fc..5cd85dbf2e8 100644 --- a/embedding/components/ui/progressDlg/locale/en-US/nsProgressDialog.dtd +++ b/embedding/components/ui/progressDlg/locale/en-US/nsProgressDialog.dtd @@ -2,6 +2,9 @@ See: http://lxr.mozilla.org/seamonkey/source/embedding/components/ui/progressDlg/nsProgressDialog.xul --> + + + @@ -31,12 +34,6 @@ - - - - - - - - diff --git a/embedding/components/ui/progressDlg/nsIProgressDialog.idl b/embedding/components/ui/progressDlg/nsIProgressDialog.idl index f3a4a9c097e..9c4f8020676 100644 --- a/embedding/components/ui/progressDlg/nsIProgressDialog.idl +++ b/embedding/components/ui/progressDlg/nsIProgressDialog.idl @@ -26,6 +26,7 @@ interface nsIWebBrowserPersist; interface nsIDOMWindow; interface nsILocalFile; +interface nsIObserver; /* nsIProgressDialog * @@ -44,6 +45,8 @@ interface nsILocalFile; * closes it manually. * 6. Release the instance. The instance will be referenced by * the dialog itself, so it won't get freed until the dialog closes. + * The dialog will keep the instance alive, so typically one does + * not need to hold a reference to it. * * Important Note: Implementors of this interface must also implement * nsISupportsWeakReference. @@ -98,6 +101,16 @@ interface nsIProgressDialog : nsIWebProgressListener { */ attribute wstring openingWith; + /** + * Set this attribute to the observer object that will be + * notified when the user presses the Cancel button. The + * observer's "observe" method will be called with: + * aSubject = the nsIProgressDialog + * aTopic = "oncancel" + * aData = "" + */ + attribute nsIObserver observer; + /** * The web browser persist object doing the associated I/O. * May be null. diff --git a/embedding/components/ui/progressDlg/nsProgressDialog.js b/embedding/components/ui/progressDlg/nsProgressDialog.js index 8816f8d1c77..1680606b4c3 100644 --- a/embedding/components/ui/progressDlg/nsProgressDialog.js +++ b/embedding/components/ui/progressDlg/nsProgressDialog.js @@ -46,6 +46,7 @@ function nsProgressDialog() { this.mParent = null; this.mOperation = null; this.mStartTime = ( new Date() ).getTime(); + this.observer = null; this.mLastUpdate = Number.MIN_VALUE; // To ensure first onProgress causes update. this.mInterval = 750; // Default to .75 seconds. this.mElapsed = 0; @@ -68,9 +69,9 @@ const nsIProgressDialog = Components.interfaces.nsIProgressDialog; nsProgressDialog.prototype = { // Turn this on to get debugging messages. - debug: true, + debug: false, - // Currently, use old helperAppDldProgress.xul. + // Chrome-related constants. dialogChrome: "chrome://global/content/nsProgressDialog.xul", dialogFeatures: "chrome,titlebar,minimizable=yes", @@ -80,6 +81,8 @@ nsProgressDialog.prototype = { set parent(newval) { return this.mParent = newval; }, get operation() { return this.mOperation; }, set operation(newval) { return this.mOperation = newval; }, + get observer() { return this.mObserver; }, + set observer(newval) { return this.mObserver = newval; }, get startTime() { return this.mStartTime; }, set startTime(newval) { return this.mStartTime = newval/1000; }, // PR_Now() is in microseconds, so we convert. get lastUpdate() { return this.mLastUpdate; }, @@ -227,6 +230,7 @@ nsProgressDialog.prototype = { onStatusChange: function( aWebProgress, aRequest, aStatus, aMessage ) { // Check for error condition (only if dialog is still open). if ( this.dialog && aStatus != Components.results.NS_OK ) { +this.dump( "nsProgressDialog::onStatusChange, status=" + this.hex( aStatus ) + "\n" ); // Get prompt service. var prompter = Components.classes[ "@mozilla.org/embedcomp/prompt-service;1" ] .getService( Components.interfaces.nsIPromptService ); @@ -380,16 +384,23 @@ nsProgressDialog.prototype = { // Cancel button stops the download (if not completed), // and closes the dialog. onCancel: function() { + // Cancel the download, if not completed. + if ( !this.completed ) { + if ( this.operation ) { + this.operation.cancelSave(); + // XXX We're supposed to clean up files/directories. + } + if ( this.observer ) { + this.observer.observe( this, "oncancel", "" ); + } + this.paused = false; + } // Test whether the dialog is already closed. // This will be the case if we've come through onUnload. if ( this.dialog ) { // Close the dialog. this.dialog.close(); } - // Cancel the download, if not completed. - if ( !this.completed && this.operation ) { - this.operation.cancelDownload(); - } }, // onunload event means the dialog has closed. diff --git a/embedding/components/ui/progressDlg/nsProgressDialog.xul b/embedding/components/ui/progressDlg/nsProgressDialog.xul index 28a59592481..824fff3b7da 100644 --- a/embedding/components/ui/progressDlg/nsProgressDialog.xul +++ b/embedding/components/ui/progressDlg/nsProgressDialog.xul @@ -47,7 +47,7 @@ Contributor(s): @@ -76,7 +76,6 @@ Contributor(s): &longTimeFormat; &unknownTime; &pausedMsg; - &filesFolder; &savingTitle; &savingAlertTitle; &openingTitle;