Bug 1950985 - Add tracking protection skip for channels annotated as a consent manager. r=timhuang

Differential Revision: https://phabricator.services.mozilla.com/D241468
This commit is contained in:
William Wen
2025-03-25 14:58:20 +00:00
parent a51e62a348
commit e7cdbaba87
8 changed files with 90 additions and 0 deletions

View File

@@ -15551,6 +15551,18 @@
value: true
mirror: always
# Skip blocking for consentmanager resources in all modes.
- name: privacy.trackingprotection.consentmanager.skip.enabled
type: RelaxedAtomicBool
value: false
mirror: always
# Skip blocking for consentmanager resources in Private Browsing mode.
- name: privacy.trackingprotection.consentmanager.skip.pbmode.enabled
type: RelaxedAtomicBool
value: true
mirror: always
# Whether to spoof user locale to English (used as part of Resist
# Fingerprinting).
# 0 - will prompt

View File

@@ -693,5 +693,36 @@ bool UrlClassifierCommon::IsPassiveContent(nsIChannel* aChannel) {
!StaticPrefs::security_mixed_content_block_object_subrequest());
}
/* static */
bool UrlClassifierCommon::ShouldProcessWithProtectionFeature(
nsIChannel* aChannel) {
MOZ_ASSERT(aChannel);
bool shouldProcess = true;
if (!(StaticPrefs::privacy_trackingprotection_consentmanager_skip_enabled() ||
(StaticPrefs::
privacy_trackingprotection_consentmanager_skip_pbmode_enabled() &&
NS_UsePrivateBrowsing(aChannel)))) {
return shouldProcess;
}
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
do_QueryInterface(aChannel);
if (classifiedChannel) {
shouldProcess =
!(classifiedChannel->GetClassificationFlags() &
nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_CONSENTMANAGER);
UC_LOG(
("UrlClassifierCommon::ShouldProcessWithProtectionFeature - "
"shouldProcess=%d for channel %p",
shouldProcess, aChannel));
}
return shouldProcess;
}
} // namespace net
} // namespace mozilla

View File

@@ -92,6 +92,8 @@ class UrlClassifierCommon final {
uint32_t aClassificationFlags,
bool aIsThirdParty);
static bool ShouldProcessWithProtectionFeature(nsIChannel* aChannel);
private:
static uint32_t TableToClassificationFlag(
const nsACString& aTable, const std::vector<ClassificationData>& aData);

View File

@@ -144,6 +144,15 @@ UrlClassifierFeatureCryptominingProtection::ProcessChannel(
return NS_OK;
}
bool ShouldProcessByProtectionFeature =
UrlClassifierCommon::ShouldProcessWithProtectionFeature(aChannel);
*aShouldContinue = !ShouldProcessByProtectionFeature;
if (!ShouldProcessByProtectionFeature) {
return NS_OK;
}
nsAutoCString list;
UrlClassifierCommon::TablesToString(aList, list);

View File

@@ -153,6 +153,15 @@ UrlClassifierFeatureEmailTrackingProtection::ProcessChannel(
return NS_OK;
}
bool ShouldProcessByProtectionFeature =
UrlClassifierCommon::ShouldProcessWithProtectionFeature(aChannel);
*aShouldContinue = !ShouldProcessByProtectionFeature;
if (!ShouldProcessByProtectionFeature) {
return NS_OK;
}
nsAutoCString list;
UrlClassifierCommon::TablesToString(aList, list);

View File

@@ -152,6 +152,15 @@ UrlClassifierFeatureFingerprintingProtection::ProcessChannel(
return NS_OK;
}
bool ShouldProcessByProtectionFeature =
UrlClassifierCommon::ShouldProcessWithProtectionFeature(aChannel);
*aShouldContinue = !ShouldProcessByProtectionFeature;
if (!ShouldProcessByProtectionFeature) {
return NS_OK;
}
nsAutoCString list;
UrlClassifierCommon::TablesToString(aList, list);

View File

@@ -148,6 +148,15 @@ UrlClassifierFeatureSocialTrackingProtection::ProcessChannel(
return NS_OK;
}
bool ShouldProcessByProtectionFeature =
UrlClassifierCommon::ShouldProcessWithProtectionFeature(aChannel);
*aShouldContinue = !ShouldProcessByProtectionFeature;
if (!ShouldProcessByProtectionFeature) {
return NS_OK;
}
nsAutoCString list;
UrlClassifierCommon::TablesToString(aList, list);

View File

@@ -152,6 +152,15 @@ UrlClassifierFeatureTrackingProtection::ProcessChannel(
return NS_OK;
}
bool ShouldProcessByProtectionFeature =
UrlClassifierCommon::ShouldProcessWithProtectionFeature(aChannel);
*aShouldContinue = !ShouldProcessByProtectionFeature;
if (!ShouldProcessByProtectionFeature) {
return NS_OK;
}
nsAutoCString list;
UrlClassifierCommon::TablesToString(aList, list);