From 0517636d52bcbe3de70f0da678dfdaf95c8d185f Mon Sep 17 00:00:00 2001 From: Andrea Scarpino Date: Mon, 8 Apr 2024 22:33:59 +0200 Subject: [PATCH 1/2] Tell the observer if the download is coming from a private tab --- jscomps/EmbedliteDownloadManager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jscomps/EmbedliteDownloadManager.js b/jscomps/EmbedliteDownloadManager.js index 4c6c289..828730a 100644 --- a/jscomps/EmbedliteDownloadManager.js +++ b/jscomps/EmbedliteDownloadManager.js @@ -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"); XPCOMUtils.defineLazyModuleGetter(this, "Downloads", "resource://gre/modules/Downloads.jsm"); @@ -78,6 +79,7 @@ let DownloadView = { JSON.stringify({ msg: "dl-done", id: download.id, + privateMode: PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false, saveAsPdf: download.saveAsPdf || false, targetPath: download.target.path })); @@ -89,6 +91,7 @@ let DownloadView = { JSON.stringify({ msg: "dl-fail", id: download.id, + privateMode: PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false, saveAsPdf: download.saveAsPdf || false })); } @@ -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 })); } From a260723a0467d35ccb208d69cf8b1e8ad5452eda Mon Sep 17 00:00:00 2001 From: Raine Makelainen Date: Fri, 28 Jun 2024 13:21:28 +0300 Subject: [PATCH 2/2] [embedlite-components] Report privateMode from onDownloadChanged. JB#61971 Signed-off-by: Raine Makelainen --- jscomps/EmbedliteDownloadManager.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/jscomps/EmbedliteDownloadManager.js b/jscomps/EmbedliteDownloadManager.js index 828730a..87d9dcb 100644 --- a/jscomps/EmbedliteDownloadManager.js +++ b/jscomps/EmbedliteDownloadManager.js @@ -52,10 +52,13 @@ let DownloadView = { stopped: download.stopped }; + let isPrivate = PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false; + Services.obs.notifyObservers(null, "embed:download", JSON.stringify({ msg: "dl-start", id: this.counter, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false, displayName: download.target.path.split('/').slice(-1)[0], sourceUrl: download.source.url, @@ -69,6 +72,7 @@ let DownloadView = { JSON.stringify({ msg: "dl-progress", id: download.id, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false, percent: download.progress })); @@ -79,7 +83,7 @@ let DownloadView = { JSON.stringify({ msg: "dl-done", id: download.id, - privateMode: PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false, targetPath: download.target.path })); @@ -91,7 +95,7 @@ let DownloadView = { JSON.stringify({ msg: "dl-fail", id: download.id, - privateMode: PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false })); } @@ -101,18 +105,20 @@ let DownloadView = { JSON.stringify({ msg: "dl-cancel", id: download.id, - privateMode: PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false })); } }, onDownloadChanged: function(download) { + let isPrivate = PrivateBrowsingUtils.isContentWindowPrivate(Services.ww.activeWindow) || false; if (download.prevState.progress !== download.progress) { Services.obs.notifyObservers(null, "embed:download", JSON.stringify({ msg: "dl-progress", id: download.id, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false, percent: download.progress })); @@ -124,6 +130,7 @@ let DownloadView = { JSON.stringify({ msg: "dl-done", id: download.id, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false, targetPath: download.target.path })); @@ -136,6 +143,7 @@ let DownloadView = { JSON.stringify({ msg: "dl-fail", id: download.id, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false })); } @@ -146,6 +154,7 @@ let DownloadView = { JSON.stringify({ msg: "dl-cancel", id: download.id, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false })); } @@ -156,6 +165,7 @@ let DownloadView = { JSON.stringify({ msg: "dl-start", id: download.id, + privateMode: isPrivate, saveAsPdf: download.saveAsPdf || false, displayName: download.target.path.split('/').slice(-1)[0], sourceUrl: download.source.url,