зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1522210 - Fingerprinting and cryptomining classifiers must have separate nsIWebProgressListener blocking state codes - part 5 - generalize content blocking notification, r=ehsan
Differential Revision: https://phabricator.services.mozilla.com/D17838
This commit is contained in:
Родитель
bf8c0e40e2
Коммит
e9ac7d9ef2
|
@ -42,7 +42,7 @@ SimpleChannelParent::NotifyCookieAllowed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
SimpleChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) {
|
SimpleChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ interface nsIParentChannel : nsIStreamListener
|
||||||
* Called to notify the HttpChannelChild that cookie has been blocked for
|
* Called to notify the HttpChannelChild that cookie has been blocked for
|
||||||
* this load.
|
* this load.
|
||||||
*/
|
*/
|
||||||
[noscript] void notifyTrackingCookieBlocked(in uint32_t aRejectedReason);
|
[noscript] void notifyCookieBlocked(in uint32_t aRejectedReason);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to notify the HttpChannelChild that flash plugin state has changed.
|
* Called to notify the HttpChannelChild that flash plugin state has changed.
|
||||||
|
|
|
@ -42,7 +42,7 @@ DataChannelParent::NotifyCookieAllowed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DataChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) {
|
DataChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ FileChannelParent::NotifyCookieAllowed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
FileChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) {
|
FileChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,7 +513,7 @@ FTPChannelParent::NotifyCookieAllowed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
FTPChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) {
|
FTPChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) {
|
||||||
// One day, this should probably be filled in.
|
// One day, this should probably be filled in.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,10 +327,10 @@ IPCResult HttpBackgroundChannelChild::RecvNotifyCookieAllowed() {
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCResult HttpBackgroundChannelChild::RecvNotifyTrackingCookieBlocked(
|
IPCResult HttpBackgroundChannelChild::RecvNotifyCookieBlocked(
|
||||||
const uint32_t& aRejectedReason) {
|
const uint32_t& aRejectedReason) {
|
||||||
LOG(
|
LOG(
|
||||||
("HttpBackgroundChannelChild::RecvNotifyTrackingCookieBlocked [this=%p "
|
("HttpBackgroundChannelChild::RecvNotifyCookieBlocked [this=%p "
|
||||||
"aRejectedReason=%" PRIu32 "]\n",
|
"aRejectedReason=%" PRIu32 "]\n",
|
||||||
this, aRejectedReason));
|
this, aRejectedReason));
|
||||||
MOZ_ASSERT(OnSocketThread());
|
MOZ_ASSERT(OnSocketThread());
|
||||||
|
@ -339,7 +339,7 @@ IPCResult HttpBackgroundChannelChild::RecvNotifyTrackingCookieBlocked(
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
mChannelChild->ProcessNotifyTrackingCookieBlocked(aRejectedReason);
|
mChannelChild->ProcessNotifyCookieBlocked(aRejectedReason);
|
||||||
|
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,7 @@ class HttpBackgroundChannelChild final : public PHttpBackgroundChannelChild {
|
||||||
|
|
||||||
IPCResult RecvNotifyCookieAllowed() override;
|
IPCResult RecvNotifyCookieAllowed() override;
|
||||||
|
|
||||||
IPCResult RecvNotifyTrackingCookieBlocked(
|
IPCResult RecvNotifyCookieBlocked(const uint32_t& aRejectedReason) override;
|
||||||
const uint32_t& aRejectedReason) override;
|
|
||||||
|
|
||||||
IPCResult RecvNotifyTrackingResource(const bool& aIsThirdParty) override;
|
IPCResult RecvNotifyTrackingResource(const bool& aIsThirdParty) override;
|
||||||
|
|
||||||
|
|
|
@ -374,10 +374,10 @@ bool HttpBackgroundChannelParent::OnNotifyCookieAllowed() {
|
||||||
return SendNotifyCookieAllowed();
|
return SendNotifyCookieAllowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked(
|
bool HttpBackgroundChannelParent::OnNotifyCookieBlocked(
|
||||||
uint32_t aRejectedReason) {
|
uint32_t aRejectedReason) {
|
||||||
LOG(
|
LOG(
|
||||||
("HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked [this=%p "
|
("HttpBackgroundChannelParent::OnNotifyCookieBlocked [this=%p "
|
||||||
"aRejectedReason=%" PRIu32 "]\n",
|
"aRejectedReason=%" PRIu32 "]\n",
|
||||||
this, aRejectedReason));
|
this, aRejectedReason));
|
||||||
AssertIsInMainProcess();
|
AssertIsInMainProcess();
|
||||||
|
@ -391,9 +391,9 @@ bool HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked(
|
||||||
RefPtr<HttpBackgroundChannelParent> self = this;
|
RefPtr<HttpBackgroundChannelParent> self = this;
|
||||||
nsresult rv = mBackgroundThread->Dispatch(
|
nsresult rv = mBackgroundThread->Dispatch(
|
||||||
NS_NewRunnableFunction(
|
NS_NewRunnableFunction(
|
||||||
"net::HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked",
|
"net::HttpBackgroundChannelParent::OnNotifyCookieBlocked",
|
||||||
[self, aRejectedReason]() {
|
[self, aRejectedReason]() {
|
||||||
self->OnNotifyTrackingCookieBlocked(aRejectedReason);
|
self->OnNotifyCookieBlocked(aRejectedReason);
|
||||||
}),
|
}),
|
||||||
NS_DISPATCH_NORMAL);
|
NS_DISPATCH_NORMAL);
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ bool HttpBackgroundChannelParent::OnNotifyTrackingCookieBlocked(
|
||||||
return NS_SUCCEEDED(rv);
|
return NS_SUCCEEDED(rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SendNotifyTrackingCookieBlocked(aRejectedReason);
|
return SendNotifyCookieBlocked(aRejectedReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HttpBackgroundChannelParent::OnNotifyTrackingResource(bool aIsThirdParty) {
|
bool HttpBackgroundChannelParent::OnNotifyTrackingResource(bool aIsThirdParty) {
|
||||||
|
|
|
@ -70,8 +70,8 @@ class HttpBackgroundChannelParent final : public PHttpBackgroundChannelParent {
|
||||||
// To send NotifyCookieAllowed message over background channel.
|
// To send NotifyCookieAllowed message over background channel.
|
||||||
bool OnNotifyCookieAllowed();
|
bool OnNotifyCookieAllowed();
|
||||||
|
|
||||||
// To send NotifyTrackingCookieBlocked message over background channel.
|
// To send NotifyCookieBlocked message over background channel.
|
||||||
bool OnNotifyTrackingCookieBlocked(uint32_t aRejectedReason);
|
bool OnNotifyCookieBlocked(uint32_t aRejectedReason);
|
||||||
|
|
||||||
// To send NotifyTrackingResource message over background channel.
|
// To send NotifyTrackingResource message over background channel.
|
||||||
bool OnNotifyTrackingResource(bool aIsThirdParty);
|
bool OnNotifyTrackingResource(bool aIsThirdParty);
|
||||||
|
|
|
@ -1843,10 +1843,8 @@ void HttpChannelChild::ProcessNotifyCookieAllowed() {
|
||||||
NS_DISPATCH_NORMAL);
|
NS_DISPATCH_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpChannelChild::ProcessNotifyTrackingCookieBlocked(
|
void HttpChannelChild::ProcessNotifyCookieBlocked(uint32_t aRejectedReason) {
|
||||||
uint32_t aRejectedReason) {
|
LOG(("HttpChannelChild::ProcessNotifyCookieBlocked [this=%p]\n", this));
|
||||||
LOG(("HttpChannelChild::ProcessNotifyTrackingCookieBlocked [this=%p]\n",
|
|
||||||
this));
|
|
||||||
MOZ_ASSERT(OnSocketThread());
|
MOZ_ASSERT(OnSocketThread());
|
||||||
|
|
||||||
RefPtr<HttpChannelChild> self = this;
|
RefPtr<HttpChannelChild> self = this;
|
||||||
|
|
|
@ -264,7 +264,7 @@ class HttpChannelChild final : public PHttpChannelChild,
|
||||||
void ProcessNotifyChannelClassifierProtectionDisabled(
|
void ProcessNotifyChannelClassifierProtectionDisabled(
|
||||||
uint32_t aAcceptedReason);
|
uint32_t aAcceptedReason);
|
||||||
void ProcessNotifyCookieAllowed();
|
void ProcessNotifyCookieAllowed();
|
||||||
void ProcessNotifyTrackingCookieBlocked(uint32_t aRejectedReason);
|
void ProcessNotifyCookieBlocked(uint32_t aRejectedReason);
|
||||||
void ProcessNotifyTrackingResource(bool aIsThirdParty);
|
void ProcessNotifyTrackingResource(bool aIsThirdParty);
|
||||||
void ProcessNotifyFlashPluginStateChanged(
|
void ProcessNotifyFlashPluginStateChanged(
|
||||||
nsIHttpChannel::FlashPluginState aState);
|
nsIHttpChannel::FlashPluginState aState);
|
||||||
|
|
|
@ -1812,12 +1812,11 @@ HttpChannelParent::NotifyCookieAllowed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HttpChannelParent::NotifyTrackingCookieBlocked(uint32_t aRejectedReason) {
|
HttpChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) {
|
||||||
LOG(("HttpChannelParent::NotifyTrackingCookieBlocked [this=%p]\n", this));
|
LOG(("HttpChannelParent::NotifyCookieBlocked [this=%p]\n", this));
|
||||||
if (!mIPCClosed) {
|
if (!mIPCClosed) {
|
||||||
MOZ_ASSERT(mBgParent);
|
MOZ_ASSERT(mBgParent);
|
||||||
Unused << NS_WARN_IF(
|
Unused << NS_WARN_IF(!mBgParent->OnNotifyCookieBlocked(aRejectedReason));
|
||||||
!mBgParent->OnNotifyTrackingCookieBlocked(aRejectedReason));
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ child:
|
||||||
async NotifyCookieAllowed();
|
async NotifyCookieAllowed();
|
||||||
|
|
||||||
// Tell the child that tracking cookies are blocked for this load.
|
// Tell the child that tracking cookies are blocked for this load.
|
||||||
async NotifyTrackingCookieBlocked(uint32_t aRejectedReason);
|
async NotifyCookieBlocked(uint32_t aRejectedReason);
|
||||||
|
|
||||||
// Tell the child that the resource being loaded is on the tracking
|
// Tell the child that the resource being loaded is on the tracking
|
||||||
// protection list.
|
// protection list.
|
||||||
|
|
|
@ -209,12 +209,16 @@ namespace {
|
||||||
|
|
||||||
struct BlockingErrorCode {
|
struct BlockingErrorCode {
|
||||||
nsresult mErrorCode;
|
nsresult mErrorCode;
|
||||||
|
uint32_t mBlockingEventCode;
|
||||||
|
uint32_t mAllowingEventCode;
|
||||||
const char* mConsoleMessage;
|
const char* mConsoleMessage;
|
||||||
nsCString mConsoleCategory;
|
nsCString mConsoleCategory;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const BlockingErrorCode sBlockingErrorCodes[] = {
|
static const BlockingErrorCode sBlockingErrorCodes[] = {
|
||||||
{NS_ERROR_TRACKING_URI, "TrackerUriBlocked",
|
{NS_ERROR_TRACKING_URI,
|
||||||
|
nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT,
|
||||||
|
nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT, "TrackerUriBlocked",
|
||||||
NS_LITERAL_CSTRING("Tracking Protection")},
|
NS_LITERAL_CSTRING("Tracking Protection")},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -233,6 +237,16 @@ static const BlockingErrorCode sBlockingErrorCodes[] = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ bool UrlClassifierFeatureFactory::IsClassifierBlockingEventCode(
|
||||||
|
uint32_t aEventCode) {
|
||||||
|
for (const auto& blockingErrorCode : sBlockingErrorCodes) {
|
||||||
|
if (aEventCode == blockingErrorCode.mBlockingEventCode) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ const char*
|
/* static */ const char*
|
||||||
UrlClassifierFeatureFactory::ClassifierBlockingErrorCodeToConsoleMessage(
|
UrlClassifierFeatureFactory::ClassifierBlockingErrorCodeToConsoleMessage(
|
||||||
nsresult aError, nsACString& aCategory) {
|
nsresult aError, nsACString& aCategory) {
|
||||||
|
|
|
@ -41,6 +41,10 @@ class UrlClassifierFeatureFactory final {
|
||||||
// Returns true if this error is known as one of the blocking error codes.
|
// Returns true if this error is known as one of the blocking error codes.
|
||||||
static bool IsClassifierBlockingErrorCode(nsresult aError);
|
static bool IsClassifierBlockingErrorCode(nsresult aError);
|
||||||
|
|
||||||
|
// Returns true if this event is a known blocking state from
|
||||||
|
// nsIWebProgressListener.
|
||||||
|
static bool IsClassifierBlockingEventCode(uint32_t aEventCode);
|
||||||
|
|
||||||
// This can be called only if IsClassifierBlockingErrorCode(aError) returns
|
// This can be called only if IsClassifierBlockingErrorCode(aError) returns
|
||||||
// true.
|
// true.
|
||||||
static const char* ClassifierBlockingErrorCodeToConsoleMessage(
|
static const char* ClassifierBlockingErrorCodeToConsoleMessage(
|
||||||
|
|
|
@ -1502,7 +1502,7 @@ nsresult AntiTrackingCommon::IsOnContentBlockingAllowList(
|
||||||
// This channel is a parent-process proxy for a child process request.
|
// This channel is a parent-process proxy for a child process request.
|
||||||
// Tell the child process channel to do this instead.
|
// Tell the child process channel to do this instead.
|
||||||
if (aDecision == BlockingDecision::eBlock) {
|
if (aDecision == BlockingDecision::eBlock) {
|
||||||
parentChannel->NotifyTrackingCookieBlocked(aRejectedReason);
|
parentChannel->NotifyCookieBlocked(aRejectedReason);
|
||||||
} else {
|
} else {
|
||||||
parentChannel->NotifyCookieAllowed();
|
parentChannel->NotifyCookieAllowed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,7 +399,7 @@ NS_IMETHODIMP nsExtProtocolChannel::NotifyCookieAllowed() {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsExtProtocolChannel::NotifyTrackingCookieBlocked(
|
NS_IMETHODIMP nsExtProtocolChannel::NotifyCookieBlocked(
|
||||||
uint32_t aRejectedReason) {
|
uint32_t aRejectedReason) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче