Commit 95294d38 authored by William Wen's avatar William Wen Committed by wwwenwilliam@gmail.com
Browse files

Bug 1962092 - Add tracking protection skip for anti-fraud feature. r=timhuang

parent 2d510323
Loading
Loading
Loading
Loading
+12 −0
Changes for modules/libpref/init/StaticPrefList.yaml: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15755,6 +15755,18 @@
  value: true
  mirror: always
# Skip blocking for consentmanager resources in all modes.
- name: privacy.trackingprotection.antifraud.skip.enabled
  type: RelaxedAtomicBool
  value: false
  mirror: always
# Skip blocking for consentmanager resources in Private Browsing mode.
- name: privacy.trackingprotection.antifraud.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
+32 −12
Changes for netwerk/url-classifier/UrlClassifierCommon.cpp: 32 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -699,26 +699,46 @@ bool UrlClassifierCommon::ShouldProcessWithProtectionFeature(
  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;
  }
  bool isPrivateMode = NS_UsePrivateBrowsing(aChannel);

  nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
      do_QueryInterface(aChannel);

  if (classifiedChannel) {
    shouldProcess =
        !(classifiedChannel->GetClassificationFlags() &
          nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_CONSENTMANAGER);
    if (classifiedChannel->GetClassificationFlags() &
        nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_CONSENTMANAGER) {
      // Channel is classified as consent manager
      if (StaticPrefs::
              privacy_trackingprotection_consentmanager_skip_enabled() ||
          (StaticPrefs::
               privacy_trackingprotection_consentmanager_skip_pbmode_enabled() &&
           isPrivateMode)) {
        // Don't process channel
        shouldProcess = false;

        UC_LOG(
            ("UrlClassifierCommon::ShouldProcessWithProtectionFeature - "
             "Skipping channel %p because annotated as a consent manager",
             aChannel));
      }
    }

    if (classifiedChannel->GetClassificationFlags() &
        nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_ANTIFRAUD) {
      // Channel is classified as anti-fraud
      if (StaticPrefs::privacy_trackingprotection_antifraud_skip_enabled() ||
          (StaticPrefs::
               privacy_trackingprotection_antifraud_skip_pbmode_enabled() &&
           isPrivateMode)) {
        // Don't process channel
        shouldProcess = false;

        UC_LOG(
            ("UrlClassifierCommon::ShouldProcessWithProtectionFeature - "
         "shouldProcess=%d for channel %p",
         shouldProcess, aChannel));
             "Skipping channel %p because it is annotated as anti-fraud",
             aChannel));
      }
    }
  }

  return shouldProcess;