From b15719c7f8c862b3898bd49930bb11f5202dc893 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 15 Apr 2018 11:49:38 +0200 Subject: Bug 92737 - Part 8: Download multiple files when multiple items are dropped on Downloads button Issue #121 --- .../components/downloads/content/indicator.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'application/palemoon/components') diff --git a/application/palemoon/components/downloads/content/indicator.js b/application/palemoon/components/downloads/content/indicator.js index e6a5bd012..1a2175a92 100644 --- a/application/palemoon/components/downloads/content/indicator.js +++ b/application/palemoon/components/downloads/content/indicator.js @@ -548,15 +548,18 @@ const DownloadsIndicatorView = { if (dt.mozGetDataAt("application/x-moz-file", 0)) return; - let name = {}; - let url = browserDragAndDrop.drop(aEvent, name); - if (url) { - if (url.startsWith("about:")) { - return; - } - - let sourceDoc = dt.mozSourceNode ? dt.mozSourceNode.ownerDocument : document; - saveURL(url, name.value, null, true, true, null, sourceDoc); + let links = browserDragAndDrop.dropLinks(aEvent); + if (!links.length) + return; + let sourceDoc = dt.mozSourceNode ? dt.mozSourceNode.ownerDocument : document; + let handled = false; + for (let link of links) { + if (link.url.startsWith("about:")) + continue; + saveURL(link.url, link.name, null, true, true, null, sourceDoc); + handled = true; + } + if (handled) { aEvent.preventDefault(); } }, -- cgit v1.2.3 From 02dffb57c8c330ae6d299141ae97ae23f433a927 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 15 Apr 2018 11:52:31 +0200 Subject: Bug 92737 - Part 9: Download multiple files when multiple items are dropped on Downloads view in Library Window Issue #121 --- .../components/downloads/content/allDownloadsViewOverlay.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'application/palemoon/components') diff --git a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js index 46e867068..d9758cb09 100644 --- a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js +++ b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js @@ -1594,10 +1594,14 @@ 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; + for (let link of links) { + if (link.url.startsWith("about:")) + continue; + DownloadURL(link.url, link.name); + } } }; -- cgit v1.2.3 From fa6fa13eb45f2fbfc79545e9b832c7b1ebb2dcae Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 25 Apr 2018 16:05:19 +0200 Subject: Bug 945707 - Pausing a download fails when done after a retry + follow up (see the description) Issue #121 [follow up] Bug 92737 - Part 9: Download multiple files when multiple items are dropped on Downloads view in Library Window --- .../downloads/content/allDownloadsViewOverlay.js | 34 ++++++++++------------ .../components/downloads/content/downloads.js | 3 +- 2 files changed, 16 insertions(+), 21 deletions(-) (limited to 'application/palemoon/components') diff --git a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js index d9758cb09..cf51db9d9 100644 --- a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js +++ b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js @@ -40,22 +40,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 @@ -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 */ @@ -1450,7 +1437,9 @@ 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) { @@ -1504,6 +1493,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; }, @@ -1597,10 +1591,12 @@ DownloadsPlacesView.prototype = { 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); + DownloadURL(link.url, link.name, initiatingDoc); } } }; diff --git a/application/palemoon/components/downloads/content/downloads.js b/application/palemoon/components/downloads/content/downloads.js index 0412344bc..833d7d72f 100644 --- a/application/palemoon/components/downloads/content/downloads.js +++ b/application/palemoon/components/downloads/content/downloads.js @@ -507,8 +507,7 @@ const DownloadsPanel = { let uri = NetUtil.newURI(url); DownloadsCommon.log("Pasted URL seems valid. Starting download."); - saveURL(uri.spec, name || uri.spec, null, true, true, - undefined, document); + DownloadURL(uri.spec, name, document); } catch (ex) {} }, -- cgit v1.2.3 From 1e7bbbf01cdecf57823ca302730827c15175cd22 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 25 Apr 2018 20:27:42 +0200 Subject: Bug 1243445 - Pasting an invalid URL breaks the Downloads View in the Library Issue #121 --- .../palemoon/components/downloads/content/allDownloadsViewOverlay.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'application/palemoon/components') diff --git a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js index cf51db9d9..4ed2b6e3d 100644 --- a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js +++ b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js @@ -1443,6 +1443,10 @@ DownloadsPlacesView.prototype = { }, 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(); -- cgit v1.2.3 From 72def35cd0cf3649b6d7ab72b66117df3e1c33fc Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 26 Apr 2018 00:19:51 +0200 Subject: [PALEMOON] [frontend vs backend] Downloads: Fix - the context menu - "Copy Download Link" Issue #121 --- .../components/downloads/content/allDownloadsViewOverlay.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'application/palemoon/components') diff --git a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js index 4ed2b6e3d..054f0405f 100644 --- a/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js +++ b/application/palemoon/components/downloads/content/allDownloadsViewOverlay.js @@ -1394,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() { -- cgit v1.2.3