зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
69860e8e2e
Коммит
4ced8fedcb
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<mozilla::Pair<uint32_t, bool>> 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<StringWriteFunc>(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<nsStringHashKey, OriginLog> mLog;
|
||||
};
|
||||
|
|
|
@ -1539,7 +1539,8 @@ BrowserElementChild.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
onSecurityChange: function(webProgress, request, state) {
|
||||
onSecurityChange: function(webProgress, request, oldState, state,
|
||||
contentBlockingLogJSON) {
|
||||
if (webProgress != docShell) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
},
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
},
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
},
|
||||
|
||||
|
|
|
@ -91,7 +91,8 @@ adapted from test_bug607584.xul by Kent James <kent@caspia.com>
|
|||
{
|
||||
},
|
||||
|
||||
onSecurityChange : function(aWebProgress, aRequest, aState)
|
||||
onSecurityChange : function(aWebProgress, aRequest, aOldState, aState,
|
||||
aContentBlockingLogJSON)
|
||||
{
|
||||
},
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -77,7 +77,8 @@ nsLDBBrowserContentListener.prototype = {
|
|||
this.mStatusText.value = aMessage;
|
||||
},
|
||||
|
||||
onSecurityChange : function(aWebProgress, aRequest, aState)
|
||||
onSecurityChange : function(aWebProgress, aRequest, aOldState, aState,
|
||||
aContentBlockingLogJSON)
|
||||
{
|
||||
},
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) ||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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<nsIDocShell> 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<nsIDocShell> 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;
|
||||
|
|
|
@ -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) {},
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -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"]),
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1473,9 +1473,12 @@ NS_IMETHODIMP nsDocLoader::OnSecurityChange(nsISupports * aContext,
|
|||
|
||||
nsCOMPtr<nsIRequest> request = do_QueryInterface(aContext);
|
||||
nsIWebProgress* webProgress = static_cast<nsIWebProgress*>(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...
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче