Bug 420405 - Download triggered by <iframe src=...exe> fails if containing page has refreshed. r+a=mconnor.

This commit is contained in:
mozilla.mano%sent.com 2008-04-18 18:08:00 +00:00
Родитель 6f76f319d4
Коммит 6676b47c30
1 изменённых файлов: 34 добавлений и 26 удалений

Просмотреть файл

@ -55,6 +55,7 @@
*/
const PREF_BD_USEDOWNLOADDIR = "browser.download.useDownloadDir";
const nsITimer = Components.interfaces.nsITimer;
/* ctor
*/
@ -91,9 +92,9 @@ nsUnknownContentTypeDialog.prototype = {
this.mContext = aContext;
const nsITimer = Components.interfaces.nsITimer;
this._timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(nsITimer);
this._timer.initWithCallback(this, 0, nsITimer.TYPE_ONE_SHOT);
this._showTimer = Components.classes["@mozilla.org/timer;1"]
.createInstance(nsITimer);
this._showTimer.initWithCallback(this, 0, nsITimer.TYPE_ONE_SHOT);
},
// When opening from new tab, if tab closes while dialog is opening,
@ -497,27 +498,33 @@ nsUnknownContentTypeDialog.prototype = {
this.mDialog.setTimeout("dialog.postShowCallback()", 0);
this.mDialog.document.documentElement.getButton("accept").disabled = true;
const nsITimer = Components.interfaces.nsITimer;
this._timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(nsITimer);
this._timer.initWithCallback(this, 250, nsITimer.TYPE_ONE_SHOT);
this._showTimer = Components.classes["@mozilla.org/timer;1"]
.createInstance(nsITimer);
this._showTimer.initWithCallback(this, 250, nsITimer.TYPE_ONE_SHOT);
},
_timer: null,
notify: function (aTimer) {
if (!this.mDialog) {
this.reallyShow();
} else {
// The user may have already canceled the dialog.
try {
if (!this._blurred) {
this.mDialog.document.documentElement.getButton("accept").disabled = false;
}
} catch (ex) {}
this._delayExpired = true;
if (aTimer == this._showTimer) {
if (!this.mDialog) {
this.reallyShow();
} else {
// The user may have already canceled the dialog.
try {
if (!this._blurred) {
this.mDialog.document.documentElement.getButton("accept").disabled = false;
}
} catch (ex) {}
this._delayExpired = true;
}
// The timer won't release us, so we have to release it.
this._showTimer = null;
}
else if (aTimer == this._saveToDiskTimer) {
// Since saveToDisk may open a file picker and therefore block this routine,
// we should only call it once the dialog is closed.
this.mLauncher.saveToDisk(null, false);
this._saveToDiskTimer = null;
}
// The timer won't release us, so we have to release it.
this._timer = null;
},
postShowCallback: function () {
@ -894,12 +901,13 @@ nsUnknownContentTypeDialog.prototype = {
this.mLauncher.saveToDisk(targetFile, false);
#endif
// Since saveToDisk may open a file picker and therefore block this routine,
// we should only call it once the dialog is closed.
var _delayedSaveToDisk = function(aSelf) {
aSelf.mLauncher.saveToDisk(null, false);
}
this.mDialog.opener.setTimeout(_delayedSaveToDisk, 0, this);
// see @notify
// we cannot use opener's setTimeout, see bug 420405
this._saveToDiskTimer = Components.classes["@mozilla.org/timer;1"]
.createInstance(nsITimer);
this._saveToDiskTimer.initWithCallback(this, 0,
nsITimer.TYPE_ONE_SHOT);
}
else
this.mLauncher.launchWithApplication(null, false);