Implement the features of Clear Aboe Downloads and Open Downloads Folder.
draft
Implement the features of Clear Aboe Downloads and Open Downloads Folder.
MozReview-Commit-ID: FWn669ifvNr
--- a/browser/components/downloads/content/downloads.js
+++ b/browser/components/downloads/content/downloads.js
@@ -518,16 +518,38 @@ const DownloadsPanel = {
if (DownloadsView.richListBox.itemCount > 0) {
DownloadsView.richListBox.focus();
} else {
DownloadsFooter.focus();
}
}
},
+ clearAboveDownloads() {
+ var downloads = DownloadsView._downloads;
+ for (var i = 0; i < downloads.length && i < DownloadsView.kItemCountLimit; i++) {
+ if (downloads[i].succeeded) {
+ DownloadsCommon.removeAndFinalizeDownload(downloads[i]);
+ PlacesUtils.bhistory.removePage(
+ NetUtil.newURI(downloads[i].source.url));
+
+ }
+ }
+ this.hidePanel();
+ },
+
+ openDownloadsFolder() {
+ const PREF_DOWNLOADS_FOLDER_SETTING = "browser.download.dir";
+ var prefSvc = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+ let file = new FileUtils.File(prefSvc.getCharPref(PREF_DOWNLOADS_FOLDER_SETTING));
+ DownloadsCommon.showDownloadedFile(file);
+ this.hidePanel();
+ },
+
/**
* Opens the downloads panel when data is ready to be displayed.
*/
_openPopupIfDataReady() {
// We don't want to open the popup if we already displayed it, or if we are
// still loading data.
if (this._state != this.kStateWaitingData || DownloadsView.loading) {
return;
--- a/browser/components/downloads/content/downloadsOverlay.xul
+++ b/browser/components/downloads/content/downloadsOverlay.xul
@@ -150,19 +150,21 @@
<stack class="plain" id="downloadsSimpleSummary">
<button id="downloadsHistory"
class="plain"
label="&downloadsHistory.label;"
accesskey="&downloadsHistory.accesskey;"
oncommand="DownloadsPanel.showDownloadsHistory();"/>
<menupopup id="downloadSubPanel" position="after_end">
<menuitem id="clearAboveDownloadsButton"
+ oncommand="DownloadsPanel.clearAboveDownloads();"
hidden="true"
label="&clearAboveDownloadsButton.label;"/>
<menuitem id="openDownloadsFolderButton"
+ oncommand="DownloadsPanel.openDownloadsFolder();"
label="&openDownloadsFolderButton.label;"/>
</menupopup>
<button id="downloadFooterSubPanelButton"
accesskey="&downloadsHistory.accesskey;"
type="panel"
popup="downloadSubPanel"
align="center"