зеркало из https://github.com/mozilla/gecko-dev.git
Fix 178227 'Clearing Download Manager History doesn't work', Fix 195388 'Can not manually edit Download directory path' patch by mconnor@rogers.com
This commit is contained in:
Родитель
7d18356627
Коммит
30614ad556
|
@ -99,6 +99,51 @@ function onOK() {
|
|||
}
|
||||
}
|
||||
|
||||
// check download directory is valid
|
||||
function checkDownloadDirectory() {
|
||||
var dloadDir = Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(Components.interfaces.nsILocalFile);
|
||||
if (!dloadDir) return false;
|
||||
|
||||
var givenValue = document.getElementById("defaultDir");
|
||||
var downloadDir = document.getElementById("downloadDir");
|
||||
if (downloadDir.selectedItem == document.getElementById("alwaysAskRadio")) { return; }
|
||||
|
||||
try {
|
||||
dloadDir.initWithPath(givenValue.value);
|
||||
dloadDir.isDirectory();
|
||||
}
|
||||
catch(ex) {
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
var prefbundle = document.getElementById("bundle_prefutilities");
|
||||
|
||||
if ( givenValue.value == "" ) { // no directory, reset back to Always Ask
|
||||
downloadDir.selectedItem = document.getElementById("alwaysAskRadio");
|
||||
} else {
|
||||
var checkValue = {value:false};
|
||||
|
||||
var title = prefbundle.getString("downloadDirTitle");
|
||||
var description = prefbundle.getFormattedString("invalidDirPopup", [givenValue.value]);
|
||||
var buttonPressed = promptService.confirmEx(window,
|
||||
title, description,
|
||||
(promptService.BUTTON_TITLE_YES * promptService.BUTTON_POS_0) +
|
||||
(promptService.BUTTON_TITLE_NO * promptService.BUTTON_POS_1),
|
||||
null, null, null, null, checkValue);
|
||||
|
||||
if (buttonPressed != 0) {
|
||||
// they don't want to create the directory
|
||||
return;
|
||||
}
|
||||
try {
|
||||
dloadDir.create(1,0777);
|
||||
} catch(ex) {
|
||||
alert( prefbundle.getFormattedString("invalidDir", [givenValue.value]) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Startup()
|
||||
{
|
||||
if (top.opener) {
|
||||
|
|
|
@ -67,8 +67,10 @@
|
|||
.createInstance(nsIFilePicker);
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
// XXXBlake Localize!
|
||||
fp.init(window, "Select Download Directory:", nsIFilePicker.modeGetFolder);
|
||||
|
||||
var prefbundle = document.getElementById("bundle_prefutilities");
|
||||
var description = prefbundle.getString("downloadDirTitle");
|
||||
fp.init(window, description, nsIFilePicker.modeGetFolder);
|
||||
try
|
||||
{
|
||||
var initialDir = pref.getComplexValue("browser.download.dir", nsILocalFile);
|
||||
|
@ -235,7 +237,8 @@
|
|||
<radio id="alwaysAskRadio" label="&rememberLast.label;" value="false"/>
|
||||
<hbox flex="1">
|
||||
<radio id="useDownloadDirRadio" label="&useDownloadDir.label;" value="true"/>
|
||||
<textbox id="defaultDir" flex="1" readonly="true" prefstring="browser.download.dir"/>
|
||||
<textbox id="defaultDir" flex="1" prefstring="browser.download.dir"
|
||||
onchange="checkDownloadDirectory();"/>
|
||||
<button id="browse" label="&browse.label;" oncommand="selectFolder();"/>
|
||||
</hbox>
|
||||
</radiogroup>
|
||||
|
|
|
@ -204,12 +204,16 @@ var PrivacyPanel = {
|
|||
var rdfs = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
var state = rdfs.GetResource("http://home.netscape.com/NC-rdf#DownloadState");
|
||||
var ds = dlMgr.datasource;
|
||||
var dls = [];
|
||||
|
||||
dlMgr.startBatchUpdate();
|
||||
while (downloads.hasMoreElements()) {
|
||||
var download = downloads.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
dls.push(download);
|
||||
}
|
||||
dlMgr.startBatchUpdate();
|
||||
for (var i = 0; i < dls.length; ++i) {
|
||||
try {
|
||||
dlMgr.removeDownload(download.Value);
|
||||
dlMgr.removeDownload(dls[i].Value);
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
|
|
@ -29,3 +29,8 @@ prefRemoveAllRemoveButton=Clear All Information
|
|||
prefRemovePasswdsMsg=Remove all saved passwords?
|
||||
prefRemovePasswdsTitle=Remove All Passwords
|
||||
prefRemovePasswdsRemoveButton=Remove All Passwords
|
||||
|
||||
invalidDirPopup=The directory %S does not exist. Do you wish to create it?
|
||||
downloadDirTitle=Select Download Directory
|
||||
invalidDir=Unable to create directory %S. This is not a valid directory name.
|
||||
blankDir=You did not specify a download directory.
|
||||
|
|
Загрузка…
Ссылка в новой задаче