Commit c1f177e4 authored by Felipe Gomes's avatar Felipe Gomes
Browse files

Bug 827976 - Downloads Manager doesn't need a reference to the hidden window. r=mak

Differential Revision: https://phabricator.services.mozilla.com/D21079

--HG--
extra : moz-landing-system : lando
parent 07bc0f44
......@@ -185,8 +185,9 @@ var DownloadsCommon = {
* HistoryDownloadsData objects, depending on the privacy status of the
* specified window and on whether history downloads should be included.
*
* @param window
* @param [optional] window
* The browser window which owns the download button.
* If not given, the privacy status will be assumed as non-private.
* @param [optional] history
* True to include history downloads when the window is public.
* @param [optional] privateAll
......@@ -197,7 +198,7 @@ var DownloadsCommon = {
* `kMaxHistoryResultsForLimitedView`.
*/
getData(window, history = false, privateAll = false, limited = false) {
let isPrivate = PrivateBrowsingUtils.isContentWindowPrivate(window);
let isPrivate = window && PrivateBrowsingUtils.isContentWindowPrivate(window);
if (isPrivate && !privateAll) {
return PrivateDownloadsData;
}
......
......@@ -5,6 +5,7 @@ XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
DownloadsCommon: "resource:///modules/DownloadsCommon.jsm",
DownloadsViewUI: "resource:///modules/DownloadsViewUI.jsm",
FileUtils: "resource://gre/modules/FileUtils.jsm",
......@@ -41,8 +42,8 @@ this.DownloadsManager = class DownloadsManager {
init(store) {
this._store = store;
this._browser = Services.appShell.hiddenDOMWindow;
this._downloadData = DownloadsCommon.getData(this._browser.ownerGlobal, true, false, true);
this._downloadData = DownloadsCommon.getData(null /* null for non-private downloads */,
true, false, true);
this._downloadData.addView(this);
}
......@@ -141,7 +142,7 @@ this.DownloadsManager = class DownloadsManager {
doDownloadAction(download => {
DownloadsCommon.openDownloadedFile(
new FileUtils.File(download.target.path), null,
this._browser.ownerGlobal);
BrowserWindowTracker.getTopWindow());
});
break;
case at.UNINIT:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment