mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1588899 - P1. Move classification flags related method to nsIClassifiedChannel. r=Ehsan,baku
This is where it should have been in the first place. Those attributes belong there. Differential Revision: https://phabricator.services.mozilla.com/D49577 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
8512c64c65
commit
e6d0e7dfda
@ -348,13 +348,15 @@ NetworkObserver.prototype = {
|
||||
(topic != "http-on-examine-response" &&
|
||||
topic != "http-on-examine-cached-response" &&
|
||||
topic != "http-on-failed-opening-request") ||
|
||||
!(subject instanceof Ci.nsIHttpChannel)
|
||||
!(subject instanceof Ci.nsIHttpChannel) ||
|
||||
!(subject instanceof Ci.nsIClassifiedChannel)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const blockedOrFailed = topic === "http-on-failed-opening-request";
|
||||
|
||||
subject.QueryInterface(Ci.nsIClassifiedChannel);
|
||||
const channel = subject.QueryInterface(Ci.nsIHttpChannel);
|
||||
|
||||
if (!matchRequest(channel, this.filters)) {
|
||||
@ -559,11 +561,15 @@ NetworkObserver.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(channel instanceof Ci.nsIHttpChannel)) {
|
||||
if (
|
||||
!(channel instanceof Ci.nsIHttpChannel) ||
|
||||
!(channel instanceof Ci.nsIClassifiedChannel)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
channel = channel.QueryInterface(Ci.nsIHttpChannel);
|
||||
channel = channel.QueryInterface(Ci.nsIClassifiedChannel);
|
||||
|
||||
if (
|
||||
activitySubtype == gActivityDistributor.ACTIVITY_SUBTYPE_REQUEST_HEADER
|
||||
|
@ -169,6 +169,7 @@
|
||||
#include "nsIForm.h"
|
||||
#include "nsIFragmentContentSink.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIIdleService.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
@ -7993,13 +7994,13 @@ bool nsContentUtils::IsTrackingResourceWindow(nsPIDOMWindowInner* aWindow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel =
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(document->GetChannel());
|
||||
if (!httpChannel) {
|
||||
if (!classifiedChannel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return httpChannel->IsTrackingResource();
|
||||
return classifiedChannel->IsTrackingResource();
|
||||
}
|
||||
|
||||
// static public
|
||||
@ -8012,13 +8013,13 @@ bool nsContentUtils::IsThirdPartyTrackingResourceWindow(
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel =
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(document->GetChannel());
|
||||
if (!httpChannel) {
|
||||
if (!classifiedChannel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return httpChannel->IsThirdPartyTrackingResource();
|
||||
return classifiedChannel->IsThirdPartyTrackingResource();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -38,7 +38,7 @@ enum MozContentPolicyType {
|
||||
};
|
||||
|
||||
/**
|
||||
* String versions of CLASSIFIED_* tracking flags from nsHttpChannel.idl
|
||||
* String versions of CLASSIFIED_* tracking flags from nsIClassifiedChannel.idl
|
||||
*/
|
||||
enum MozUrlClassificationFlags {
|
||||
"fingerprinting",
|
||||
|
@ -227,5 +227,34 @@ NS_IMETHODIMP RemoteWebProgressRequest::SetLoadFlags(nsLoadFlags aLoadFlags) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoteWebProgressRequest::IsTrackingResource(bool* aIsTrackingResource) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoteWebProgressRequest::IsThirdPartyTrackingResource(
|
||||
bool* aIsTrackingResource) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoteWebProgressRequest::GetClassificationFlags(
|
||||
uint32_t* aClassificationFlags) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoteWebProgressRequest::GetFirstPartyClassificationFlags(
|
||||
uint32_t* aClassificationFlags) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoteWebProgressRequest::GetThirdPartyClassificationFlags(
|
||||
uint32_t* aClassificationFlags) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIClassOfService.h"
|
||||
@ -3592,7 +3593,10 @@ nsresult ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
|
||||
aRequest->mSourceMapURL = NS_ConvertUTF8toUTF16(sourceMapURL);
|
||||
}
|
||||
|
||||
if (httpChannel->IsThirdPartyTrackingResource()) {
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel = do_QueryInterface(req);
|
||||
MOZ_ASSERT(classifiedChannel);
|
||||
if (classifiedChannel &&
|
||||
classifiedChannel->IsThirdPartyTrackingResource()) {
|
||||
aRequest->SetIsTracking();
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
* result information of channel classifier. The information contains, for
|
||||
* example, the name of matched table and the name of matched provider.
|
||||
*/
|
||||
[scriptable, uuid(70cf6091-a1de-4aa8-8224-058f8964be31)]
|
||||
[builtinclass, scriptable, uuid(70cf6091-a1de-4aa8-8224-058f8964be31)]
|
||||
interface nsIClassifiedChannel : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -64,4 +64,131 @@ interface nsIClassifiedChannel : nsISupports
|
||||
* Full hash of URLs that matched
|
||||
*/
|
||||
readonly attribute Array<ACString> matchedTrackingFullHashes;
|
||||
|
||||
/**
|
||||
* Returns the classification flags if the channel has been processed by
|
||||
* URL-Classifier features and is considered first-party.
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long firstPartyClassificationFlags;
|
||||
|
||||
/**
|
||||
* Returns the classification flags if the channel has been processed by
|
||||
* URL-Classifier features and is considered third-party with the top
|
||||
* window URI.
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long thirdPartyClassificationFlags;
|
||||
|
||||
/*
|
||||
* Returns the classification flags if the channel has been processed by
|
||||
* URL-Classifier features. This value is equal to
|
||||
* "firstPartyClassificationFlags || thirdPartyClassificationFlags".
|
||||
*
|
||||
* Note that top-level channels could be classified as well.
|
||||
* In order to identify third-party resources specifically, use
|
||||
* classificationThirdPartyFlags;
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long classificationFlags;
|
||||
|
||||
cenum ClassificationFlags : 32 {
|
||||
/**
|
||||
* The resource is on the fingerprinting list.
|
||||
*/
|
||||
CLASSIFIED_FINGERPRINTING = 0x0001,
|
||||
CLASSIFIED_FINGERPRINTING_CONTENT = 0x0080,
|
||||
|
||||
/**
|
||||
* The resource is on the cryptomining list.
|
||||
*/
|
||||
CLASSIFIED_CRYPTOMINING = 0x0002,
|
||||
CLASSIFIED_CRYPTOMINING_CONTENT = 0x0100,
|
||||
|
||||
/**
|
||||
* The following are about tracking annotation and are available only
|
||||
* if the privacy.trackingprotection.annotate_channels pref.
|
||||
* CLASSIFIED_TRACKING is set if we are not able to identify the
|
||||
* type of classification.
|
||||
*/
|
||||
CLASSIFIED_TRACKING = 0x0004,
|
||||
CLASSIFIED_TRACKING_AD = 0x0008,
|
||||
CLASSIFIED_TRACKING_ANALYTICS = 0x0010,
|
||||
CLASSIFIED_TRACKING_SOCIAL = 0x0020,
|
||||
CLASSIFIED_TRACKING_CONTENT = 0x0040,
|
||||
|
||||
/**
|
||||
* The following are about social tracking.
|
||||
*/
|
||||
CLASSIFIED_SOCIALTRACKING = 0x0200,
|
||||
CLASSIFIED_SOCIALTRACKING_FACEBOOK = 0x0400,
|
||||
CLASSIFIED_SOCIALTRACKING_LINKEDIN = 0x0800,
|
||||
CLASSIFIED_SOCIALTRACKING_TWITTER = 0x1000,
|
||||
|
||||
/**
|
||||
* This is exposed to help to identify tracking classification using the
|
||||
* basic lists.
|
||||
*/
|
||||
CLASSIFIED_ANY_BASIC_TRACKING = CLASSIFIED_TRACKING |
|
||||
CLASSIFIED_TRACKING_AD | CLASSIFIED_TRACKING_ANALYTICS |
|
||||
CLASSIFIED_TRACKING_SOCIAL | CLASSIFIED_FINGERPRINTING,
|
||||
|
||||
/**
|
||||
* This is exposed to help to identify tracking classification using the
|
||||
* strict lists.
|
||||
*/
|
||||
CLASSIFIED_ANY_STRICT_TRACKING = CLASSIFIED_ANY_BASIC_TRACKING |
|
||||
CLASSIFIED_TRACKING_CONTENT | CLASSIFIED_FINGERPRINTING_CONTENT,
|
||||
|
||||
/**
|
||||
* This is exposed to help to identify social tracking classification
|
||||
* flags.
|
||||
*/
|
||||
CLASSIFIED_ANY_SOCIAL_TRACKING = CLASSIFIED_SOCIALTRACKING |
|
||||
CLASSIFIED_SOCIALTRACKING_FACEBOOK |
|
||||
CLASSIFIED_SOCIALTRACKING_LINKEDIN | CLASSIFIED_SOCIALTRACKING_TWITTER,
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the channel has loaded a resource that is classified as
|
||||
* tracker.
|
||||
* This is a helper attribute which returns the same value of
|
||||
* (classificationFlags & CLASSIFIED_ANY_BASIC_TRACKING) or
|
||||
* (classificationFlags & CLASSIFIED_ANY_STRICT_TRACKING)
|
||||
*
|
||||
* Note that top-level channels could be marked as tracking
|
||||
* resource. In order to identify third-party tracking resources
|
||||
* specifically, use isThirdPartyTrackingResource().
|
||||
*/
|
||||
boolean isTrackingResource();
|
||||
|
||||
%{ C++
|
||||
inline bool IsTrackingResource()
|
||||
{
|
||||
bool value = false;
|
||||
if (NS_SUCCEEDED(IsTrackingResource(&value)) && value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Returns the classification flags if the channel has been processed by
|
||||
* URL-Classifier features and is considered third-party with the top
|
||||
* window URI.
|
||||
*
|
||||
* This is a helper attribute which returns the same value of
|
||||
* (thirdPartyClassificationFlags & CLASSIFIED_ANY_BASIC_TRACKING) or
|
||||
* (thirdPartyClassificationFlags & CLASSIFIED_ANY_STRICT_TRACKING)
|
||||
*/
|
||||
boolean isThirdPartyTrackingResource();
|
||||
|
||||
%{ C++
|
||||
inline bool IsThirdPartyTrackingResource()
|
||||
{
|
||||
bool value = false;
|
||||
if (NS_SUCCEEDED(IsThirdPartyTrackingResource(&value)) && value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
%}
|
||||
};
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsCookiePermission.h"
|
||||
#include "nsIEffectiveTLDService.h"
|
||||
@ -143,14 +144,15 @@ void CookieServiceChild::TrackCookieLoad(nsIChannel* aChannel) {
|
||||
if (RequireThirdPartyCheck(loadInfo)) {
|
||||
mThirdPartyUtil->IsThirdPartyChannel(aChannel, uri, &isForeign);
|
||||
}
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(aChannel);
|
||||
if (classifiedChannel) {
|
||||
isTrackingResource = classifiedChannel->IsTrackingResource();
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
if (isForeign && AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
||||
httpChannel, uri, &rejectedReason)) {
|
||||
aChannel, uri, &rejectedReason)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
|
||||
@ -471,14 +473,15 @@ nsresult CookieServiceChild::GetCookieStringInternal(
|
||||
bool isTrackingResource = false;
|
||||
bool firstPartyStorageAccessGranted = false;
|
||||
uint32_t rejectedReason = 0;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(aChannel);
|
||||
if (classifiedChannel) {
|
||||
isTrackingResource = classifiedChannel->IsTrackingResource();
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
if (isForeign && AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
||||
httpChannel, aHostURI, &rejectedReason)) {
|
||||
aChannel, aHostURI, &rejectedReason)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
@ -515,14 +518,15 @@ nsresult CookieServiceChild::SetCookieStringInternal(
|
||||
bool isTrackingResource = false;
|
||||
bool firstPartyStorageAccessGranted = false;
|
||||
uint32_t rejectedReason = 0;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(aChannel);
|
||||
if (classifiedChannel) {
|
||||
isTrackingResource = classifiedChannel->IsTrackingResource();
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
if (isForeign && AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
||||
httpChannel, aHostURI, &rejectedReason)) {
|
||||
aChannel, aHostURI, &rejectedReason)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
|
@ -122,14 +122,15 @@ void CookieServiceParent::TrackCookieLoad(nsIChannel* aChannel) {
|
||||
bool isTrackingResource = false;
|
||||
bool storageAccessGranted = false;
|
||||
uint32_t rejectedReason = 0;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(aChannel);
|
||||
if (classifiedChannel) {
|
||||
isTrackingResource = classifiedChannel->IsTrackingResource();
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
||||
httpChannel, uri, &rejectedReason)) {
|
||||
aChannel, uri, &rejectedReason)) {
|
||||
storageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "nsCookieService.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
@ -2012,15 +2013,16 @@ nsresult nsCookieService::GetCookieStringCommon(nsIURI* aHostURI,
|
||||
bool isTrackingResource = false;
|
||||
bool firstPartyStorageAccessGranted = false;
|
||||
uint32_t rejectedReason = 0;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(aChannel);
|
||||
if (classifiedChannel) {
|
||||
isTrackingResource = classifiedChannel->IsTrackingResource();
|
||||
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
||||
httpChannel, aHostURI, &rejectedReason)) {
|
||||
aChannel, aHostURI, &rejectedReason)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
@ -2134,15 +2136,16 @@ nsresult nsCookieService::SetCookieStringCommon(nsIURI* aHostURI,
|
||||
bool isTrackingResource = false;
|
||||
bool firstPartyStorageAccessGranted = false;
|
||||
uint32_t rejectedReason = 0;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
isTrackingResource = httpChannel->IsTrackingResource();
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(aChannel);
|
||||
if (classifiedChannel) {
|
||||
isTrackingResource = classifiedChannel->IsTrackingResource();
|
||||
|
||||
// Check first-party storage access even for non-tracking resources, since
|
||||
// we will need the result when computing the access rights for the reject
|
||||
// foreign cookie behavior mode.
|
||||
if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
||||
httpChannel, aHostURI, &rejectedReason)) {
|
||||
aChannel, aHostURI, &rejectedReason)) {
|
||||
firstPartyStorageAccessGranted = true;
|
||||
}
|
||||
}
|
||||
|
@ -567,5 +567,37 @@ DocumentChannelChild::Resume() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentChannelChild::IsTrackingResource(bool* aIsTrackingResource) {
|
||||
// TODO
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentChannelChild::IsThirdPartyTrackingResource(bool* aIsTrackingResource) {
|
||||
// TODO
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentChannelChild::GetClassificationFlags(uint32_t* aClassificationFlags) {
|
||||
// TODO
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentChannelChild::GetFirstPartyClassificationFlags(
|
||||
uint32_t* aClassificationFlags) {
|
||||
// TODO
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentChannelChild::GetThirdPartyClassificationFlags(
|
||||
uint32_t* aClassificationFlags) {
|
||||
// TODO
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
@ -234,17 +234,11 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
||||
NS_IMETHOD SetTopLevelContentWindowId(uint64_t aContentWindowId) override;
|
||||
NS_IMETHOD GetTopLevelOuterContentWindowId(uint64_t* aWindowId) override;
|
||||
NS_IMETHOD SetTopLevelOuterContentWindowId(uint64_t aWindowId) override;
|
||||
NS_IMETHOD IsTrackingResource(bool* aIsTrackingResource) override;
|
||||
NS_IMETHOD IsThirdPartyTrackingResource(bool* aIsTrackingResource) override;
|
||||
NS_IMETHOD GetClassificationFlags(uint32_t* aIsClassificationFlags) override;
|
||||
NS_IMETHOD GetFirstPartyClassificationFlags(
|
||||
uint32_t* aIsClassificationFlags) override;
|
||||
NS_IMETHOD GetThirdPartyClassificationFlags(
|
||||
uint32_t* aIsClassificationFlags) override;
|
||||
|
||||
NS_IMETHOD GetFlashPluginState(
|
||||
nsIHttpChannel::FlashPluginState* aState) override;
|
||||
|
||||
using nsIHttpChannel::IsThirdPartyTrackingResource;
|
||||
using nsIClassifiedChannel::IsThirdPartyTrackingResource;
|
||||
|
||||
virtual void SetSource(UniqueProfilerBacktrace aSource) override {
|
||||
mSource = std::move(aSource);
|
||||
|
@ -83,39 +83,12 @@ NullHttpChannel::SetTopLevelOuterContentWindowId(uint64_t aWindowId) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::IsTrackingResource(bool* aIsTrackingResource) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::IsThirdPartyTrackingResource(bool* aIsTrackingResource) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::GetClassificationFlags(uint32_t* aClassificationFlags) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::GetFlashPluginState(
|
||||
nsIHttpChannel::FlashPluginState* aResult) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::GetFirstPartyClassificationFlags(
|
||||
uint32_t* aClassificationFlags) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::GetThirdPartyClassificationFlags(
|
||||
uint32_t* aClassificationFlags) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::GetTransferSize(uint64_t* aTransferSize) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -1335,7 +1335,7 @@ HttpTrafficCategory nsHttpChannel::CreateTrafficCategory() {
|
||||
uint32_t flags = isThirdParty ? mThirdPartyClassificationFlags
|
||||
: mFirstPartyClassificationFlags;
|
||||
|
||||
using CF = nsIHttpChannel::ClassificationFlags;
|
||||
using CF = nsIClassifiedChannel::ClassificationFlags;
|
||||
using TC = HttpTrafficAnalyzer::TrackingClassification;
|
||||
|
||||
if (flags & CF::CLASSIFIED_TRACKING_CONTENT) {
|
||||
|
@ -438,133 +438,6 @@ interface nsIHttpChannel : nsIIdentChannel
|
||||
*/
|
||||
[must_use] attribute uint64_t topLevelContentWindowId;
|
||||
|
||||
/**
|
||||
* Returns the classification flags if the channel has been processed by
|
||||
* URL-Classifier features and is considered first-party.
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long firstPartyClassificationFlags;
|
||||
|
||||
/**
|
||||
* Returns the classification flags if the channel has been processed by
|
||||
* URL-Classifier features and is considered third-party with the top
|
||||
* window URI.
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long thirdPartyClassificationFlags;
|
||||
|
||||
/*
|
||||
* Returns the classification flags if the channel has been processed by
|
||||
* URL-Classifier features. This value is equal to
|
||||
* "firstPartyClassificationFlags || thirdPartyClassificationFlags".
|
||||
*
|
||||
* Note that top-level channels could be classified as well.
|
||||
* In order to identify third-party resources specifically, use
|
||||
* classificationThirdPartyFlags;
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long classificationFlags;
|
||||
|
||||
cenum ClassificationFlags : 32 {
|
||||
/**
|
||||
* The resource is on the fingerprinting list.
|
||||
*/
|
||||
CLASSIFIED_FINGERPRINTING = 0x0001,
|
||||
CLASSIFIED_FINGERPRINTING_CONTENT = 0x0080,
|
||||
|
||||
/**
|
||||
* The resource is on the cryptomining list.
|
||||
*/
|
||||
CLASSIFIED_CRYPTOMINING = 0x0002,
|
||||
CLASSIFIED_CRYPTOMINING_CONTENT = 0x0100,
|
||||
|
||||
/**
|
||||
* The following are about tracking annotation and are available only
|
||||
* if the privacy.trackingprotection.annotate_channels pref.
|
||||
* CLASSIFIED_TRACKING is set if we are not able to identify the
|
||||
* type of classification.
|
||||
*/
|
||||
CLASSIFIED_TRACKING = 0x0004,
|
||||
CLASSIFIED_TRACKING_AD = 0x0008,
|
||||
CLASSIFIED_TRACKING_ANALYTICS = 0x0010,
|
||||
CLASSIFIED_TRACKING_SOCIAL = 0x0020,
|
||||
CLASSIFIED_TRACKING_CONTENT = 0x0040,
|
||||
|
||||
/**
|
||||
* The following are about social tracking.
|
||||
*/
|
||||
CLASSIFIED_SOCIALTRACKING = 0x0200,
|
||||
CLASSIFIED_SOCIALTRACKING_FACEBOOK = 0x0400,
|
||||
CLASSIFIED_SOCIALTRACKING_LINKEDIN = 0x0800,
|
||||
CLASSIFIED_SOCIALTRACKING_TWITTER = 0x1000,
|
||||
|
||||
/**
|
||||
* This is exposed to help to identify tracking classification using the
|
||||
* basic lists.
|
||||
*/
|
||||
CLASSIFIED_ANY_BASIC_TRACKING = CLASSIFIED_TRACKING |
|
||||
CLASSIFIED_TRACKING_AD | CLASSIFIED_TRACKING_ANALYTICS |
|
||||
CLASSIFIED_TRACKING_SOCIAL | CLASSIFIED_FINGERPRINTING,
|
||||
|
||||
/**
|
||||
* This is exposed to help to identify tracking classification using the
|
||||
* strict lists.
|
||||
*/
|
||||
CLASSIFIED_ANY_STRICT_TRACKING = CLASSIFIED_ANY_BASIC_TRACKING |
|
||||
CLASSIFIED_TRACKING_CONTENT | CLASSIFIED_FINGERPRINTING_CONTENT,
|
||||
|
||||
/**
|
||||
* This is exposed to help to identify social tracking classification
|
||||
* flags.
|
||||
*/
|
||||
CLASSIFIED_ANY_SOCIAL_TRACKING = CLASSIFIED_SOCIALTRACKING |
|
||||
CLASSIFIED_SOCIALTRACKING_FACEBOOK |
|
||||
CLASSIFIED_SOCIALTRACKING_LINKEDIN | CLASSIFIED_SOCIALTRACKING_TWITTER,
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the channel has loaded a resource that is classified as
|
||||
* tracker.
|
||||
* This is a helper attribute which returns the same value of
|
||||
* (classificationFlags & CLASSIFIED_ANY_BASIC_TRACKING) or
|
||||
* (classificationFlags & CLASSIFIED_ANY_STRICT_TRACKING)
|
||||
*
|
||||
* Note that top-level channels could be marked as tracking
|
||||
* resource. In order to identify third-party tracking resources
|
||||
* specifically, use isThirdPartyTrackingResource().
|
||||
*/
|
||||
boolean isTrackingResource();
|
||||
|
||||
%{ C++
|
||||
inline bool IsTrackingResource()
|
||||
{
|
||||
bool value = false;
|
||||
if (NS_SUCCEEDED(IsTrackingResource(&value)) && value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Returns the classification flags if the channel has been processed by
|
||||
* URL-Classifier features and is considered third-party with the top
|
||||
* window URI.
|
||||
*
|
||||
* This is a helper attribute which returns the same value of
|
||||
* (thirdPartyClassificationFlags & CLASSIFIED_ANY_BASIC_TRACKING) or
|
||||
* (thirdPartyClassificationFlags & CLASSIFIED_ANY_STRICT_TRACKING)
|
||||
*/
|
||||
boolean isThirdPartyTrackingResource();
|
||||
|
||||
%{ C++
|
||||
inline bool IsThirdPartyTrackingResource()
|
||||
{
|
||||
bool value = false;
|
||||
if (NS_SUCCEEDED(IsThirdPartyTrackingResource(&value)) && value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Returns the allowing status for flash plugin for this channel.
|
||||
*/
|
||||
|
@ -695,42 +695,6 @@ nsViewSourceChannel::SetTopLevelOuterContentWindowId(uint64_t aWindowId) {
|
||||
: mHttpChannel->SetTopLevelOuterContentWindowId(aWindowId);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::IsTrackingResource(bool* aIsTrackingResource) {
|
||||
return !mHttpChannel ? NS_ERROR_NULL_POINTER
|
||||
: mHttpChannel->IsTrackingResource(aIsTrackingResource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::IsThirdPartyTrackingResource(bool* aIsTrackingResource) {
|
||||
return !mHttpChannel
|
||||
? NS_ERROR_NULL_POINTER
|
||||
: mHttpChannel->IsThirdPartyTrackingResource(aIsTrackingResource);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetClassificationFlags(uint32_t* aClassificationFlags) {
|
||||
return !mHttpChannel
|
||||
? NS_ERROR_NULL_POINTER
|
||||
: mHttpChannel->GetClassificationFlags(aClassificationFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetFirstPartyClassificationFlags(
|
||||
uint32_t* aClassificationFlags) {
|
||||
return !mHttpChannel ? NS_ERROR_NULL_POINTER
|
||||
: mHttpChannel->GetFirstPartyClassificationFlags(
|
||||
aClassificationFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetThirdPartyClassificationFlags(
|
||||
uint32_t* aClassificationFlags) {
|
||||
return !mHttpChannel ? NS_ERROR_NULL_POINTER
|
||||
: mHttpChannel->GetThirdPartyClassificationFlags(
|
||||
aClassificationFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetFlashPluginState(
|
||||
nsIHttpChannel::FlashPluginState* aResult) {
|
||||
|
@ -36,7 +36,7 @@ function listener(tracking, priority, throttleable, nextTest) {
|
||||
listener.prototype = {
|
||||
onStartRequest(request) {
|
||||
Assert.equal(
|
||||
request.QueryInterface(Ci.nsIHttpChannel).isTrackingResource(),
|
||||
request.QueryInterface(Ci.nsIClassifiedChannel).isTrackingResource(),
|
||||
this._tracking,
|
||||
"tracking flag"
|
||||
);
|
||||
|
@ -538,30 +538,32 @@ bool UrlClassifierCommon::IsAllowListed(nsIChannel* aChannel) {
|
||||
// static
|
||||
bool UrlClassifierCommon::IsTrackingClassificationFlag(uint32_t aFlag) {
|
||||
if (StaticPrefs::privacy_annotate_channels_strict_list_enabled() &&
|
||||
(aFlag &
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_ANY_STRICT_TRACKING)) {
|
||||
(aFlag & nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_ANY_STRICT_TRACKING)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (StaticPrefs::privacy_socialtracking_block_cookies_enabled() &&
|
||||
(aFlag &
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_ANY_SOCIAL_TRACKING)) {
|
||||
(aFlag & nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_ANY_SOCIAL_TRACKING)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (aFlag &
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_ANY_BASIC_TRACKING);
|
||||
return (
|
||||
aFlag &
|
||||
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_ANY_BASIC_TRACKING);
|
||||
}
|
||||
|
||||
// static
|
||||
bool UrlClassifierCommon::IsCryptominingClassificationFlag(uint32_t aFlag) {
|
||||
if (aFlag & nsIHttpChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING) {
|
||||
if (aFlag &
|
||||
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (StaticPrefs::privacy_annotate_channels_strict_list_enabled() &&
|
||||
(aFlag &
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING_CONTENT)) {
|
||||
(aFlag & nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_CRYPTOMINING_CONTENT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "mozilla/AntiTrackingCommon.h"
|
||||
#include "mozilla/net/UrlClassifierCommon.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
@ -133,13 +134,13 @@ UrlClassifierFeatureCryptominingAnnotation::ProcessChannel(
|
||||
static std::vector<UrlClassifierCommon::ClassificationData>
|
||||
sClassificationData = {
|
||||
{NS_LITERAL_CSTRING("content-cryptomining-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::
|
||||
nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_CRYPTOMINING_CONTENT},
|
||||
};
|
||||
|
||||
uint32_t flags = UrlClassifierCommon::TablesToClassificationFlags(
|
||||
aList, sClassificationData,
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING);
|
||||
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING);
|
||||
|
||||
UrlClassifierCommon::SetTrackingInfo(aChannel, aList, aHashes);
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "mozilla/AntiTrackingCommon.h"
|
||||
#include "mozilla/net/UrlClassifierCommon.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
@ -135,13 +136,13 @@ UrlClassifierFeatureFingerprintingAnnotation::ProcessChannel(
|
||||
static std::vector<UrlClassifierCommon::ClassificationData>
|
||||
sClassificationData = {
|
||||
{NS_LITERAL_CSTRING("content-fingerprinting-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::
|
||||
nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_FINGERPRINTING_CONTENT},
|
||||
};
|
||||
|
||||
uint32_t flags = UrlClassifierCommon::TablesToClassificationFlags(
|
||||
aList, sClassificationData,
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_FINGERPRINTING);
|
||||
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_FINGERPRINTING);
|
||||
|
||||
UrlClassifierCommon::SetTrackingInfo(aChannel, aList, aHashes);
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "mozilla/AntiTrackingCommon.h"
|
||||
#include "mozilla/net/UrlClassifierCommon.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
@ -135,19 +136,19 @@ UrlClassifierFeatureSocialTrackingAnnotation::ProcessChannel(
|
||||
static std::vector<UrlClassifierCommon::ClassificationData>
|
||||
sClassificationData = {
|
||||
{NS_LITERAL_CSTRING("social-tracking-protection-facebook-"),
|
||||
nsIHttpChannel::ClassificationFlags::
|
||||
nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_SOCIALTRACKING_FACEBOOK},
|
||||
{NS_LITERAL_CSTRING("social-tracking-protection-linkedin-"),
|
||||
nsIHttpChannel::ClassificationFlags::
|
||||
nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_SOCIALTRACKING_LINKEDIN},
|
||||
{NS_LITERAL_CSTRING("social-tracking-protection-twitter-"),
|
||||
nsIHttpChannel::ClassificationFlags::
|
||||
nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_SOCIALTRACKING_TWITTER},
|
||||
};
|
||||
|
||||
uint32_t flags = UrlClassifierCommon::TablesToClassificationFlags(
|
||||
aList, sClassificationData,
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_SOCIALTRACKING);
|
||||
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_SOCIALTRACKING);
|
||||
|
||||
UrlClassifierCommon::AnnotateChannel(
|
||||
aChannel, flags,
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "mozilla/StaticPrefs_privacy.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/net/UrlClassifierCommon.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -127,18 +128,21 @@ UrlClassifierFeatureTrackingAnnotation::ProcessChannel(
|
||||
static std::vector<UrlClassifierCommon::ClassificationData>
|
||||
sClassificationData = {
|
||||
{NS_LITERAL_CSTRING("ads-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_AD},
|
||||
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_TRACKING_AD},
|
||||
{NS_LITERAL_CSTRING("analytics-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_ANALYTICS},
|
||||
nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_TRACKING_ANALYTICS},
|
||||
{NS_LITERAL_CSTRING("social-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_SOCIAL},
|
||||
nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_TRACKING_SOCIAL},
|
||||
{NS_LITERAL_CSTRING("content-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_CONTENT},
|
||||
nsIClassifiedChannel::ClassificationFlags::
|
||||
CLASSIFIED_TRACKING_CONTENT},
|
||||
};
|
||||
|
||||
uint32_t flags = UrlClassifierCommon::TablesToClassificationFlags(
|
||||
aList, sClassificationData,
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING);
|
||||
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_TRACKING);
|
||||
|
||||
UrlClassifierCommon::SetTrackingInfo(aChannel, aList, aHashes);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mozIThirdPartyUtil.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsICookiePermission.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsIDocShell.h"
|
||||
@ -892,22 +893,23 @@ void NotifyBlockingDecisionInternal(
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED, aReportingChannel, false,
|
||||
aURI, aTrackingChannel);
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aTrackingChannel);
|
||||
if (!httpChannel) {
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(aTrackingChannel);
|
||||
if (!classifiedChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t classificationFlags =
|
||||
httpChannel->GetThirdPartyClassificationFlags();
|
||||
classifiedChannel->GetThirdPartyClassificationFlags();
|
||||
if (classificationFlags &
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING) {
|
||||
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_TRACKING) {
|
||||
aWindow->NotifyContentBlockingEvent(
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER, aReportingChannel,
|
||||
false, aURI, aTrackingChannel);
|
||||
}
|
||||
|
||||
if (classificationFlags &
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_SOCIALTRACKING) {
|
||||
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_SOCIALTRACKING) {
|
||||
aWindow->NotifyContentBlockingEvent(
|
||||
nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER,
|
||||
aReportingChannel, false, aURI, aTrackingChannel);
|
||||
@ -1683,15 +1685,19 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER;
|
||||
|
||||
// Not a tracker.
|
||||
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
||||
do_QueryInterface(aChannel);
|
||||
if (behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER) {
|
||||
if (httpChannel && !httpChannel->IsThirdPartyTrackingResource()) {
|
||||
if (classifiedChannel &&
|
||||
!classifiedChannel->IsThirdPartyTrackingResource()) {
|
||||
LOG(("Our channel isn't a third-party tracking channel"));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(behavior ==
|
||||
nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN);
|
||||
if (httpChannel && httpChannel->IsThirdPartyTrackingResource()) {
|
||||
if (classifiedChannel &&
|
||||
classifiedChannel->IsThirdPartyTrackingResource()) {
|
||||
// fall through
|
||||
} else if (nsContentUtils::IsThirdPartyWindowOrChannel(nullptr, aChannel,
|
||||
aURI)) {
|
||||
|
@ -1067,6 +1067,6 @@ this.AntiTracking = {
|
||||
channel.asyncOpen(listener);
|
||||
});
|
||||
|
||||
return channel.QueryInterface(Ci.nsIHttpChannel).isTrackingResource();
|
||||
return channel.QueryInterface(Ci.nsIClassifiedChannel).isTrackingResource();
|
||||
},
|
||||
};
|
||||
|
@ -3,7 +3,7 @@
|
||||
const { Schemas } = ChromeUtils.import("resource://gre/modules/Schemas.jsm");
|
||||
|
||||
/**
|
||||
* If this test fails, likely nsIHttpChannel has added or changed a
|
||||
* If this test fails, likely nsIClassifiedChannel has added or changed a
|
||||
* CLASSIFIED_* flag. Those changes must be in sync with
|
||||
* ChannelWrapper.webidl/cpp and the web_request.json schema file.
|
||||
*/
|
||||
@ -20,7 +20,7 @@ add_task(async function test_webrequest_url_classification_enum() {
|
||||
|
||||
let prefix = /^(?:CLASSIFIED_)/;
|
||||
let entries = 0;
|
||||
for (let c of Object.keys(Ci.nsIHttpChannel).filter(name =>
|
||||
for (let c of Object.keys(Ci.nsIClassifiedChannel).filter(name =>
|
||||
prefix.test(name)
|
||||
)) {
|
||||
let entry = c.replace(prefix, "").toLowerCase();
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/BrowserHost.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsIClassifiedChannel.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
@ -48,7 +49,7 @@ namespace extensions {
|
||||
#define CHANNELWRAPPER_PROP_KEY \
|
||||
NS_LITERAL_STRING("ChannelWrapper::CachedInstance")
|
||||
|
||||
using CF = nsIHttpChannel::ClassificationFlags;
|
||||
using CF = nsIClassifiedChannel::ClassificationFlags;
|
||||
using MUC = MozUrlClassificationFlags;
|
||||
|
||||
struct ClassificationStruct {
|
||||
@ -906,14 +907,20 @@ void FillClassification(
|
||||
void ChannelWrapper::GetUrlClassification(
|
||||
dom::Nullable<dom::MozUrlClassification>& aRetVal, ErrorResult& aRv) const {
|
||||
MozUrlClassification classification;
|
||||
if (nsCOMPtr<nsIHttpChannel> chan = MaybeHttpChannel()) {
|
||||
nsCOMPtr<nsIHttpChannel> chan = MaybeHttpChannel();
|
||||
nsCOMPtr<nsIClassifiedChannel> classified = do_QueryInterface(chan);
|
||||
MOZ_DIAGNOSTIC_ASSERT(
|
||||
classified,
|
||||
"Must be an object inheriting from both nsIHttpChannel and "
|
||||
"nsIClassifiedChannel");
|
||||
if (classified) {
|
||||
uint32_t classificationFlags;
|
||||
chan->GetFirstPartyClassificationFlags(&classificationFlags);
|
||||
classified->GetFirstPartyClassificationFlags(&classificationFlags);
|
||||
FillClassification(classification.mFirstParty, classificationFlags, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
chan->GetThirdPartyClassificationFlags(&classificationFlags);
|
||||
classified->GetThirdPartyClassificationFlags(&classificationFlags);
|
||||
FillClassification(classification.mThirdParty, classificationFlags, aRv);
|
||||
}
|
||||
aRetVal.SetValue(std::move(classification));
|
||||
|
@ -248,8 +248,10 @@ function runTests(flag, prefs, trackingResource) {
|
||||
|
||||
function onExamResp(subject, topic, data) {
|
||||
let channel = subject.QueryInterface(Ci.nsIHttpChannel);
|
||||
let classifiedChannel = subject.QueryInterface(Ci.nsIClassifiedChannel);
|
||||
if (
|
||||
!channel ||
|
||||
!classifiedChannel ||
|
||||
!channel.URI.spec.startsWith(
|
||||
"http://example.com/tests/toolkit/components/url-classifier/tests/mochitest/raptor.jpg"
|
||||
)
|
||||
@ -259,8 +261,8 @@ function runTests(flag, prefs, trackingResource) {
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
sendAsyncMessage("last-channel-flags", {
|
||||
classificationFlags: channel.classificationFlags,
|
||||
isTrackingResource: channel.isTrackingResource(),
|
||||
classificationFlags: classifiedChannel.classificationFlags,
|
||||
isTrackingResource: classifiedChannel.isTrackingResource(),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
runTests(SpecialPowers.Ci.nsIHttpChannel.CLASSIFIED_TRACKING,
|
||||
runTests(SpecialPowers.Ci.nsIClassifiedChannel.CLASSIFIED_TRACKING,
|
||||
[
|
||||
["privacy.trackingprotection.enabled", true],
|
||||
["privacy.trackingprotection.annotate_channels", true],
|
||||
|
@ -10,7 +10,7 @@
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
runTests(SpecialPowers.Ci.nsIHttpChannel.CLASSIFIED_CRYPTOMINING,
|
||||
runTests(SpecialPowers.Ci.nsIClassifiedChannel.CLASSIFIED_CRYPTOMINING,
|
||||
[
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.annotate_channels", false],
|
||||
|
@ -10,7 +10,7 @@
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
runTests(SpecialPowers.Ci.nsIHttpChannel.CLASSIFIED_FINGERPRINTING,
|
||||
runTests(SpecialPowers.Ci.nsIClassifiedChannel.CLASSIFIED_FINGERPRINTING,
|
||||
[
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
["privacy.trackingprotection.annotate_channels", false],
|
||||
|
@ -10,7 +10,7 @@
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
runTests(SpecialPowers.Ci.nsIHttpChannel.CLASSIFIED_SOCIALTRACKING,
|
||||
runTests(SpecialPowers.Ci.nsIClassifiedChannel.CLASSIFIED_SOCIALTRACKING,
|
||||
[
|
||||
["privacy.socialtracking.block_cookies.enabled", false],
|
||||
["privacy.trackingprotection.enabled", false],
|
||||
|
@ -141,7 +141,9 @@ add_task(async function testShouldClassify() {
|
||||
channel.asyncOpen({
|
||||
onStartRequest: (request, context) => {
|
||||
Assert.equal(
|
||||
request.QueryInterface(Ci.nsIHttpChannel).isTrackingResource(),
|
||||
request
|
||||
.QueryInterface(Ci.nsIClassifiedChannel)
|
||||
.isTrackingResource(),
|
||||
getExpectedResult(params)
|
||||
);
|
||||
request.cancel(Cr.NS_ERROR_ABORT);
|
||||
|
Loading…
Reference in New Issue
Block a user