зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1539637 - Make cryptomining and fingerprinting annotations use the "strict" list always, r=dimi
Differential Revision: https://phabricator.services.mozilla.com/D25266 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
105ca7b09f
Коммит
10b25d6759
|
@ -92,7 +92,7 @@ class IPCFeature final : public nsIUrlClassifierFeature {
|
|||
}
|
||||
|
||||
NS_IMETHOD
|
||||
ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
ProcessChannel(nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override {
|
||||
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
||||
*aShouldContinue = true;
|
||||
|
|
|
@ -523,13 +523,15 @@ interface nsIHttpChannel : nsIChannel
|
|||
* The resource is on the fingerprinting list. This is only available if
|
||||
* the privacy.trackingprotection.fingerprinting_annotate_enabled pref.
|
||||
*/
|
||||
CLASSIFIED_FINGERPRINTING = 0x01,
|
||||
CLASSIFIED_FINGERPRINTING = 0x0001,
|
||||
CLASSIFIED_FINGERPRINTING_CONTENT = 0x0080,
|
||||
|
||||
/**
|
||||
* The resource is on the cryptomining list. This is only available if
|
||||
* the privacy.trackingprotection.cryptomining_annotate_enabled pref is set.
|
||||
*/
|
||||
CLASSIFIED_CRYPTOMINING = 0x02,
|
||||
CLASSIFIED_CRYPTOMINING = 0x0002,
|
||||
CLASSIFIED_CRYPTOMINING_CONTENT = 0x0100,
|
||||
|
||||
/**
|
||||
* The following are about tracking annotation and are available only
|
||||
|
@ -537,11 +539,11 @@ interface nsIHttpChannel : nsIChannel
|
|||
* CLASSIFIED_TRACKING is set if we are not able to identify the
|
||||
* type of classification.
|
||||
*/
|
||||
CLASSIFIED_TRACKING = 0x04,
|
||||
CLASSIFIED_TRACKING_AD = 0x08,
|
||||
CLASSIFIED_TRACKING_ANALYTICS = 0x10,
|
||||
CLASSIFIED_TRACKING_SOCIAL = 0x20,
|
||||
CLASSIFIED_TRACKING_CONTENT = 0x40,
|
||||
CLASSIFIED_TRACKING = 0x0004,
|
||||
CLASSIFIED_TRACKING_AD = 0x0008,
|
||||
CLASSIFIED_TRACKING_ANALYTICS = 0x0010,
|
||||
CLASSIFIED_TRACKING_SOCIAL = 0x0020,
|
||||
CLASSIFIED_TRACKING_CONTENT = 0x0040,
|
||||
|
||||
/**
|
||||
* This is exposed to help to identify tracking classification using the
|
||||
|
@ -556,7 +558,7 @@ interface nsIHttpChannel : nsIChannel
|
|||
* strict lists.
|
||||
*/
|
||||
CLASSIFIED_ANY_STRICT_TRACKING = CLASSIFIED_ANY_BASIC_TRACKING |
|
||||
CLASSIFIED_TRACKING_CONTENT,
|
||||
CLASSIFIED_TRACKING_CONTENT | CLASSIFIED_FINGERPRINTING_CONTENT,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -424,23 +424,17 @@ bool FeatureData::MaybeCompleteClassification(nsIChannel* aChannel) {
|
|||
return true;
|
||||
}
|
||||
|
||||
nsAutoCString list;
|
||||
list.Assign(mHostInPrefTables[nsIUrlClassifierFeature::blacklist]);
|
||||
nsTArray<nsCString> list;
|
||||
list.AppendElement(mHostInPrefTables[nsIUrlClassifierFeature::blacklist]);
|
||||
|
||||
for (TableData* tableData : mBlacklistTables) {
|
||||
if (tableData->MatchState() == TableData::eMatch) {
|
||||
if (!list.IsEmpty()) {
|
||||
list.AppendLiteral(",");
|
||||
}
|
||||
|
||||
list.Append(tableData->Table());
|
||||
list.AppendElement(tableData->Table());
|
||||
}
|
||||
}
|
||||
|
||||
UC_LOG(
|
||||
("FeatureData::MaybeCompleteClassification[%p] - process channel %p with "
|
||||
"list %s",
|
||||
this, aChannel, list.get()));
|
||||
UC_LOG(("FeatureData::MaybeCompleteClassification[%p] - process channel %p",
|
||||
this, aChannel));
|
||||
|
||||
bool shouldContinue = false;
|
||||
rv = mFeature->ProcessChannel(aChannel, list, &shouldContinue);
|
||||
|
|
|
@ -387,8 +387,7 @@ void UrlClassifierCommon::AnnotateChannel(
|
|||
// prefs) and cryptomining (which is not considered as tracking).
|
||||
bool validClassificationFlags =
|
||||
IsTrackingClassificationFlag(aClassificationFlags) ||
|
||||
(aClassificationFlags &
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING);
|
||||
IsCryptominingClassificationFlag(aClassificationFlags);
|
||||
|
||||
if (validClassificationFlags &&
|
||||
(isThirdPartyWithTopLevelWinURI || IsAllowListed(aChannel, aPurpose))) {
|
||||
|
@ -474,5 +473,58 @@ bool UrlClassifierCommon::IsTrackingClassificationFlag(uint32_t aFlag) {
|
|||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_ANY_BASIC_TRACKING);
|
||||
}
|
||||
|
||||
// static
|
||||
bool UrlClassifierCommon::IsCryptominingClassificationFlag(uint32_t aFlag) {
|
||||
if (aFlag & nsIHttpChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (StaticPrefs::privacy_annotate_channels_strict_list_enabled() &&
|
||||
(aFlag &
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING_CONTENT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void UrlClassifierCommon::TablesToString(const nsTArray<nsCString>& aList,
|
||||
nsACString& aString) {
|
||||
aString.Truncate();
|
||||
|
||||
for (const nsCString& table : aList) {
|
||||
if (!aString.IsEmpty()) {
|
||||
aString.Append(",");
|
||||
}
|
||||
aString.Append(table);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t UrlClassifierCommon::TablesToClassificationFlags(
|
||||
const nsTArray<nsCString>& aList,
|
||||
const std::vector<ClassificationData>& aData, uint32_t aDefaultFlag) {
|
||||
uint32_t flags = 0;
|
||||
for (const nsCString& table : aList) {
|
||||
flags |= TableToClassificationFlag(table, aData);
|
||||
}
|
||||
|
||||
if (flags == 0) {
|
||||
flags |= aDefaultFlag;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
uint32_t UrlClassifierCommon::TableToClassificationFlag(
|
||||
const nsACString& aTable, const std::vector<ClassificationData>& aData) {
|
||||
for (const ClassificationData& data : aData) {
|
||||
if (StringBeginsWith(aTable, data.mPrefix)) {
|
||||
return data.mFlag;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -53,11 +53,32 @@ class UrlClassifierCommon final {
|
|||
|
||||
static bool IsTrackingClassificationFlag(uint32_t aFlag);
|
||||
|
||||
static bool IsCryptominingClassificationFlag(uint32_t aFlag);
|
||||
|
||||
// Join the table names in 1 single string.
|
||||
static void TablesToString(const nsTArray<nsCString>& aList,
|
||||
nsACString& aString);
|
||||
|
||||
struct ClassificationData {
|
||||
nsCString mPrefix;
|
||||
uint32_t mFlag;
|
||||
};
|
||||
|
||||
// Checks if the entries in aList are part of the ClassificationData vector
|
||||
// and it returns the corresponding flags. If none of them is found, the
|
||||
// default flag is returned.
|
||||
static uint32_t TablesToClassificationFlags(
|
||||
const nsTArray<nsCString>& aList,
|
||||
const std::vector<ClassificationData>& aData, uint32_t aDefaultFlag);
|
||||
|
||||
private:
|
||||
// aBlockedReason must be one of the nsIWebProgressListener state.
|
||||
static void NotifyChannelBlocked(nsIChannel* aChannel,
|
||||
nsIURI* aURIBeingLoaded,
|
||||
unsigned aBlockedReason);
|
||||
|
||||
static uint32_t TableToClassificationFlag(
|
||||
const nsACString& aTable, const std::vector<ClassificationData>& aData);
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -120,7 +120,8 @@ UrlClassifierFeatureCryptominingAnnotation::GetIfNameMatches(
|
|||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureCryptominingAnnotation::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsACString& aList, bool* aShouldContinue) {
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
||||
|
||||
|
@ -132,9 +133,19 @@ UrlClassifierFeatureCryptominingAnnotation::ProcessChannel(
|
|||
"channel[%p]",
|
||||
aChannel));
|
||||
|
||||
static std::vector<UrlClassifierCommon::ClassificationData>
|
||||
sClassificationData = {
|
||||
{NS_LITERAL_CSTRING("content-cryptomining-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::
|
||||
CLASSIFIED_CRYPTOMINING_CONTENT},
|
||||
};
|
||||
|
||||
uint32_t flags = UrlClassifierCommon::TablesToClassificationFlags(
|
||||
aList, sClassificationData,
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING);
|
||||
|
||||
UrlClassifierCommon::AnnotateChannel(
|
||||
aChannel, AntiTrackingCommon::eCryptomining,
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_CRYPTOMINING,
|
||||
aChannel, AntiTrackingCommon::eCryptomining, flags,
|
||||
nsIWebProgressListener::STATE_LOADED_CRYPTOMINING_CONTENT);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ class UrlClassifierFeatureCryptominingAnnotation final
|
|||
static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
|
||||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel,
|
||||
const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
|
|
|
@ -139,7 +139,8 @@ UrlClassifierFeatureCryptominingProtection::GetIfNameMatches(
|
|||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureCryptominingProtection::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsACString& aList, bool* aShouldContinue) {
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
||||
|
||||
|
@ -153,8 +154,11 @@ UrlClassifierFeatureCryptominingProtection::ProcessChannel(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoCString list;
|
||||
UrlClassifierCommon::TablesToString(aList, list);
|
||||
|
||||
UrlClassifierCommon::SetBlockedContent(aChannel, NS_ERROR_CRYPTOMINING_URI,
|
||||
aList, EmptyCString(), EmptyCString());
|
||||
list, EmptyCString(), EmptyCString());
|
||||
|
||||
UC_LOG(
|
||||
("UrlClassifierFeatureCryptominingProtection::ProcessChannel, "
|
||||
|
|
|
@ -27,7 +27,8 @@ class UrlClassifierFeatureCryptominingProtection final
|
|||
static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
|
||||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel,
|
||||
const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
|
|
|
@ -81,9 +81,9 @@ UrlClassifierFeatureCustomTables::GetSkipHostList(nsACString& aList) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureCustomTables::ProcessChannel(nsIChannel* aChannel,
|
||||
const nsACString& aList,
|
||||
bool* aShouldContinue) {
|
||||
UrlClassifierFeatureCustomTables::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
||||
|
||||
|
|
|
@ -122,7 +122,8 @@ UrlClassifierFeatureFingerprintingAnnotation::GetIfNameMatches(
|
|||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureFingerprintingAnnotation::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsACString& aList, bool* aShouldContinue) {
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
||||
|
||||
|
@ -134,10 +135,21 @@ UrlClassifierFeatureFingerprintingAnnotation::ProcessChannel(
|
|||
"annotating channel[%p]",
|
||||
aChannel));
|
||||
|
||||
static std::vector<UrlClassifierCommon::ClassificationData>
|
||||
sClassificationData = {
|
||||
{NS_LITERAL_CSTRING("content-fingerprinting-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::
|
||||
CLASSIFIED_FINGERPRINTING_CONTENT},
|
||||
};
|
||||
|
||||
uint32_t flags = UrlClassifierCommon::TablesToClassificationFlags(
|
||||
aList, sClassificationData,
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_FINGERPRINTING);
|
||||
|
||||
UrlClassifierCommon::AnnotateChannel(
|
||||
aChannel, AntiTrackingCommon::eFingerprinting,
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_FINGERPRINTING,
|
||||
aChannel, AntiTrackingCommon::eFingerprinting, flags,
|
||||
nsIWebProgressListener::STATE_LOADED_FINGERPRINTING_CONTENT);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,8 @@ class UrlClassifierFeatureFingerprintingAnnotation final
|
|||
static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
|
||||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel,
|
||||
const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
|
|
|
@ -143,7 +143,8 @@ UrlClassifierFeatureFingerprintingProtection::GetIfNameMatches(
|
|||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureFingerprintingProtection::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsACString& aList, bool* aShouldContinue) {
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
||||
|
||||
|
@ -157,8 +158,11 @@ UrlClassifierFeatureFingerprintingProtection::ProcessChannel(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoCString list;
|
||||
UrlClassifierCommon::TablesToString(aList, list);
|
||||
|
||||
UrlClassifierCommon::SetBlockedContent(aChannel, NS_ERROR_FINGERPRINTING_URI,
|
||||
aList, EmptyCString(), EmptyCString());
|
||||
list, EmptyCString(), EmptyCString());
|
||||
|
||||
UC_LOG(
|
||||
("UrlClassifierFeatureFingerprintingProtection::ProcessChannel, "
|
||||
|
|
|
@ -27,7 +27,8 @@ class UrlClassifierFeatureFingerprintingProtection final
|
|||
static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
|
||||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel,
|
||||
const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
|
|
|
@ -147,7 +147,7 @@ UrlClassifierFeatureFlash::GetIfNameMatches(const nsACString& aName) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureFlash::ProcessChannel(nsIChannel* aChannel,
|
||||
const nsACString& aList,
|
||||
const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
||||
|
|
|
@ -28,7 +28,7 @@ class UrlClassifierFeatureFlash final : public UrlClassifierFeatureBase {
|
|||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD
|
||||
ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
ProcessChannel(nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
|
|
|
@ -76,9 +76,9 @@ UrlClassifierFeatureLoginReputation::GetIfNameMatches(const nsACString& aName) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureLoginReputation::ProcessChannel(nsIChannel* aChannel,
|
||||
const nsACString& aList,
|
||||
bool* aShouldContinue) {
|
||||
UrlClassifierFeatureLoginReputation::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
MOZ_CRASH(
|
||||
"UrlClassifierFeatureLoginReputation::ProcessChannel should never be "
|
||||
"called");
|
||||
|
|
|
@ -26,7 +26,8 @@ class UrlClassifierFeatureLoginReputation final
|
|||
static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
|
||||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel,
|
||||
const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
|
|
|
@ -109,9 +109,9 @@ UrlClassifierFeaturePhishingProtection::GetIfNameMatches(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeaturePhishingProtection::ProcessChannel(nsIChannel* aChannel,
|
||||
const nsACString& aList,
|
||||
bool* aShouldContinue) {
|
||||
UrlClassifierFeaturePhishingProtection::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class UrlClassifierFeaturePhishingProtection final
|
|||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD
|
||||
ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
ProcessChannel(nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
|
|
|
@ -115,50 +115,34 @@ UrlClassifierFeatureTrackingAnnotation::GetIfNameMatches(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureTrackingAnnotation::ProcessChannel(nsIChannel* aChannel,
|
||||
const nsACString& aList,
|
||||
bool* aShouldContinue) {
|
||||
UrlClassifierFeatureTrackingAnnotation::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
||||
|
||||
// This is not a blocking feature.
|
||||
*aShouldContinue = true;
|
||||
|
||||
nsTArray<nsCString> list;
|
||||
Classifier::SplitTables(aList, list);
|
||||
static std::vector<UrlClassifierCommon::ClassificationData>
|
||||
sClassificationData = {
|
||||
{NS_LITERAL_CSTRING("ads-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_AD},
|
||||
{NS_LITERAL_CSTRING("analytics-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_ANALYTICS},
|
||||
{NS_LITERAL_CSTRING("social-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_SOCIAL},
|
||||
{NS_LITERAL_CSTRING("content-track-"),
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_CONTENT},
|
||||
};
|
||||
|
||||
uint32_t loadingState = nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT;
|
||||
|
||||
uint32_t flags = 0;
|
||||
for (nsCString& table : list) {
|
||||
if (StringBeginsWith(table, NS_LITERAL_CSTRING("ads-track-"))) {
|
||||
flags |= nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_AD;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StringBeginsWith(table, NS_LITERAL_CSTRING("analytics-track-"))) {
|
||||
flags |=
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_ANALYTICS;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StringBeginsWith(table, NS_LITERAL_CSTRING("social-track-"))) {
|
||||
flags |= nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_SOCIAL;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StringBeginsWith(table, NS_LITERAL_CSTRING("content-track-"))) {
|
||||
flags |= nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING_CONTENT;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags == 0) {
|
||||
flags |= nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING;
|
||||
}
|
||||
uint32_t flags = UrlClassifierCommon::TablesToClassificationFlags(
|
||||
aList, sClassificationData,
|
||||
nsIHttpChannel::ClassificationFlags::CLASSIFIED_TRACKING);
|
||||
|
||||
UrlClassifierCommon::AnnotateChannel(
|
||||
aChannel, AntiTrackingCommon::eTrackingAnnotations, flags, loadingState);
|
||||
aChannel, AntiTrackingCommon::eTrackingAnnotations, flags,
|
||||
nsIWebProgressListener::STATE_LOADED_TRACKING_CONTENT);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ class UrlClassifierFeatureTrackingAnnotation final
|
|||
static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
|
||||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel,
|
||||
const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
|
|
|
@ -133,9 +133,9 @@ UrlClassifierFeatureTrackingProtection::GetIfNameMatches(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureTrackingProtection::ProcessChannel(nsIChannel* aChannel,
|
||||
const nsACString& aList,
|
||||
bool* aShouldContinue) {
|
||||
UrlClassifierFeatureTrackingProtection::ProcessChannel(
|
||||
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) {
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
||||
|
||||
|
@ -145,20 +145,25 @@ UrlClassifierFeatureTrackingProtection::ProcessChannel(nsIChannel* aChannel,
|
|||
// This is a blocking feature.
|
||||
*aShouldContinue = isAllowListed;
|
||||
|
||||
if (!isAllowListed) {
|
||||
UrlClassifierCommon::SetBlockedContent(
|
||||
aChannel, NS_ERROR_TRACKING_URI, aList, EmptyCString(), EmptyCString());
|
||||
if (isAllowListed) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
UC_LOG(
|
||||
("UrlClassifierFeatureTrackingProtection::ProcessChannel, cancelling "
|
||||
"channel[%p]",
|
||||
aChannel));
|
||||
nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
Unused << httpChannel->CancelByChannelClassifier(NS_ERROR_TRACKING_URI);
|
||||
} else {
|
||||
Unused << aChannel->Cancel(NS_ERROR_TRACKING_URI);
|
||||
}
|
||||
nsAutoCString list;
|
||||
UrlClassifierCommon::TablesToString(aList, list);
|
||||
|
||||
UrlClassifierCommon::SetBlockedContent(aChannel, NS_ERROR_TRACKING_URI, list,
|
||||
EmptyCString(), EmptyCString());
|
||||
|
||||
UC_LOG(
|
||||
("UrlClassifierFeatureTrackingProtection::ProcessChannel, cancelling "
|
||||
"channel[%p]",
|
||||
aChannel));
|
||||
nsCOMPtr<nsIHttpChannelInternal> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel) {
|
||||
Unused << httpChannel->CancelByChannelClassifier(NS_ERROR_TRACKING_URI);
|
||||
} else {
|
||||
Unused << aChannel->Cancel(NS_ERROR_TRACKING_URI);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -27,7 +27,8 @@ class UrlClassifierFeatureTrackingProtection final
|
|||
static already_AddRefed<nsIUrlClassifierFeature> GetIfNameMatches(
|
||||
const nsACString& aName);
|
||||
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel,
|
||||
const nsTArray<nsCString>& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
NS_IMETHOD GetURIByListType(nsIChannel* aChannel,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "nsTArrayForwardDeclare.h"
|
||||
%}
|
||||
[ref] native StringArrayRef(nsTArray<nsCString>);
|
||||
[ref] native ConstStringArrayRef(const nsTArray<nsCString>);
|
||||
|
||||
interface nsIChannel;
|
||||
interface nsIURI;
|
||||
|
@ -62,7 +63,8 @@ interface nsIUrlClassifierFeature : nsISupports
|
|||
* tracking-protection cancel the channel, and after that we should stop
|
||||
* processing other features.
|
||||
*/
|
||||
[noscript] boolean processChannel(in nsIChannel aChannel, in ACString aList);
|
||||
[noscript] boolean processChannel(in nsIChannel aChannel,
|
||||
in ConstStringArrayRef aList);
|
||||
|
||||
/**
|
||||
* Features can work with different URLs from a channel (channel url, or
|
||||
|
|
Загрузка…
Ссылка в новой задаче