Bug 1354532 - Part 6 - Make sure we're using the public session downloads data in the Library panel subview. r?paolo
MozReview-Commit-ID: 5JflNp8Y6A
--- a/browser/components/downloads/DownloadsCommon.jsm
+++ b/browser/components/downloads/DownloadsCommon.jsm
@@ -277,19 +277,22 @@ this.DownloadsCommon = {
},
/**
* Get access to one of the DownloadsData or PrivateDownloadsData objects,
* depending on the privacy status of the window in question.
*
* @param aWindow
* The browser window which owns the download button.
+ * @param [optional] forcePublic
+ * Whether to force the public downloads data to be returned, even if
+ * we're in private browsing window mode.
*/
- getData(aWindow) {
- if (PrivateBrowsingUtils.isContentWindowPrivate(aWindow)) {
+ getData(aWindow, forcePublic = false) {
+ if (!forcePublic && PrivateBrowsingUtils.isContentWindowPrivate(aWindow)) {
return PrivateDownloadsData;
}
return DownloadsData;
},
/**
* Initializes the Downloads back-end and starts receiving events for both the
* private and non-private downloads data objects.
--- a/browser/components/downloads/DownloadsPanelSubView.jsm
+++ b/browser/components/downloads/DownloadsPanelSubView.jsm
@@ -24,17 +24,18 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource://gre/modules/FileUtils.jsm");
let gPanelViewInstances = new WeakMap();
class DownloadsPanelSubView extends DownloadsViewUI.BaseDownloadsPlacesView {
constructor(event) {
let document = event.target.ownerDocument
let window = document.defaultView;
- super(window);
+ // Pass in `true` to make sure we subscribe to the public session downloads data.
+ super(window, true);
this.context = "panelDownloadsContextMenu";
this.controller = new DownloadsViewUI.DownloadsPlacesViewController(this);
this.showLabel = DownloadsCommon.strings[AppConstants.platform == "macosx" ?
"showMacLabel" : "showLabel"];
this.openLabel = DownloadsCommon.strings.openFileLabel;
let query = "place:transition=" + Ci.nsINavHistoryService.TRANSITION_DOWNLOAD +
--- a/browser/components/downloads/DownloadsViewUI.jsm
+++ b/browser/components/downloads/DownloadsViewUI.jsm
@@ -41,21 +41,21 @@ this.DownloadsViewUI = {
* handled by the Downloads user interface, including standard commands.
*/
isCommandName(name) {
return name.startsWith("cmd_") || name.startsWith("downloadsCmd_");
},
};
this.DownloadsViewUI.BaseDownloadsPlacesView = class {
- constructor(window) {
- this.init(window);
+ constructor(window, forcePublicData) {
+ this.init(window, true, forcePublicData);
}
- init(window, active = true) {
+ init(window, active = true, forcePublicData = false) {
this.window = window;
// Map download URLs to download element shells regardless of their type
this._downloadElementsShellsForURI = new Map();
// Map download data items to their element shells.
this._viewItemsForDownloads = new WeakMap();
@@ -64,17 +64,17 @@ this.DownloadsViewUI.BaseDownloadsPlaces
this._lastSessionDownloadElement = null;
this._searchTerm = "";
this._active = active;
// Register as a downloads view. The places data will be initialized by
// the places setter.
- this._downloadsData = DownloadsCommon.getData(window.opener || window);
+ this._downloadsData = DownloadsCommon.getData(window.opener || window, forcePublicData);
this._downloadsData.addView(this);
// Get the Download button out of the attention state since we're about to
// view all downloads.
DownloadsCommon.getIndicatorData(window).attention = DownloadsCommon.ATTENTION_NONE;
}
destructor() {