Show an error if the user tries to open or show a download file that does not exist.

This commit is contained in:
ben%bengoodger.com 2003-12-01 01:54:25 +00:00
Родитель e2e1fe9307
Коммит b8004d16de
6 изменённых файлов: 65 добавлений и 10 удалений

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

@ -46,6 +46,7 @@
#include "nsIMIMEInfo.h"
#define SHOW_DLMGR_PREF "browser.download.manager.showWhenStarting"
#define USE_DL_WINDOW_PREF "browser.download.manager.useWindow"
class nsDownloadProxy : public nsIDownload,
public nsIWebProgressListener
@ -76,7 +77,10 @@ public:
PRBool showDM = PR_TRUE;
branch->GetBoolPref(SHOW_DLMGR_PREF, &showDM);
if (showDM) {
PRBool useWindow = PR_TRUE;
branch->GetBoolPref(USE_DL_WINDOW_PREF, &useWindow);
if (showDM && useWindow) {
nsAutoString path;
rv = aTarget->GetPath(path);
if (NS_FAILED(rv)) return rv;

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

@ -321,6 +321,15 @@
</xul:vbox>
<xul:vbox pack="start">
<xul:label value="&show.label;" class="link"
#ifdef XP_WIN
tooltip="&cmd.show.tooltipWin;"
#else
#ifdef XP_MACOSX
tooltip="&cmd.show.tooltipMac;"
#else
tooltip="&cmd.show.tooltipUnix;"
#endif
#endif
onclick="this.parentNode.parentNode.parentNode.fireEvent('show');"/>
</xul:vbox>
</xul:hbox>

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

@ -119,10 +119,17 @@ function autoClose(aDownload)
.getService(Components.interfaces.nsIPrefBranch);
var autoClose = pref.getBoolPref("browser.download.closeWhenDone")
if (autoClose && (!window.opener || window.opener.location.href == window.location.href))
window.close();
gCloseDownloadManager();
}
}
// This function can be overwritten by extensions that wish to place the Download Window in
// another part of the UI, such as in a tab or a sidebar panel.
function gCloseDownloadManager()
{
window.close();
}
var gDownloadObserver = {
observe: function (aSubject, aTopic, aState)
{
@ -211,6 +218,26 @@ function onDownloadShow(aEvent)
f.reveal();
#endif
}
else {
var brandStrings = document.getElementById("brandStrings");
var appName = brandStrings.getString("brandShortName");
var strings = document.getElementById("downloadStrings");
var name = aEvent.target.getAttribute("target");
#ifdef XP_WIN
var message = strings.getFormattedString("fileDoesNotExistShowErrorWin", [name, appName]);
#else
#ifdef XP_MACOSX
var message = strings.getFormattedString("fileDoesNotExistShowErrorMac", [name, appName]);
#else
var message = strings.getFormattedString("fileDoesNotExistShowErrorUnix", [name, appName]);
#endif
#endif
var title = strings.getFormattedString("fileDoesNotExistShowTitle", [name]);
var promptSvc = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
promptSvc.alert(window, title, message);
}
}
function onDownloadOpen(aEvent)
@ -225,6 +252,19 @@ function onDownloadOpen(aEvent)
// XXXben security check!
f.launch();
}
else {
var brandStrings = document.getElementById("brandStrings");
var appName = brandStrings.getString("brandShortName");
var strings = document.getElementById("downloadStrings");
var name = aEvent.target.getAttribute("target");
var message = strings.getFormattedString("fileDoesNotExistOpenError", [name, appName]);
var title = strings.getFormattedString("fileDoesNotExistOpenTitle", [name]);
var promptSvc = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
promptSvc.alert(window, title, message);
}
}
else if(download.canceledOrFailed) {
// If the user canceled this download, double clicking tries again.

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

@ -63,6 +63,7 @@
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<stringbundleset id="downloadSet">
<stringbundle id="brandStrings" src="chrome://global/locale/brand.properties"/>
<stringbundle id="downloadStrings" src="chrome://mozapps/locale/downloads/downloads.properties"/>
</stringbundleset>

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

@ -34,6 +34,9 @@
<!ENTITY cmd.cancel.accesskey "c">
<!ENTITY cmd.show.label "Show">
<!ENTITY cmd.show.accesskey "s">
<!ENTITY cmd.show.tooltipWin "Show this file in Explorer">
<!ENTITY cmd.show.tooltipMac "Show this file in Finder">
<!ENTITY cmd.show.tooltipUnix "Show this file in a browser window">
<!ENTITY cmd.open.label "Open">
<!ENTITY cmd.open.accesskey "o">
<!ENTITY cmd.openWith.label "Open With...">

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

@ -21,14 +21,12 @@ statusFormat=#1 at #2 KB/sec; #3 remain
longTimeFormat=#1:#2:#3
shortTimeFormat=#2:#3
showInShellLabelWin=Show in Explorer
showInShellAccesskeyWin=E
showInShellLabelMac=Show in Finder
showInShellAccesskeyMac=F
showInShellLabelUnix=Show in Browser
showInShellAccesskeyUnix=B
fileDoesNotExistOpenTitle=Cannot Open %S
fileDoesNotExistOpenError=%1S does not exist. (Perhaps you moved it from the place it was downloaded to?). Because of this, %2S cannot open this file.
fileDoesNotExistShowTitle=Cannot Show %S
fileDoesNotExistShowErrorWin=%S does not exist. (Perhaps you moved it from the place it was downloaded to?). Because of this, %S cannot show this file in Explorer.
fileDoesNotExistShowErrorMac=%S does not exist. (Perhaps you moved it from the place it was downloaded to?). Because of this, %S cannot show this file in Finder.
fileDoesNotExistShowErrorUnix=%S does not exist. (Perhaps you moved it from the place it was downloaded to?). Because of this, %S cannot show this file in a browser window.
chooseAppFilePickerTitle=Open With...
downloadsTitle=%S%% of 1 file - Downloads