Bug 463888 - Do not persist the "Save As" location in private browsing mode; r=gavin, a=blocking-firefox3.1+

This commit is contained in:
Ehsan Akhgari 2008-11-14 02:04:41 +03:30
Родитель 707c8cc829
Коммит 7c6d6fc94f
2 изменённых файлов: 30 добавлений и 4 удалений

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

@ -23,6 +23,7 @@
# Ben Goodger <ben@netscape.com> (Save File)
# Fredrik Holmqvist <thesuckiestemail@yahoo.se>
# Asaf Romano <mozilla.mano@sent.com>
# Ehsan Akhgari <ehsan.akhgari@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -510,9 +511,21 @@ function getTargetFile(aFpP, aSkipPrompt)
if (fp.show() == Components.interfaces.nsIFilePicker.returnCancel || !fp.file)
return false;
var directory = fp.file.parent.QueryInterface(nsILocalFile);
prefs.setComplexValue("lastDir", nsILocalFile, directory);
// Do not remember the last save directory inside the private browsing mode
var persistLastDir = true;
try {
var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
.getService(Components.interfaces.nsIPrivateBrowsingService);
if (pbs.privateBrowsingEnabled)
persistLastDir = false;
}
catch (e) {
}
if (persistLastDir) {
var directory = fp.file.parent.QueryInterface(nsILocalFile);
prefs.setComplexValue("lastDir", nsILocalFile, directory);
}
fp.file.leafName = validateFileName(fp.file.leafName);
aFpP.saveAsType = fp.filterIndex;

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

@ -27,6 +27,7 @@
# Fredrik Holmqvist <thesuckiestemail@yahoo.se>
# Dan Mosedale <dmose@mozilla.org>
# Jim Mathies <jmathies@mozilla.com>
# Ehsan Akhgari <ehsan.akhgari@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -237,7 +238,19 @@ nsUnknownContentTypeDialog.prototype = {
}
catch (e) { }
var newDir = result.parent;
prefs.setComplexValue("browser.download.lastDir", Components.interfaces.nsILocalFile, newDir);
// Do not remember the last save directory inside the private browsing mode
var persistLastDir = true;
try {
var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
.getService(Components.interfaces.nsIPrivateBrowsingService);
if (pbs.privateBrowsingEnabled)
persistLastDir = false;
}
catch (e) { }
if (persistLastDir)
prefs.setComplexValue("browser.download.lastDir", Components.interfaces.nsILocalFile, newDir);
result = this.validateLeafName(newDir, result.leafName, null);
}
return result;