Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tell the observer if the download is coming from a private tab #97

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions jscomps/EmbedliteDownloadManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Cu = Components.utils;
const Cr = Components.results;

const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const { PrivateBrowsingUtils } = ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
ilpianista marked this conversation as resolved.
Show resolved Hide resolved

XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
"resource://gre/modules/Downloads.jsm");
Expand Down Expand Up @@ -78,6 +79,7 @@ let DownloadView = {
JSON.stringify({
msg: "dl-done",
id: download.id,
privateMode: PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false,
ilpianista marked this conversation as resolved.
Show resolved Hide resolved
saveAsPdf: download.saveAsPdf || false,
targetPath: download.target.path
}));
Expand All @@ -89,6 +91,7 @@ let DownloadView = {
JSON.stringify({
msg: "dl-fail",
id: download.id,
privateMode: PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When downloading normally without pausing / cancelling and continuing download these "embed:download" notifies inside onDownloadAdded should not trigger.

In normal scenario onDownloadAdded gets called only once per download (first thing that happens). To report status changes you need to stringify download.source.isPrivate for each "embed:download" notifies of the onDownloadChanged (and onDownloadAdded). Simpler just to have it foreach "embed:download" message.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understood this, please have a look to my changes. Thanks!

saveAsPdf: download.saveAsPdf || false
}));
}
Expand All @@ -98,6 +101,7 @@ let DownloadView = {
JSON.stringify({
msg: "dl-cancel",
id: download.id,
privateMode: PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false,
saveAsPdf: download.saveAsPdf || false
}));
}
Expand Down