зеркало из https://github.com/mozilla/pjs.git
Make it possible to persist the disk and memory cache capacity prefs again.
Also, if the user doesn't have a disk cache parent folder chosen, show and set the default which is the profile directory. b=125189; r=morse; sr=sfraser
This commit is contained in:
Родитель
83075218c4
Коммит
76e51f9dde
|
@ -2,18 +2,51 @@
|
|||
*
|
||||
*/
|
||||
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
const nsILocalFile = Components.interfaces.nsILocalFile;
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
const nsILocalFile = Components.interfaces.nsILocalFile;
|
||||
const nsIFile = Components.interfaces.nsIFile;
|
||||
const nsIProperties = Components.interfaces.nsIProperties;
|
||||
const kCacheParentDirPref = "browser.cache.disk.parent_directory";
|
||||
|
||||
function Startup()
|
||||
{
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var path = Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(nsILocalFile);
|
||||
|
||||
path = pref.getComplexValue("browser.cache.disk.parent_directory", nsILocalFile);
|
||||
document.getElementById("browserCacheDiskCacheFolder").value = path.unicodePath;
|
||||
var path = null;
|
||||
var pref = null;
|
||||
try
|
||||
{
|
||||
pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
path = pref.getComplexValue(kCacheParentDirPref, nsILocalFile);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
// parent_directory pref not set; path is null so we'll failover
|
||||
// to filling in the parent_directory as the profile directory
|
||||
}
|
||||
|
||||
if (!path)
|
||||
{
|
||||
try
|
||||
{
|
||||
// no disk cache folder found; default to profile directory
|
||||
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(nsIProperties);
|
||||
var ifile = dirSvc.get("ProfD", nsIFile);
|
||||
path = ifile.QueryInterface(nsILocalFile);
|
||||
|
||||
// now remember the new assumption
|
||||
if (pref)
|
||||
pref.setComplexValue(kCacheParentDirPref, nsILocalFile, path);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// if both pref and dir svc fail leave this field blank else show path
|
||||
if (path)
|
||||
document.getElementById("browserCacheDiskCacheFolder").value =
|
||||
path.unicodePath;
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +60,16 @@ function prefCacheSelectFolder()
|
|||
var title = prefutilitiesBundle.getString("cachefolder");
|
||||
|
||||
fp.init(window, title, nsIFilePicker.modeGetFolder);
|
||||
try
|
||||
{
|
||||
var initialDir = pref.getComplexValue(kCacheParentDirPref, nsILocalFile);
|
||||
if (initialDir)
|
||||
fp.displayDirectory = initialDir;
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
// ignore exception: file picker will open at default location
|
||||
}
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
var ret = fp.show();
|
||||
|
||||
|
@ -35,7 +78,7 @@ function prefCacheSelectFolder()
|
|||
var viewable = fp.file.unicodePath;
|
||||
var folderField = document.getElementById("browserCacheDiskCacheFolder");
|
||||
folderField.value = viewable;
|
||||
pref.setComplexValue("browser.cache.disk.parent_directory", nsILocalFile, localFile)
|
||||
pref.setComplexValue(kCacheParentDirPref, nsILocalFile, localFile)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче