summaryrefslogtreecommitdiffstats
path: root/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-04-28 17:57:18 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-04-28 17:57:18 +0200
commitf69729b0aa1d8cd1964994919ab30ce7c7d9f410 (patch)
treed877e04983b628a9e45271615fc9486712e4a404 /application/palemoon/components/downloads/content/allDownloadsViewOverlay.js
parentb53db93006f732fb2e140137e4713dedca1700d9 (diff)
parentde057c7a5635e65f45ce47162d226b1ddf24e8aa (diff)
downloadUXP-f69729b0aa1d8cd1964994919ab30ce7c7d9f410.tar
UXP-f69729b0aa1d8cd1964994919ab30ce7c7d9f410.tar.gz
UXP-f69729b0aa1d8cd1964994919ab30ce7c7d9f410.tar.lz
UXP-f69729b0aa1d8cd1964994919ab30ce7c7d9f410.tar.xz
UXP-f69729b0aa1d8cd1964994919ab30ce7c7d9f410.zip
Merge branch 'master' of https://github.com/MoonchildProductions/UXP
Diffstat (limited to 'application/palemoon/components/downloads/content/allDownloadsViewOverlay.js')
-rw-r--r--application/palemoon/components/downloads/content/allDownloadsViewOverlay.js59
1 files changed, 29 insertions, 30 deletions
diff --git a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js
index 46e867068..054f0405f 100644
--- a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js
+++ b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js
@@ -41,22 +41,6 @@ const DOWNLOAD_VIEW_SUPPORTED_COMMANDS =
const NOT_AVAILABLE = Number.MAX_VALUE;
/**
- * Download a URL.
- *
- * @param aURL
- * the url to download (nsIURI object)
- * @param [optional] aFileName
- * the destination file name
- */
-function DownloadURL(aURL, aFileName) {
- // For private browsing, try to get document out of the most recent browser
- // window, or provide our own if there's no browser window.
- let browserWin = RecentWindow.getMostRecentBrowserWindow();
- let initiatingDoc = browserWin ? browserWin.document : document;
- saveURL(aURL, aFileName, null, true, true, undefined, initiatingDoc);
-}
-
-/**
* A download element shell is responsible for handling the commands and the
* displayed data for a single download view element. The download element
* could represent either a past download (for which we get data from places) or
@@ -654,7 +638,10 @@ DownloadElementShell.prototype = {
// In future we may try to download into the same original target uri, when
// we have it. Though that requires verifying the path is still valid and
// may surprise the user if he wants to be requested every time.
- DownloadURL(this.downloadURI, this.getDownloadMetaData().fileName);
+ let browserWin = RecentWindow.getMostRecentBrowserWindow();
+ let initiatingDoc = browserWin ? browserWin.document : document;
+ DownloadURL(this.downloadURI, this.getDownloadMetaData().fileName,
+ initiatingDoc);
},
/* nsIController */
@@ -1407,16 +1394,11 @@ DownloadsPlacesView.prototype = {
_copySelectedDownloadsToClipboard:
function DPV__copySelectedDownloadsToClipboard() {
- let selectedElements = this._richlistbox.selectedItems;
- // Tycho: let urls = [e._shell.downloadURI for each (e in selectedElements)];
- let urls = [];
-
- for each (e in selectedElements) {
- urls.push(e._shell.downloadURI);
- }
+ let urls = [for (element of this._richlistbox.selectedItems)
+ element._shell.downloadURI];
Cc["@mozilla.org/widget/clipboardhelper;1"].
- getService(Ci.nsIClipboardHelper).copyString(urls.join("\n"), document);
+ getService(Ci.nsIClipboardHelper).copyString(urls.join("\n"));
},
_getURLFromClipboardData: function DPV__getURLFromClipboardData() {
@@ -1450,10 +1432,16 @@ DownloadsPlacesView.prototype = {
_downloadURLFromClipboard: function DPV__downloadURLFromClipboard() {
let [url, name] = this._getURLFromClipboardData();
- DownloadURL(url, name);
+ let browserWin = RecentWindow.getMostRecentBrowserWindow();
+ let initiatingDoc = browserWin ? browserWin.document : document;
+ DownloadURL(url, name, initiatingDoc);
},
doCommand: function DPV_doCommand(aCommand) {
+ // Commands may be invoked with keyboard shortcuts even if disabled.
+ if (!this.isCommandEnabled(aCommand)) {
+ return;
+ }
switch (aCommand) {
case "cmd_copy":
this._copySelectedDownloadsToClipboard();
@@ -1504,6 +1492,11 @@ DownloadsPlacesView.prototype = {
else
contextMenu.removeAttribute("state");
+ if (state == nsIDM.DOWNLOAD_DOWNLOADING) {
+ // The resumable property of a download may change at any time, so
+ // ensure we update the related command now.
+ goUpdateCommand("downloadsCmd_pauseResume");
+ }
return true;
},
@@ -1594,10 +1587,16 @@ DownloadsPlacesView.prototype = {
if (dt.mozGetDataAt("application/x-moz-file", 0))
return;
- let name = { };
- let url = Services.droppedLinkHandler.dropLink(aEvent, name);
- if (url)
- DownloadURL(url, name.value);
+ let links = Services.droppedLinkHandler.dropLinks(aEvent);
+ if (!links.length)
+ return;
+ let browserWin = RecentWindow.getMostRecentBrowserWindow();
+ let initiatingDoc = browserWin ? browserWin.document : document;
+ for (let link of links) {
+ if (link.url.startsWith("about:"))
+ continue;
+ DownloadURL(link.url, link.name, initiatingDoc);
+ }
}
};