From 4ced8fedcbd23cd50bdb10a0b1d280b0b70d45c2 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Sat, 22 Sep 2018 20:29:07 -0400 Subject: [PATCH] Bug 1493563 - Part 5: Present the old state and the content blocking log to the web progress listeners; r=baku Differential Revision: https://phabricator.services.mozilla.com/D6595 --- accessible/base/DocManager.cpp | 4 +- .../base/content/browser-contentblocking.js | 3 +- browser/base/content/browser.js | 6 ++- browser/base/content/tabbrowser.js | 19 ++++++-- .../test/general/browser_alltabslistener.js | 6 ++- .../components/extensions/parent/ext-tabs.js | 3 +- .../components/shell/nsMacShellService.cpp | 4 +- docshell/base/nsDocShell.cpp | 4 +- docshell/base/nsDocShellTreeOwner.cpp | 4 +- dom/base/ContentBlockingLog.h | 46 +++++++++++++++++++ .../BrowserElementChildPreload.js | 3 +- dom/clients/manager/ClientNavigateOpChild.cpp | 3 +- dom/clients/manager/ClientOpenWindowUtils.cpp | 4 +- dom/html/HTMLFormElement.cpp | 4 +- dom/html/nsHTMLDNSPrefetch.cpp | 4 +- dom/ipc/TabParent.cpp | 17 +++++++ dom/presentation/PresentationCallbacks.cpp | 4 +- editor/composer/nsEditingSession.cpp | 5 +- editor/composer/test/test_bug434998.xul | 3 +- editor/libeditor/tests/test_bug607584.xul | 3 +- editor/libeditor/tests/test_bug616590.xul | 3 +- editor/libeditor/tests/test_bug780908.xul | 3 +- .../chrome/printpreview_bug396024_helper.xul | 3 +- .../chrome/printpreview_bug482976_helper.xul | 3 +- .../base/tests/chrome/printpreview_helper.xul | 3 +- layout/printing/ipc/RemotePrintJobChild.cpp | 5 +- layout/printing/nsPrintJob.cpp | 4 +- .../layout-debug/ui/content/layoutdebug.js | 3 +- mobile/android/chrome/content/browser.js | 3 +- .../modules/geckoview/GeckoViewProgress.jsm | 3 +- .../geckoview/GeckoViewTrackingProtection.jsm | 3 +- netwerk/base/nsISecureBrowserUI.idl | 25 ++++++++++ .../manager/ssl/nsSecureBrowserUIImpl.cpp | 39 +++++++++++++++- toolkit/actors/PrintingChild.jsm | 3 +- .../antitracking/test/browser/head.js | 5 +- toolkit/components/browser/nsWebBrowser.cpp | 7 ++- .../printing/content/printPreviewProgress.js | 3 +- .../printing/content/printProgress.js | 3 +- .../ipc/PrintProgressDialogChild.cpp | 4 +- .../components/printingui/nsPrintProgress.cpp | 6 ++- .../printingui/nsPrintingPromptService.cpp | 7 ++- .../statusfilter/nsBrowserStatusFilter.cpp | 7 ++- .../mochitest/test_threathit_report.html | 3 +- toolkit/modules/RemoteSecurityUI.jsm | 8 +++- toolkit/modules/RemoteWebProgress.jsm | 14 ++++-- toolkit/modules/WebProgressChild.jsm | 5 +- toolkit/mozapps/downloads/nsHelperAppDlg.js | 3 +- .../mozapps/extensions/content/extensions.js | 3 +- uriloader/base/nsDocLoader.cpp | 5 +- uriloader/base/nsIWebProgressListener.idl | 19 +++++++- .../prefetch/nsOfflineCacheUpdateService.cpp | 4 +- uriloader/prefetch/nsPrefetchService.cpp | 4 +- xpfe/appshell/nsChromeTreeOwner.cpp | 4 +- xpfe/appshell/nsWebShellWindow.cpp | 4 +- 54 files changed, 304 insertions(+), 66 deletions(-) diff --git a/accessible/base/DocManager.cpp b/accessible/base/DocManager.cpp index eb0fae05e719..92e6d2bbdde6 100644 --- a/accessible/base/DocManager.cpp +++ b/accessible/base/DocManager.cpp @@ -344,7 +344,9 @@ DocManager::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP DocManager::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t aState) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); return NS_OK; diff --git a/browser/base/content/browser-contentblocking.js b/browser/base/content/browser-contentblocking.js index 341f4dfa56f9..5075b2655527 100644 --- a/browser/base/content/browser-contentblocking.js +++ b/browser/base/content/browser-contentblocking.js @@ -464,7 +464,8 @@ var ContentBlocking = { Services.telemetry.getHistogramById("TRACKING_PROTECTION_SHIELD").add(value); }, - onSecurityChange(state, webProgress, isSimulated) { + onSecurityChange(oldState, state, webProgress, isSimulated, + contentBlockingLogJSON) { let baseURI = this._baseURIForChannelClassifier; // Don't deal with about:, file: etc. diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index a7315f93a90d..32cc1017586e 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -4987,7 +4987,8 @@ var XULBrowserWindow = { // 3. Called directly during this object's initializations. // aRequest will be null always in case 2 and 3, and sometimes in case 1 (for // instance, there won't be a request when STATE_BLOCKED_TRACKING_CONTENT is observed). - onSecurityChange(aWebProgress, aRequest, aState, aIsSimulated) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON, aIsSimulated) { // Don't need to do anything if the data we use to update the UI hasn't // changed let uri = gBrowser.currentURI; @@ -5014,7 +5015,8 @@ var XULBrowserWindow = { uri = Services.uriFixup.createExposableURI(uri); } catch (e) {} gIdentityHandler.updateIdentity(this._state, uri); - ContentBlocking.onSecurityChange(this._state, aWebProgress, aIsSimulated); + ContentBlocking.onSecurityChange(aOldState, this._state, aWebProgress, aIsSimulated, + aContentBlockingLogJSON); }, // simulate all change notifications after switching tabs diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index 057edec9e395..0b7944b8e3fd 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -944,8 +944,13 @@ window._gBrowser = { if (securityUI) { // Include the true final argument to indicate that this event is // simulated (instead of being observed by the webProgressListener). + // Note: check state first to make sure the security UI object updates its + // state from the docshell correctly. + let state = securityUI.state; + let oldState = securityUI.oldState; this._callProgressListeners(null, "onSecurityChange", - [webProgress, null, securityUI.state, true], + [webProgress, null, oldState, state, + securityUI.contentBlockingLogJSON, true], true, false); } @@ -1665,12 +1670,17 @@ window._gBrowser = { // Restore the securityUI state. let securityUI = aBrowser.securityUI; + // Make sure to call the state getter before the oldState getter to give + // the securityUI object a chance to sync its state with the docshell let state = securityUI ? securityUI.state : Ci.nsIWebProgressListener.STATE_IS_INSECURE; + let oldState = securityUI ? securityUI.oldState : + Ci.nsIWebProgressListener.STATE_IS_INSECURE; // Include the true final argument to indicate that this event is // simulated (instead of being observed by the webProgressListener). this._callProgressListeners(aBrowser, "onSecurityChange", - [aBrowser.webProgress, null, state, true], + [aBrowser.webProgress, null, oldState, state, + securityUI.contentBlockingLogJSON, true], true, false); if (aShouldBeRemote) { @@ -5060,9 +5070,10 @@ class TabProgressListener { this.mMessage = aMessage; } - onSecurityChange(aWebProgress, aRequest, aState) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, aContentBlockingLogJSON) { this._callProgressListeners("onSecurityChange", - [aWebProgress, aRequest, aState]); + [aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON]); } onRefreshAttempted(aWebProgress, aURI, aDelay, aSameURI) { diff --git a/browser/base/content/test/general/browser_alltabslistener.js b/browser/base/content/test/general/browser_alltabslistener.js index 634e6c74a390..6dca34fdd67b 100644 --- a/browser/base/content/test/general/browser_alltabslistener.js +++ b/browser/base/content/test/general/browser_alltabslistener.js @@ -26,7 +26,8 @@ var gFrontProgressListener = { onStatusChange(aWebProgress, aRequest, aStatus, aMessage) { }, - onSecurityChange(aWebProgress, aRequest, aState) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { var state = "onSecurityChange"; info("FrontProgress: " + state + " 0x" + aState.toString(16)); ok(gFrontNotificationsPos < gFrontNotifications.length, "Got an expected notification for the front notifications listener"); @@ -66,7 +67,8 @@ var gAllProgressListener = { ok(aBrowser == gTestBrowser, state + " notification came from the correct browser"); }, - onSecurityChange(aBrowser, aWebProgress, aRequest, aState) { + onSecurityChange(aBrowser, aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { var state = "onSecurityChange"; info("AllProgress: " + state + " 0x" + aState.toString(16)); ok(aBrowser == gTestBrowser, state + " notification came from the correct browser"); diff --git a/browser/components/extensions/parent/ext-tabs.js b/browser/components/extensions/parent/ext-tabs.js index b051da1041d6..2ee4a31d2431 100644 --- a/browser/components/extensions/parent/ext-tabs.js +++ b/browser/components/extensions/parent/ext-tabs.js @@ -1201,7 +1201,8 @@ this.tabs = class extends ExtensionAPI { let printProgressListener = { onLocationChange(webProgress, request, location, flags) { }, onProgressChange(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) { }, - onSecurityChange(webProgress, request, state) { }, + onSecurityChange(webProgress, request, oldState, state, + contentBlockingLogJSON) { }, onStateChange(webProgress, request, flags, status) { if ((flags & Ci.nsIWebProgressListener.STATE_STOP) && (flags & Ci.nsIWebProgressListener.STATE_IS_DOCUMENT)) { resolve(retval == 0 ? "saved" : "replaced"); diff --git a/browser/components/shell/nsMacShellService.cpp b/browser/components/shell/nsMacShellService.cpp index a3b19cfd6be1..1fbe50803544 100644 --- a/browser/components/shell/nsMacShellService.cpp +++ b/browser/components/shell/nsMacShellService.cpp @@ -191,7 +191,9 @@ nsMacShellService::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsMacShellService::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t aState) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { return NS_OK; } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index eaa759291d14..d91d4a73c4c7 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -7008,7 +7008,9 @@ nsDocShell::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsDocShell::OnSecurityChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, uint32_t aState) + nsIRequest* aRequest, uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); return NS_OK; diff --git a/docshell/base/nsDocShellTreeOwner.cpp b/docshell/base/nsDocShellTreeOwner.cpp index 2f0613b54e59..58cefea1650f 100644 --- a/docshell/base/nsDocShellTreeOwner.cpp +++ b/docshell/base/nsDocShellTreeOwner.cpp @@ -767,7 +767,9 @@ nsDocShellTreeOwner::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsDocShellTreeOwner::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t aState) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { return NS_OK; } diff --git a/dom/base/ContentBlockingLog.h b/dom/base/ContentBlockingLog.h index 5db9aadbdf3a..9ccf8da96676 100644 --- a/dom/base/ContentBlockingLog.h +++ b/dom/base/ContentBlockingLog.h @@ -7,10 +7,12 @@ #ifndef mozilla_dom_ContentBlockingLog_h #define mozilla_dom_ContentBlockingLog_h +#include "mozilla/JSONWriter.h" #include "mozilla/Pair.h" #include "mozilla/UniquePtr.h" #include "nsClassHashtable.h" #include "nsHashKeys.h" +#include "nsReadableUtils.h" #include "nsTArray.h" namespace mozilla { @@ -22,6 +24,19 @@ class ContentBlockingLog final // blocking types defined in nsIWebProgressListener. typedef nsTArray> OriginLog; + struct StringWriteFunc : public JSONWriteFunc + { + nsAString& mBuffer; // The lifetime of the struct must be bound to the buffer + explicit StringWriteFunc(nsAString& aBuffer) + : mBuffer(aBuffer) + {} + + void Write(const char* aStr) override + { + mBuffer.Append(NS_ConvertUTF8toUTF16(aStr)); + } + }; + public: ContentBlockingLog() = default; ~ContentBlockingLog() = default; @@ -43,6 +58,37 @@ public: } } + nsAutoString Stringify() + { + nsAutoString buffer; + + JSONWriter w(MakeUnique(buffer)); + w.Start(); + + for (auto iter = mLog.Iter(); !iter.Done(); iter.Next()) { + if (!iter.UserData()) { + w.StartArrayProperty(NS_ConvertUTF16toUTF8(iter.Key()).get(), w.SingleLineStyle); + w.EndArray(); + continue; + } + + w.StartArrayProperty(NS_ConvertUTF16toUTF8(iter.Key()).get(), w.SingleLineStyle); + for (auto& item: *iter.UserData()) { + w.StartArrayElement(w.SingleLineStyle); + { + w.IntElement(item.first()); + w.BoolElement(item.second()); + } + w.EndArray(); + } + w.EndArray(); + } + + w.End(); + + return buffer; + } + private: nsClassHashtable mLog; }; diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js index 47e028c99112..90b0ae03e8ec 100644 --- a/dom/browser-element/BrowserElementChildPreload.js +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -1539,7 +1539,8 @@ BrowserElementChild.prototype = { } }, - onSecurityChange: function(webProgress, request, state) { + onSecurityChange: function(webProgress, request, oldState, state, + contentBlockingLogJSON) { if (webProgress != docShell) { return; } diff --git a/dom/clients/manager/ClientNavigateOpChild.cpp b/dom/clients/manager/ClientNavigateOpChild.cpp index 3e56a287b2bf..bba6109d2163 100644 --- a/dom/clients/manager/ClientNavigateOpChild.cpp +++ b/dom/clients/manager/ClientNavigateOpChild.cpp @@ -128,7 +128,8 @@ public: NS_IMETHOD OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t aState) override + uint32_t aOldState, uint32_t aState, + const nsAString& aContentBlockingLogJSON) override { MOZ_CRASH("Unexpected notification."); return NS_OK; diff --git a/dom/clients/manager/ClientOpenWindowUtils.cpp b/dom/clients/manager/ClientOpenWindowUtils.cpp index 26507ffb2fa3..a0f4a927009e 100644 --- a/dom/clients/manager/ClientOpenWindowUtils.cpp +++ b/dom/clients/manager/ClientOpenWindowUtils.cpp @@ -133,7 +133,9 @@ public: NS_IMETHOD OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t aState) override + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) override { MOZ_ASSERT(false, "Unexpected notification."); return NS_OK; diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index 7c9fe66ce6f6..08b64a6cc33b 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -2131,7 +2131,9 @@ HTMLFormElement::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP HTMLFormElement::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t state) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); return NS_OK; diff --git a/dom/html/nsHTMLDNSPrefetch.cpp b/dom/html/nsHTMLDNSPrefetch.cpp index 7fdbabb8472f..f6337861709b 100644 --- a/dom/html/nsHTMLDNSPrefetch.cpp +++ b/dom/html/nsHTMLDNSPrefetch.cpp @@ -577,7 +577,9 @@ nsHTMLDNSPrefetch::nsDeferrals::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsHTMLDNSPrefetch::nsDeferrals::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, - uint32_t state) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { return NS_OK; } diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index ffbd5c32b1b4..91db46e33e2d 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -884,6 +884,15 @@ TabParent::Init(mozIDOMWindowProxy *window) return NS_OK; } +NS_IMETHODIMP +TabParent::GetOldState(uint32_t *aOldState) +{ + NS_ENSURE_ARG(aOldState); + NS_WARNING("SecurityState not valid here"); + *aOldState = 0; + return NS_OK; +} + NS_IMETHODIMP TabParent::GetState(uint32_t *aState) { @@ -893,6 +902,14 @@ TabParent::GetState(uint32_t *aState) return NS_OK; } +NS_IMETHODIMP +TabParent::GetContentBlockingLogJSON(nsAString& aContentBlockingLogJSON) +{ + NS_WARNING("ContentBlockingLog not valid here"); + aContentBlockingLogJSON.SetIsVoid(true); + return NS_OK; +} + NS_IMETHODIMP TabParent::GetSecInfo(nsITransportSecurityInfo** _result) { diff --git a/dom/presentation/PresentationCallbacks.cpp b/dom/presentation/PresentationCallbacks.cpp index 55ac50409a49..7aa5bbe55d37 100644 --- a/dom/presentation/PresentationCallbacks.cpp +++ b/dom/presentation/PresentationCallbacks.cpp @@ -273,7 +273,9 @@ PresentationResponderLoadingCallback::OnStatusChange(nsIWebProgress* aWebProgres NS_IMETHODIMP PresentationResponderLoadingCallback::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t state) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { // Do nothing. return NS_OK; diff --git a/editor/composer/nsEditingSession.cpp b/editor/composer/nsEditingSession.cpp index 399e954ef137..e6e45fd06732 100644 --- a/editor/composer/nsEditingSession.cpp +++ b/editor/composer/nsEditingSession.cpp @@ -813,7 +813,10 @@ nsEditingSession::OnStatusChange(nsIWebProgress *aWebProgress, ----------------------------------------------------------------------------*/ NS_IMETHODIMP nsEditingSession::OnSecurityChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, uint32_t state) + nsIRequest *aRequest, + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); return NS_OK; diff --git a/editor/composer/test/test_bug434998.xul b/editor/composer/test/test_bug434998.xul index 1f3fab7514a7..ebf9126500e8 100644 --- a/editor/composer/test/test_bug434998.xul +++ b/editor/composer/test/test_bug434998.xul @@ -87,7 +87,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=434998 { }, - onSecurityChange : function(aWebProgress, aRequest, aState) + onSecurityChange : function(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { }, diff --git a/editor/libeditor/tests/test_bug607584.xul b/editor/libeditor/tests/test_bug607584.xul index 16d815965f7f..5ff23a413a47 100644 --- a/editor/libeditor/tests/test_bug607584.xul +++ b/editor/libeditor/tests/test_bug607584.xul @@ -93,7 +93,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607584 { }, - onSecurityChange : function(aWebProgress, aRequest, aState) + onSecurityChange : function(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { }, diff --git a/editor/libeditor/tests/test_bug616590.xul b/editor/libeditor/tests/test_bug616590.xul index dfc94b1a8f9e..169b6eef4a7c 100644 --- a/editor/libeditor/tests/test_bug616590.xul +++ b/editor/libeditor/tests/test_bug616590.xul @@ -82,7 +82,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=616590 { }, - onSecurityChange : function(aWebProgress, aRequest, aState) + onSecurityChange : function(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { }, diff --git a/editor/libeditor/tests/test_bug780908.xul b/editor/libeditor/tests/test_bug780908.xul index 1e0939d041fd..8b626cbdd33d 100644 --- a/editor/libeditor/tests/test_bug780908.xul +++ b/editor/libeditor/tests/test_bug780908.xul @@ -91,7 +91,8 @@ adapted from test_bug607584.xul by Kent James { }, - onSecurityChange : function(aWebProgress, aRequest, aState) + onSecurityChange : function(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { }, diff --git a/layout/base/tests/chrome/printpreview_bug396024_helper.xul b/layout/base/tests/chrome/printpreview_bug396024_helper.xul index ae11bc2fd0d4..2f20470ee6d9 100644 --- a/layout/base/tests/chrome/printpreview_bug396024_helper.xul +++ b/layout/base/tests/chrome/printpreview_bug396024_helper.xul @@ -23,7 +23,8 @@ function printpreview() { onProgressChange: function(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) { }, - onSecurityChange: function(webProgress, request, state) { }, + onSecurityChange: function(webProgress, request, oldState, state, + contentBlockingLogJSON) { }, onStateChange: function(webProgress, request, stateFlags, status) { }, onStatusChange: function(webProgress, request, status, message) { }, QueryInterface: function(iid) { diff --git a/layout/base/tests/chrome/printpreview_bug482976_helper.xul b/layout/base/tests/chrome/printpreview_bug482976_helper.xul index 114b37bf1747..cc35e2e77c9d 100644 --- a/layout/base/tests/chrome/printpreview_bug482976_helper.xul +++ b/layout/base/tests/chrome/printpreview_bug482976_helper.xul @@ -23,7 +23,8 @@ function printpreview() { onProgressChange: function(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) { }, - onSecurityChange: function(webProgress, request, state) { }, + onSecurityChange: function(webProgress, request, oldState, state, + contentBlockingLogJSON) { }, onStateChange: function(webProgress, request, stateFlags, status) { }, onStatusChange: function(webProgress, request, status, message) { }, QueryInterface: function(iid) { diff --git a/layout/base/tests/chrome/printpreview_helper.xul b/layout/base/tests/chrome/printpreview_helper.xul index aac0ed817b28..c3a9ade0083f 100644 --- a/layout/base/tests/chrome/printpreview_helper.xul +++ b/layout/base/tests/chrome/printpreview_helper.xul @@ -30,7 +30,8 @@ function printpreview() { onProgressChange: function(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) { }, - onSecurityChange: function(webProgress, request, state) { }, + onSecurityChange: function(webProgress, request, oldState, state, + contentBlockingLogJSON) { }, onStateChange: function(webProgress, request, stateFlags, status) { }, onStatusChange: function(webProgress, request, status, message) { }, QueryInterface: function(iid) { diff --git a/layout/printing/ipc/RemotePrintJobChild.cpp b/layout/printing/ipc/RemotePrintJobChild.cpp index 2451d190ac5c..f64a932fe9ed 100644 --- a/layout/printing/ipc/RemotePrintJobChild.cpp +++ b/layout/printing/ipc/RemotePrintJobChild.cpp @@ -163,7 +163,10 @@ RemotePrintJobChild::OnStatusChange(nsIWebProgress* aProgress, NS_IMETHODIMP RemotePrintJobChild::OnSecurityChange(nsIWebProgress* aProgress, - nsIRequest* aRequest, uint32_t aState) + nsIRequest* aRequest, + uint32_t aState, + uint32_t aOldState, + const nsAString& aContentBlockingLogJSON) { return NS_OK; } diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index 863374fe005a..ae3f24f1a5cb 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -2116,7 +2116,9 @@ nsPrintJob::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsPrintJob::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t aState) + uint32_t aState, + uint32_t aOldState, + const nsAString& aContentBlockingLogJSON) { MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); return NS_OK; diff --git a/layout/tools/layout-debug/ui/content/layoutdebug.js b/layout/tools/layout-debug/ui/content/layoutdebug.js index e6e2130aa19b..3baaaa3c0441 100644 --- a/layout/tools/layout-debug/ui/content/layoutdebug.js +++ b/layout/tools/layout-debug/ui/content/layoutdebug.js @@ -77,7 +77,8 @@ nsLDBBrowserContentListener.prototype = { this.mStatusText.value = aMessage; }, - onSecurityChange : function(aWebProgress, aRequest, aState) + onSecurityChange : function(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { }, diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 54cf5cfb90fa..9eb60360af37 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -4692,7 +4692,8 @@ Tab.prototype = { _state: null, _hostChanged: false, // onLocationChange will flip this bit - onSecurityChange: function(aWebProgress, aRequest, aState) { + onSecurityChange: function(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { // Don't need to do anything if the data we use to update the UI hasn't changed if (this._state == aState && !this._hostChanged) return; diff --git a/mobile/android/modules/geckoview/GeckoViewProgress.jsm b/mobile/android/modules/geckoview/GeckoViewProgress.jsm index 8e94b3e49710..2525a8fe0571 100644 --- a/mobile/android/modules/geckoview/GeckoViewProgress.jsm +++ b/mobile/android/modules/geckoview/GeckoViewProgress.jsm @@ -252,7 +252,8 @@ class GeckoViewProgress extends GeckoViewModule { } } - onSecurityChange(aWebProgress, aRequest, aState) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { debug `onSecurityChange`; // Don't need to do anything if the data we use to update the UI hasn't changed diff --git a/mobile/android/modules/geckoview/GeckoViewTrackingProtection.jsm b/mobile/android/modules/geckoview/GeckoViewTrackingProtection.jsm index 74f365718924..6581ac0db044 100644 --- a/mobile/android/modules/geckoview/GeckoViewTrackingProtection.jsm +++ b/mobile/android/modules/geckoview/GeckoViewTrackingProtection.jsm @@ -20,7 +20,8 @@ class GeckoViewTrackingProtection extends GeckoViewModule { this.browser.addProgressListener(this.progressFilter, flags); } - onSecurityChange(aWebProgress, aRequest, aState) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { debug `onSecurityChange`; if (!(aState & Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT) || diff --git a/netwerk/base/nsISecureBrowserUI.idl b/netwerk/base/nsISecureBrowserUI.idl index 3f12d7bd3871..0bd8a25f9d03 100644 --- a/netwerk/base/nsISecureBrowserUI.idl +++ b/netwerk/base/nsISecureBrowserUI.idl @@ -16,7 +16,32 @@ interface nsISecureBrowserUI : nsISupports void init(in mozIDOMWindowProxy window); void setDocShell(in nsIDocShell docShell); + // A value composed of the Security State Flags and the Security + // Strength Flags defined in nsIWebProgressListener. + // Any undefined bits are reserved for future use. + // This represents the security state before the change. + readonly attribute unsigned long oldState; + // A value composed of the Security State Flags and the Security + // Strength Flags defined in nsIWebProgressListener. + // Any undefined bits are reserved for future use. + // This represents the security state after the change. readonly attribute unsigned long state; + // An optional JSON string representing a log of the content blocking + // events happened so far. This will be a JSON object containing keys + // representing origins that content blocking has acted on, with values + // being an array of items, each representing one action. Each action + // itself is an an array containing three elements, the first element + // being a blocking code from one of the Security State Flags above, and + // the second element being a boolean representing whether the origin + // was blocked (if true) or unblocked (if false) in that category, and + // the third element being the number of times that combination has been + // repeated consecutively. + // The reason JSON strings was chosen here was that we needed a format + // that is transferrable across processes in JS; and also the consumer + // of this data (browser-contentblocking.js) would be able to use the + // JSON.parse() API to parse out an object representation of the value. + readonly attribute AString contentBlockingLogJSON; + // Information about the connection security. readonly attribute nsITransportSecurityInfo secInfo; }; diff --git a/security/manager/ssl/nsSecureBrowserUIImpl.cpp b/security/manager/ssl/nsSecureBrowserUIImpl.cpp index 49dbc1ecd56a..9259360fa036 100644 --- a/security/manager/ssl/nsSecureBrowserUIImpl.cpp +++ b/security/manager/ssl/nsSecureBrowserUIImpl.cpp @@ -64,6 +64,20 @@ nsSecureBrowserUIImpl::Init(mozIDOMWindowProxy* aWindow) return wp->AddProgressListener(this, nsIWebProgress::NOTIFY_LOCATION); } +NS_IMETHODIMP +nsSecureBrowserUIImpl::GetOldState(uint32_t* aOldState) +{ + MOZ_ASSERT(NS_IsMainThread()); + NS_ENSURE_ARG(aOldState); + + MOZ_LOG(gSecureBrowserUILog, LogLevel::Debug, ("GetOldState %p", this)); + // Only sync our state with the docshell in GetState(). + MOZ_LOG(gSecureBrowserUILog, LogLevel::Debug, (" mOldState: %x", mOldState)); + + *aOldState = mOldState; + return NS_OK; +} + NS_IMETHODIMP nsSecureBrowserUIImpl::GetState(uint32_t* aState) { @@ -81,6 +95,26 @@ nsSecureBrowserUIImpl::GetState(uint32_t* aState) return NS_OK; } +NS_IMETHODIMP +nsSecureBrowserUIImpl::GetContentBlockingLogJSON(nsAString& aContentBlockingLogJSON) +{ + MOZ_ASSERT(NS_IsMainThread()); + + MOZ_LOG(gSecureBrowserUILog, LogLevel::Debug, ("GetContentBlockingLogJSON %p", this)); + aContentBlockingLogJSON.Truncate(); + nsCOMPtr docShell = do_QueryReferent(mDocShell); + if (docShell) { + nsIDocument* doc = docShell->GetDocument(); + if (doc) { + aContentBlockingLogJSON = doc->GetContentBlockingLog()->Stringify(); + } + } + MOZ_LOG(gSecureBrowserUILog, LogLevel::Debug, + (" ContentBlockingLogJSON: %s", NS_ConvertUTF16toUTF8(aContentBlockingLogJSON).get())); + + return NS_OK; +} + NS_IMETHODIMP nsSecureBrowserUIImpl::GetSecInfo(nsITransportSecurityInfo** result) { @@ -315,7 +349,7 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress, if (NS_WARN_IF(!eventSink)) { return NS_ERROR_INVALID_ARG; } - ContentBlockingLog* contentBlockingLog = nullptr; + mozilla::dom::ContentBlockingLog* contentBlockingLog = nullptr; nsCOMPtr docShell = do_QueryReferent(mDocShell); if (docShell) { nsIDocument* doc = docShell->GetDocument(); @@ -365,7 +399,8 @@ nsSecureBrowserUIImpl::OnStatusChange(nsIWebProgress*, } nsresult -nsSecureBrowserUIImpl::OnSecurityChange(nsIWebProgress*, nsIRequest*, uint32_t) +nsSecureBrowserUIImpl::OnSecurityChange(nsIWebProgress*, nsIRequest*, uint32_t, + uint32_t, const nsAString&) { MOZ_ASSERT_UNREACHABLE("Should have been excluded in AddProgressListener()"); return NS_OK; diff --git a/toolkit/actors/PrintingChild.jsm b/toolkit/actors/PrintingChild.jsm index 1fbcba8f7315..9e74183d0847 100644 --- a/toolkit/actors/PrintingChild.jsm +++ b/toolkit/actors/PrintingChild.jsm @@ -421,5 +421,6 @@ PrintingListener.prototype = { onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {}, onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {}, - onSecurityChange(aWebProgress, aRequest, aState) {}, + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) {}, }; diff --git a/toolkit/components/antitracking/test/browser/head.js b/toolkit/components/antitracking/test/browser/head.js index f6454f58b3df..7a0d13797ab8 100644 --- a/toolkit/components/antitracking/test/browser/head.js +++ b/toolkit/components/antitracking/test/browser/head.js @@ -596,8 +596,9 @@ this.AntiTracking = { let cookieBlocked = 0; let listener = { - onSecurityChange(webProgress, request, stateFlags, status) { - if (stateFlags & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER) { + onSecurityChange(webProgress, request, oldState, state, + status, contentBlockingLogJSON) { + if (state & Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_TRACKER) { ++cookieBlocked; } }, diff --git a/toolkit/components/browser/nsWebBrowser.cpp b/toolkit/components/browser/nsWebBrowser.cpp index c433ba18aff6..b6fc24433cbf 100644 --- a/toolkit/components/browser/nsWebBrowser.cpp +++ b/toolkit/components/browser/nsWebBrowser.cpp @@ -833,10 +833,13 @@ nsWebBrowser::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsWebBrowser::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t aState) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { if (mProgressListener) { - return mProgressListener->OnSecurityChange(aWebProgress, aRequest, aState); + return mProgressListener->OnSecurityChange(aWebProgress, aRequest, aOldState, + aState, aContentBlockingLogJSON); } return NS_OK; } diff --git a/toolkit/components/printing/content/printPreviewProgress.js b/toolkit/components/printing/content/printPreviewProgress.js index 54a0a837e3de..3b63e24e7050 100644 --- a/toolkit/components/printing/content/printPreviewProgress.js +++ b/toolkit/components/printing/content/printPreviewProgress.js @@ -59,7 +59,8 @@ var progressListener = { }, onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {}, - onSecurityChange(aWebProgress, aRequest, state) {}, + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) {}, onStatusChange(aWebProgress, aRequest, aStatus, aMessage) { if (aMessage) diff --git a/toolkit/components/printing/content/printProgress.js b/toolkit/components/printing/content/printProgress.js index 98ac22167aeb..3dbdbdc23225 100644 --- a/toolkit/components/printing/content/printProgress.js +++ b/toolkit/components/printing/content/printProgress.js @@ -144,7 +144,8 @@ var progressListener = { dialog.title.setAttribute("value", aMessage); }, - onSecurityChange(aWebProgress, aRequest, state) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { // we can ignore this notification }, diff --git a/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp b/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp index 45b13445e8a2..5c51857d3c30 100644 --- a/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp +++ b/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp @@ -100,7 +100,9 @@ PrintProgressDialogChild::OnStatusChange(nsIWebProgress* aProgress, NS_IMETHODIMP PrintProgressDialogChild::OnSecurityChange(nsIWebProgress* aProgress, nsIRequest* aRequest, - uint32_t aState) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { return NS_OK; } diff --git a/toolkit/components/printingui/nsPrintProgress.cpp b/toolkit/components/printingui/nsPrintProgress.cpp index 8bf307b06967..086b03748d48 100644 --- a/toolkit/components/printingui/nsPrintProgress.cpp +++ b/toolkit/components/printingui/nsPrintProgress.cpp @@ -244,7 +244,11 @@ NS_IMETHODIMP nsPrintProgress::OnStatusChange(nsIWebProgress *aWebProgress, nsIR return NS_OK; } -NS_IMETHODIMP nsPrintProgress::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t state) +NS_IMETHODIMP nsPrintProgress::OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { return NS_OK; } diff --git a/toolkit/components/printingui/nsPrintingPromptService.cpp b/toolkit/components/printingui/nsPrintingPromptService.cpp index 8ce0adb12698..f3c50d243059 100644 --- a/toolkit/components/printingui/nsPrintingPromptService.cpp +++ b/toolkit/components/printingui/nsPrintingPromptService.cpp @@ -228,12 +228,15 @@ nsPrintingPromptService::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsPrintingPromptService::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t state) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { #if !defined(XP_MACOSX) if (mWebProgressListener) { return mWebProgressListener->OnSecurityChange( - aWebProgress, aRequest, state); + aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON); } #endif return NS_OK; diff --git a/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp b/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp index c4d04dcc416b..fc66eace1624 100644 --- a/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp +++ b/toolkit/components/statusfilter/nsBrowserStatusFilter.cpp @@ -265,12 +265,15 @@ nsBrowserStatusFilter::OnStatusChange(nsIWebProgress *aWebProgress, NS_IMETHODIMP nsBrowserStatusFilter::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, - uint32_t aState) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { if (!mListener) return NS_OK; - return mListener->OnSecurityChange(aWebProgress, aRequest, aState); + return mListener->OnSecurityChange(aWebProgress, aRequest, aOldState, + aState, aContentBlockingLogJSON); } //----------------------------------------------------------------------------- diff --git a/toolkit/components/url-classifier/tests/mochitest/test_threathit_report.html b/toolkit/components/url-classifier/tests/mochitest/test_threathit_report.html index 7b2b96d6439a..292749ea21dc 100644 --- a/toolkit/components/url-classifier/tests/mochitest/test_threathit_report.html +++ b/toolkit/components/url-classifier/tests/mochitest/test_threathit_report.html @@ -194,7 +194,8 @@ function testOnWindow(aTestData) { let browser = win.gBrowser.selectedBrowser; let wp = win.gBrowser.contentWindow.docShell.QueryInterface(Ci.nsIWebProgress); let progressListener = { - onSecurityChange(aWebProgress, aRequest, aState) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { expected = aTestData.reportUrl; }, QueryInterface: ChromeUtils.generateQI(["nsISupportsWeakReference"]), diff --git a/toolkit/modules/RemoteSecurityUI.jsm b/toolkit/modules/RemoteSecurityUI.jsm index 1d0e402e37a5..5d736b38c0dc 100644 --- a/toolkit/modules/RemoteSecurityUI.jsm +++ b/toolkit/modules/RemoteSecurityUI.jsm @@ -7,19 +7,25 @@ var EXPORTED_SYMBOLS = ["RemoteSecurityUI"]; function RemoteSecurityUI() { this._secInfo = null; + this._oldState = 0; this._state = 0; + this._contentBlockingLogJSON = ""; } RemoteSecurityUI.prototype = { QueryInterface: ChromeUtils.generateQI([Ci.nsISecureBrowserUI]), // nsISecureBrowserUI + get oldState() { return this._oldState; }, get state() { return this._state; }, + get contentBlockingLogJSON() { return this._contentBlockingLogJSON; }, get tooltipText() { return ""; }, get secInfo() { return this._secInfo; }, - _update(aSecInfo, aState) { + _update(aSecInfo, aOldState, aState, aContentBlockingLogJSON) { this._secInfo = aSecInfo; + this._oldState = aOldState; this._state = aState; + this._contentBlockingLogJSON = aContentBlockingLogJSON; }, }; diff --git a/toolkit/modules/RemoteWebProgress.jsm b/toolkit/modules/RemoteWebProgress.jsm index 90534eca8335..f421f3149ef6 100644 --- a/toolkit/modules/RemoteWebProgress.jsm +++ b/toolkit/modules/RemoteWebProgress.jsm @@ -109,7 +109,7 @@ RemoteWebProgressManager.prototype = { this._progressListeners.filter(l => l.listener != aListener); }, - _fixSecInfoAndState(aSecInfo, aState) { + _fixSecInfo(aSecInfo) { let deserialized = null; if (aSecInfo) { let helper = Cc["@mozilla.org/network/serialization-helper;1"] @@ -119,7 +119,7 @@ RemoteWebProgressManager.prototype = { deserialized.QueryInterface(Ci.nsITransportSecurityInfo); } - return [deserialized, aState]; + return deserialized; }, setCurrentURI(aURI) { @@ -240,19 +240,23 @@ RemoteWebProgressManager.prototype = { break; case "Content:SecurityChange": - let [secInfo, state] = this._fixSecInfoAndState(json.secInfo, json.state); + let secInfo = this._fixSecInfo(json.secInfo); + let oldState = json.oldState; + let state = json.state; + let contentBlockingLogJSON = json.contentBlockingLogJSON; if (isTopLevel) { // Invoking this getter triggers the generation of the underlying object, // which we need to access with ._securityUI, because .securityUI returns // a wrapper that makes _update inaccessible. void this._browser.securityUI; - this._browser._securityUI._update(secInfo, state); + this._browser._securityUI._update(secInfo, oldState, state, + contentBlockingLogJSON); } this._callProgressListeners( Ci.nsIWebProgress.NOTIFY_SECURITY, "onSecurityChange", webProgress, - request, state + request, oldState, state, contentBlockingLogJSON ); break; diff --git a/toolkit/modules/WebProgressChild.jsm b/toolkit/modules/WebProgressChild.jsm index 1694ae4b584f..a20449e17257 100644 --- a/toolkit/modules/WebProgressChild.jsm +++ b/toolkit/modules/WebProgressChild.jsm @@ -213,12 +213,15 @@ class WebProgressChild { return null; } - onSecurityChange(aWebProgress, aRequest, aState) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { let json = this._setupJSON(aWebProgress, aRequest); let objects = this._setupObjects(aWebProgress, aRequest); + json.oldState = aOldState; json.state = aState; json.secInfo = this.getSecInfoAsString(); + json.contentBlockingLogJSON = aContentBlockingLogJSON; json.matchedList = null; if (aRequest && aRequest instanceof Ci.nsIClassifiedChannel) { diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js index 21dfb3fd5cec..3d74a2a9d166 100644 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.js +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js @@ -70,7 +70,8 @@ nsUnknownContentTypeDialogProgressListener.prototype = { onLocationChange(aWebProgress, aRequest, aLocation, aFlags) { }, - onSecurityChange(aWebProgress, aRequest, state) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { }, onRefreshAttempted(aWebProgress, aURI, aDelay, aSameURI) { diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 19a2ae1d1244..1ab8728b41e5 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -2135,7 +2135,8 @@ var gDiscoverView = { aRequest.cancel(Cr.NS_BINDING_ABORTED); }, - onSecurityChange(aWebProgress, aRequest, aState) { + onSecurityChange(aWebProgress, aRequest, aOldState, aState, + aContentBlockingLogJSON) { // Don't care about security if the page is not https if (!this.homepageURL.schemeIs("https")) return; diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index c9e3d597c738..c85ab11e2a13 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -1473,9 +1473,12 @@ NS_IMETHODIMP nsDocLoader::OnSecurityChange(nsISupports * aContext, nsCOMPtr request = do_QueryInterface(aContext); nsIWebProgress* webProgress = static_cast(this); + nsAutoString contentBlockingLogJSON( + aContentBlockingLog ? aContentBlockingLog->Stringify() : EmptyString()); NOTIFY_LISTENERS(nsIWebProgress::NOTIFY_SECURITY, - listener->OnSecurityChange(webProgress, request, aState); + listener->OnSecurityChange(webProgress, request, aOldState, aState, + contentBlockingLogJSON); ); // Pass the notification up to the parent... diff --git a/uriloader/base/nsIWebProgressListener.idl b/uriloader/base/nsIWebProgressListener.idl index 7140e4f6c480..e73fb56fc05f 100644 --- a/uriloader/base/nsIWebProgressListener.idl +++ b/uriloader/base/nsIWebProgressListener.idl @@ -474,15 +474,30 @@ interface nsIWebProgressListener : nsISupports * The nsIWebProgress instance that fired the notification. * @param aRequest * The nsIRequest that has new security state. + * @param aOldState + * A value composed of the Security State Flags and the Security + * Strength Flags listed above. Any undefined bits are reserved for + * future use. This represents the security state before the change. * @param aState * A value composed of the Security State Flags and the Security * Strength Flags listed above. Any undefined bits are reserved for - * future use. + * future use. This represents the security state after the change. + * @param aContentBlockingLog + * An optional JSON string representing a log of the content blocking + * events happened so far. This will be a JSON object containing keys + * representing origins that content blocking has acted on, with values + * being an array of items, each representing one action. Each action + * itself is an an array containing two elements, the first element + * being a blocking code from one of the Security State Flags above, and + * the second element being a boolean representing whether the origin + * was blocked (if true) or unblocked (if false) in that category. * * NOTE: These notifications will only occur if a security package is * installed. */ void onSecurityChange(in nsIWebProgress aWebProgress, in nsIRequest aRequest, - in unsigned long aState); + in unsigned long aOldState, + in unsigned long aState, + in AString aContentBlockingLogJSON); }; diff --git a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp index 74d51d6421ac..7389dd81741c 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp @@ -222,7 +222,9 @@ nsOfflineCachePendingUpdate::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsOfflineCachePendingUpdate::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, - uint32_t state) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); return NS_OK; diff --git a/uriloader/prefetch/nsPrefetchService.cpp b/uriloader/prefetch/nsPrefetchService.cpp index 745c7e4b458e..42aee02057f8 100644 --- a/uriloader/prefetch/nsPrefetchService.cpp +++ b/uriloader/prefetch/nsPrefetchService.cpp @@ -1028,7 +1028,9 @@ nsPrefetchService::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsPrefetchService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, - uint32_t state) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); return NS_OK; diff --git a/xpfe/appshell/nsChromeTreeOwner.cpp b/xpfe/appshell/nsChromeTreeOwner.cpp index d8a7f3e49342..d610a0aec105 100644 --- a/xpfe/appshell/nsChromeTreeOwner.cpp +++ b/xpfe/appshell/nsChromeTreeOwner.cpp @@ -499,7 +499,9 @@ nsChromeTreeOwner::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsChromeTreeOwner::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, - uint32_t state) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { return NS_OK; } diff --git a/xpfe/appshell/nsWebShellWindow.cpp b/xpfe/appshell/nsWebShellWindow.cpp index 4f75d01265ea..e0cafa3d0625 100644 --- a/xpfe/appshell/nsWebShellWindow.cpp +++ b/xpfe/appshell/nsWebShellWindow.cpp @@ -676,7 +676,9 @@ nsWebShellWindow::OnStatusChange(nsIWebProgress* aWebProgress, NS_IMETHODIMP nsWebShellWindow::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, - uint32_t state) + uint32_t aOldState, + uint32_t aState, + const nsAString& aContentBlockingLogJSON) { MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); return NS_OK;