diff --git a/mozilla/embedding/components/ui/progressDlg/nsIProgressDialog.idl b/mozilla/embedding/components/ui/progressDlg/nsIProgressDialog.idl index 7b1f5df7fc8..53f3e7c9693 100644 --- a/mozilla/embedding/components/ui/progressDlg/nsIProgressDialog.idl +++ b/mozilla/embedding/components/ui/progressDlg/nsIProgressDialog.idl @@ -61,6 +61,12 @@ interface nsIProgressDialog : nsIDownload { * open yet, or has been closed. */ attribute nsIDOMWindow dialog; + + /** + * Whether or not to cancel the download when the progress dialog is closed. + * If set, the Cancel button will also be hidden. + */ + attribute boolean cancelOnClose; }; diff --git a/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.js b/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.js index 10c1c816762..0158adcdf9e 100644 --- a/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.js +++ b/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.js @@ -52,6 +52,7 @@ function nsProgressDialog() { // Initialize data properties. this.mParent = null; this.mOperation = null; + this.mCancelOnClose = null; this.mStartTime = ( new Date() ).getTime(); this.observer = null; this.mLastUpdate = Number.MIN_VALUE; // To ensure first onProgress causes update. @@ -90,6 +91,8 @@ nsProgressDialog.prototype = { set parent(newval) { return this.mParent = newval; }, get operation() { return this.mOperation; }, set operation(newval) { return this.mOperation = newval; }, + get cancelOnClose() { return this.mCancelOnClose; }, + set cancelOnClose(newval) { return this.mCancelOnClose = newval; }, get observer() { return this.mObserver; }, set observer(newval) { return this.mObserver = newval; }, get startTime() { return this.mStartTime; }, @@ -404,6 +407,10 @@ nsProgressDialog.prototype = { this.dialogElement( "keep" ).checked = prefs.getBoolPref( "browser.download.progressDnldDialog.keepAlive" ); } } + + if ( !this.cancelOnClose ) { + this.hide( "cancel" ); + } // Initialize title. this.setTitle(); @@ -443,7 +450,9 @@ nsProgressDialog.prototype = { } } this.dialog = null; // The dialog is history. - this.onCancel(); + if ( this.cancelOnClose ) { + this.onCancel(); + } }, // onpause event means the user pressed the pause/resume button @@ -750,8 +759,11 @@ nsProgressDialog.prototype = { // Hide a given dialog field. hide: function( field ) { this.dialogElement( field ).setAttribute( "style", "display: none;" ); - // Hide the associated separator, too. - this.dialogElement( field+"Separator" ).setAttribute( "style", "display: none;" ); + // Hide the associated separator, too, if one exists. + var separator = this.dialogElement( field+"Separator" ); + if ( separator ) { + separator.setAttribute( "style", "display: none;" ); + } }, // Return input in hex, prepended with "0x" and leading zeros (to 8 digits). diff --git a/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.xul b/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.xul index 320fe801c35..c23482feaec 100644 --- a/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.xul +++ b/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.xul @@ -156,10 +156,12 @@ +