Bug 1191591 - Delegate to the parent class' code when opening downloads from the download panel. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D73773
This commit is contained in:
Sam Foster 2020-05-15 20:43:46 +00:00
Родитель 77c99ee7fb
Коммит f6a19436a1
1 изменённых файлов: 24 добавлений и 28 удалений

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

@ -981,24 +981,20 @@ XPCOMUtils.defineConstant(this, "DownloadsView", DownloadsView);
* @param aElement
* XUL element corresponding to the single download item in the view.
*/
function DownloadsViewItem(download, aElement) {
this.download = download;
this.element = aElement;
this.element._shell = this;
this.element.setAttribute("type", "download");
this.element.classList.add("download-state");
class DownloadsViewItem extends DownloadsViewUI.DownloadElementShell {
constructor(download, aElement) {
super();
this.isPanel = true;
}
this.download = download;
this.element = aElement;
this.element._shell = this;
DownloadsViewItem.prototype = {
__proto__: DownloadsViewUI.DownloadElementShell.prototype,
this.element.setAttribute("type", "download");
this.element.classList.add("download-state");
/**
* The XUL element corresponding to the associated richlistbox item.
*/
_element: null,
this.isPanel = true;
}
onChanged() {
let newState = DownloadsCommon.stateOfDownload(this.download);
@ -1008,7 +1004,7 @@ DownloadsViewItem.prototype = {
} else {
this._updateStateInner();
}
},
}
isCommandEnabled(aCommand) {
switch (aCommand) {
@ -1044,33 +1040,33 @@ DownloadsViewItem.prototype = {
this,
aCommand
);
},
}
doCommand(aCommand) {
if (this.isCommandEnabled(aCommand)) {
this[aCommand]();
}
},
}
// Item commands
downloadsCmd_unblock() {
DownloadsPanel.hidePanel();
this.confirmUnblock(window, "unblock");
},
}
downloadsCmd_chooseUnblock() {
DownloadsPanel.hidePanel();
this.confirmUnblock(window, "chooseUnblock");
},
}
downloadsCmd_unblockAndOpen() {
DownloadsPanel.hidePanel();
this.unblockAndOpenDownload().catch(Cu.reportError);
},
}
downloadsCmd_open() {
DownloadsCommon.openDownload(this.download).catch(Cu.reportError);
super.downloadsCmd_open();
// We explicitly close the panel here to give the user the feedback that
// their click has been received, and we're handling the action.
@ -1078,7 +1074,7 @@ DownloadsViewItem.prototype = {
// before the panel would close. This also helps to prevent the user from
// accidentally opening a file several times.
DownloadsPanel.hidePanel();
},
}
downloadsCmd_show() {
let file = new FileUtils.File(this.download.target.path);
@ -1090,30 +1086,30 @@ DownloadsViewItem.prototype = {
// window to open before the panel closed. This also helps to prevent the
// user from opening the containing folder several times.
DownloadsPanel.hidePanel();
},
}
downloadsCmd_showBlockedInfo() {
DownloadsBlockedSubview.toggle(
this.element,
...this.rawBlockedTitleAndDetails
);
},
}
downloadsCmd_openReferrer() {
openURL(this.download.source.referrerInfo.originalReferrer);
},
}
downloadsCmd_copyLocation() {
DownloadsCommon.copyDownloadLink(this.download);
},
}
downloadsCmd_doDefault() {
let defaultCommand = this.currentDefaultCommandName;
if (defaultCommand && this.isCommandEnabled(defaultCommand)) {
this.doCommand(defaultCommand);
}
},
};
}
}
// DownloadsViewController