[PALEMOON] Bug 1129896 - Part 2 of 2 - Convert the shared front-end code to a JavaScript code module

This commit is contained in:
janekptacijarabaci 2018-07-29 13:12:21 +02:00 • committed by Roy Tam
commit 83ba13fdac
8 changed files with 94 additions and 64 deletions

View file

@ -4,6 +4,21 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
XPCOMUtils.defineLazyModuleGetter(this, "DownloadsCommon",
"resource:///modules/DownloadsCommon.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DownloadsViewUI",
"resource:///modules/DownloadsViewUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
/**
* Handles the Downloads panel user interface for each browser window.
*
@ -1066,7 +1081,7 @@ function DownloadsViewItem(download, aElement) {
}
DownloadsViewItem.prototype = {
__proto__: DownloadElementShell.prototype,
__proto__: DownloadsViewUI.DownloadElementShell.prototype,
/**
* The XUL element corresponding to the associated richlistbox item.
@ -1253,10 +1268,7 @@ DownloadsViewItemController.prototype = {
commands: {
cmd_delete: function DVIC_cmd_delete()
{
Downloads.getList(Downloads.ALL)
.then(list => list.remove(this.download))
.then(() => this.download.finalize(true))
.catch(Cu.reportError);
DownloadsCommon.removeAndFinalizeDownload(this.download);
PlacesUtils.bhistory.removePage(
NetUtil.newURI(this.download.source.url));
},