Backed out 8 changesets (bug 1620322) for bustages on nsContentSink.cpp . CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Mon, 09 Mar 2020 22:18:36 +0200
changeset 517669 5b47cfcab1554c89400b7a6299ff0cabac4bda0c
parent 517668 fa7358af3fb2bd9e424d056a388a6d5dd525daff
child 517670 f6898bd931c53a7c9ab373a6af960747d06def4b
push id37199
push useropoprus@mozilla.com
push dateTue, 10 Mar 2020 03:43:44 +0000
treeherdermozilla-central@6f21f98dcfcd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1620322
milestone75.0a1
backs outf41739c64dff7f559754d90f993b5abe60f5f8a1
be942a7f329e12b591f318c11f9d09caab59fc6f
a916987c7c71e2bc483a619f06859237225d6d4e
ead3484ffb5f92a35c685ca3c5dbb22fb00d9030
4e1e8b9afa1addc6d3a086602a14a1d3b98847b2
473bba698e5a005a18b788988d898a59152b9764
0e5e5d41597d83dc79d898e9d2bdfb0e9095db71
31b24d79db3ddbadb0034b8f317b677f615593cd
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 8 changesets (bug 1620322) for bustages on nsContentSink.cpp . CLOSED TREE Backed out changeset f41739c64dff (bug 1620322) Backed out changeset be942a7f329e (bug 1620322) Backed out changeset a916987c7c71 (bug 1620322) Backed out changeset ead3484ffb5f (bug 1620322) Backed out changeset 4e1e8b9afa1a (bug 1620322) Backed out changeset 473bba698e5a (bug 1620322) Backed out changeset 0e5e5d41597d (bug 1620322) Backed out changeset 31b24d79db3d (bug 1620322)
build/win32/orderfile.txt
build/win64/orderfile.txt
dom/base/ContentBlockingLog.cpp
dom/base/ContentBlockingLog.h
dom/base/Document.cpp
dom/base/Document.h
dom/base/Navigator.cpp
dom/base/ThirdPartyUtil.cpp
dom/base/moz.build
dom/base/nsContentUtils.cpp
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsPIDOMWindow.h
dom/base/nsWindowRoot.cpp
dom/ipc/BrowserChild.cpp
dom/ipc/BrowserChild.h
dom/ipc/BrowserParent.cpp
dom/ipc/BrowserParent.h
dom/ipc/ContentParent.cpp
dom/ipc/PBrowser.ipdl
dom/ipc/WindowGlobalParent.cpp
dom/ipc/WindowGlobalParent.h
dom/media/MediaCache.cpp
dom/reporting/CrashReport.cpp
dom/security/ReferrerInfo.cpp
dom/workers/RuntimeService.cpp
extensions/permissions/nsPermissionManager.cpp
image/ImageCacheKey.cpp
image/imgFrame.cpp
js/xpconnect/src/XPCJSContext.cpp
layout/style/GeckoBindings.cpp
media/webrtc/signaling/src/peerconnection/RTCStatsReport.h
netwerk/base/nsNetUtil.cpp
netwerk/cookie/CookieServiceChild.cpp
netwerk/cookie/nsCookieService.cpp
netwerk/ipc/DocumentLoadListener.cpp
netwerk/protocol/http/ClassifierDummyChannel.cpp
netwerk/protocol/http/ClassifierDummyChannelChild.cpp
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/url-classifier/UrlClassifierCommon.cpp
netwerk/url-classifier/UrlClassifierCommon.h
netwerk/url-classifier/UrlClassifierFeatureBase.h
netwerk/url-classifier/UrlClassifierFeatureCryptominingAnnotation.cpp
netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp
netwerk/url-classifier/UrlClassifierFeatureFingerprintingAnnotation.cpp
netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp
netwerk/url-classifier/UrlClassifierFeatureSocialTrackingAnnotation.cpp
netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp
netwerk/url-classifier/UrlClassifierFeatureTrackingAnnotation.cpp
netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp
toolkit/components/antitracking/AntiTrackingCommon.cpp
toolkit/components/antitracking/AntiTrackingCommon.h
toolkit/components/antitracking/AntiTrackingIPCUtils.h
toolkit/components/antitracking/AntiTrackingRedirectHeuristic.cpp
toolkit/components/antitracking/AntiTrackingRedirectHeuristic.h
toolkit/components/antitracking/AntiTrackingUtils.cpp
toolkit/components/antitracking/AntiTrackingUtils.h
toolkit/components/antitracking/ContentBlocking.cpp
toolkit/components/antitracking/ContentBlocking.h
toolkit/components/antitracking/ContentBlockingAllowList.h
toolkit/components/antitracking/ContentBlockingLog.cpp
toolkit/components/antitracking/ContentBlockingLog.h
toolkit/components/antitracking/ContentBlockingNotifier.cpp
toolkit/components/antitracking/ContentBlockingNotifier.h
toolkit/components/antitracking/ContentBlockingUserInteraction.cpp
toolkit/components/antitracking/ContentBlockingUserInteraction.h
toolkit/components/antitracking/SettingsChangeObserver.cpp
toolkit/components/antitracking/StorageAccess.cpp
toolkit/components/antitracking/StoragePrincipalHelper.cpp
toolkit/components/antitracking/StoragePrincipalHelper.h
toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp
toolkit/components/antitracking/TemporaryAccessGrantObserver.h
toolkit/components/antitracking/URLDecorationStripper.cpp
toolkit/components/antitracking/moz.build
toolkit/components/telemetry/tests/gtest/TestOrigins.cpp
--- a/build/win32/orderfile.txt
+++ b/build/win32/orderfile.txt
@@ -19399,16 +19399,17 @@ Gecko_BeginWritingCString
 ?MaybeCreate@UrlClassifierFeatureFingerprintingProtection@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureFingerprintingProtection@net@mozilla@@@@PAVnsIChannel@@@Z
 ?MaybeCreate@UrlClassifierFeatureTrackingProtection@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureTrackingProtection@net@mozilla@@@@PAVnsIChannel@@@Z
 ?MaybeCreate@UrlClassifierFeatureCryptominingAnnotation@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureCryptominingAnnotation@net@mozilla@@@@PAVnsIChannel@@@Z
 ?MaybeCreate@UrlClassifierFeatureFingerprintingAnnotation@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureFingerprintingAnnotation@net@mozilla@@@@PAVnsIChannel@@@Z
 ?MaybeCreate@UrlClassifierFeatureTrackingAnnotation@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureTrackingAnnotation@net@mozilla@@@@PAVnsIChannel@@@Z
 ?ShouldEnableClassifier@UrlClassifierCommon@net@mozilla@@SA_NPAVnsIChannel@@@Z
 ?AddonMayLoad@UrlClassifierCommon@net@mozilla@@SA_NPAVnsIChannel@@PAVnsIURI@@@Z
 ?GetTopWindowURI@HttpBaseChannel@net@mozilla@@UAG?AW4nsresult@@PAPAVnsIURI@@@Z
+?MaybeGetDocumentURIBeingLoaded@AntiTrackingCommon@mozilla@@SA?AU?$already_AddRefed@VnsIURI@@@@PAVnsIChannel@@@Z
 ?GetTopWindowURI@HttpBaseChannel@net@mozilla@@IAE?AW4nsresult@@PAVnsIURI@@PAPAV5@@Z
 XPCOMService_GetThirdPartyUtil
 ?GetTopWindowForChannel@ThirdPartyUtil@@UAG?AW4nsresult@@PAVnsIChannel@@PAVnsIURI@@PAPAVmozIDOMWindowProxy@@@Z
 ?GetTopExcludingExtensionAccessibleContentFrames@nsGlobalWindowOuter@@QAE?AU?$already_AddRefed@VnsPIDOMWindowOuter@@@@PAVnsIURI@@@Z
 ?AddonAllowsLoad@BasePrincipal@mozilla@@QAE_NPAVnsIURI@@_N@Z
 ?GetURIFromWindow@ThirdPartyUtil@@UAG?AW4nsresult@@PAVmozIDOMWindowProxy@@PAPAVnsIURI@@@Z
 ?GetPrincipalFromWindow@ThirdPartyUtil@@UAG?AW4nsresult@@PAVmozIDOMWindowProxy@@PAPAVnsIPrincipal@@@Z
 ?MaybeCreate@UrlClassifierFeatureFlash@net@mozilla@@SAXPAVnsIChannel@@AAV?$nsTArray@V?$nsCOMPtr@VnsIUrlClassifierFeature@@@@@@@Z
@@ -19526,35 +19527,38 @@ XPCOMService_GetThirdPartyUtil
 ?IsThirdPartyChannel@ThirdPartyUtil@@UAG?AW4nsresult@@PAVnsIChannel@@PAVnsIURI@@PA_N@Z
 ?GetThirdPartyFlags@HttpBaseChannel@net@mozilla@@UAG?AW4nsresult@@PAI@Z
 ?GetIsInThirdPartyContext@LoadInfo@net@mozilla@@UAG?AW4nsresult@@PA_N@Z
 ?IsThirdPartyInternal@ThirdPartyUtil@@AAE?AW4nsresult@@ABV?$nsTString@D@@PAVnsIURI@@PA_N@Z
 ?IsTrackingResource@HttpBaseChannel@net@mozilla@@UAG?AW4nsresult@@PA_N@Z
 ?IsTrackingClassificationFlag@UrlClassifierCommon@net@mozilla@@SA_NI@Z
 ?DeQueue@nsHostResolver@@AAEXAAV?$LinkedList@V?$RefPtr@VnsHostRecord@@@@@mozilla@@PAPAVAddrHostRecord@@@Z
 ?popFirst@?$LinkedList@V?$RefPtr@VnsHostRecord@@@@@mozilla@@QAE?AV?$RefPtr@VnsHostRecord@@@@XZ
+?IsFirstPartyStorageAccessGrantedFor@AntiTrackingCommon@mozilla@@SA_NPAVnsIHttpChannel@@PAVnsIURI@@PAI@Z
 ?GetTopLevelPrincipal@LoadInfo@net@mozilla@@UAEPAVnsIPrincipal@@XZ
 ?GetIsMainDocumentChannel@HttpBaseChannel@net@mozilla@@UAG?AW4nsresult@@PA_N@Z
 ?GetAddrInfo@net@mozilla@@YA?AW4nsresult@@ABV?$nsTSubstring@D@@GGPAPAVAddrInfo@12@_N@Z
 ?GetIsContentPrincipal@BasePrincipal@mozilla@@UAG?AW4nsresult@@PA_N@Z
 ?CookiePermission@CookieSettings@net@mozilla@@UAG?AW4nsresult@@PAVnsIPrincipal@@PAI@Z
 ?GetInstance@nsPermissionManager@@SAPAV1@XZ
 ?Create@nsPermission@@SA?AU?$already_AddRefed@VnsPermission@@@@PAVnsIPrincipal@@ABV?$nsTSubstring@D@@II_J@Z
 ?CloneStrippingUserContextIdAndFirstPartyDomain@BasePrincipal@mozilla@@QAE?AU?$already_AddRefed@VBasePrincipal@mozilla@@@@XZ
 ??0nsPermission@@IAE@PAVnsIPrincipal@@ABV?$nsTSubstring@D@@II_J@Z
 ?AddRef@nsPermission@@UAGKXZ
 ??$AppendElement@AAV?$nsCOMPtr@VnsIPermission@@@@UnsTArrayInfallibleAllocator@@@?$nsTArray_Impl@V?$RefPtr@VnsIPermission@@@@UnsTArrayInfallibleAllocator@@@@IAEPAV?$RefPtr@VnsIPermission@@@@AAV?$nsCOMPtr@VnsIPermission@@@@@Z
 ?Release@nsPermission@@UAGKXZ
 ?extensions_cookiesBehavior_overrideOnTopLevel@StaticPrefs@mozilla@@SA_NXZ
 ?GetChannelId@HttpBaseChannel@net@mozilla@@UAG?AW4nsresult@@PA_K@Z
 ??$?0PAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@V?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@mozilla@@@?$PairHelper@PAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@V?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@mozilla@@$00$0A@@detail@mozilla@@IAE@$$QAPAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@$$QAV?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@2@@Z
+?OnAntiTrackingSettingsChanged@AntiTrackingCommon@mozilla@@SAXABV?$function@$$A6AXXZ@std@@@Z
 ?first@?$PairHelper@PAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@V?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@mozilla@@$00$0A@@detail@mozilla@@IBEABQAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@XZ
 ??4?$UniquePtr@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@V?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@mozilla@@@mozilla@@QAEAAV01@$$QAV01@@Z
 ??$AppendElement@ABV?$function@$$A6AXXZ@std@@UnsTArrayInfallibleAllocator@@@?$nsTArray_Impl@V?$function@$$A6AXXZ@std@@UnsTArrayInfallibleAllocator@@@@IAEPAV?$function@$$A6AXXZ@std@@ABV12@@Z
 ??$EnsureCapacity@UnsTArrayInfallibleAllocator@@@?$nsTArray_base@UnsTArrayInfallibleAllocator@@U?$nsTArray_CopyWithConstructors@V?$function@$$A6AXXZ@std@@@@@@IAE?AUnsTArrayInfallibleResult@@II@Z
+?IsOnContentBlockingAllowList@AntiTrackingCommon@mozilla@@SA?AW4nsresult@@PAVnsIURI@@_NW4ContentBlockingAllowListPurpose@12@AA_N@Z
 ?TestPermissionOriginNoSuffix@nsPermissionManager@@UAG?AW4nsresult@@ABV?$nsTSubstring@D@@0PAI@Z
 ?NS_IsSafeTopLevelNav@@YA_NPAVnsIChannel@@@Z
 ?IsSafeMethod@nsHttpRequestHead@net@mozilla@@QAE_NXZ
 ?NS_IsSameSiteForeign@@YA_NPAVnsIChannel@@PAVnsIURI@@@Z
 ?GetCookieStringInternal@nsCookieService@@IAEXPAVnsIURI@@PAVnsIChannel@@_N22222ABVOriginAttributes@mozilla@@AAV?$nsTString@D@@@Z
 ?GetCookiesForURI@nsCookieService@@QAEXPAVnsIURI@@PAVnsIChannel@@_N22222ABVOriginAttributes@mozilla@@AAV?$nsTArray@PAVnsCookie@@@@@Z
 ?EnsureReadComplete@nsCookieService@@IAEX_N@Z
 ?GetBaseDomain@nsCookieService@@SA?AW4nsresult@@PAVnsIEffectiveTLDService@@PAVnsIURI@@AAV?$nsTString@D@@AA_N@Z
@@ -26359,16 +26363,17 @@ Gecko_AppendPropertyValuePair
 ?PreloadImage@nsHtml5TreeOpExecutor@@QAEXABV?$nsTSubstring@_S@@0000@Z
 ?ResolvePreloadImage@Document@dom@mozilla@@QAE?AU?$already_AddRefed@VnsIURI@@@@PAVnsIURI@@ABV?$nsTSubstring@_S@@11PA_N@Z
 ?SelectSourceForTagWithAttrs@HTMLImageElement@dom@mozilla@@SA_NPAVDocument@23@_NABV?$nsTSubstring@_S@@2222AAV5@@Z
 ?MaybePreLoadImage@Document@dom@mozilla@@QAEXPAVnsIURI@@ABV?$nsTSubstring@_S@@W4ReferrerPolicy@net@3@_N@Z
 ?IsImageInCache@nsContentUtils@@SA_NPAVnsIURI@@PAVDocument@dom@mozilla@@@Z
 ?QueryInterface@imgLoader@@UAG?AW4nsresult@@ABUnsID@@PAPAX@Z
 ?FindEntryProperties@imgLoader@@UAG?AW4nsresult@@PAVnsIURI@@PAVDocument@dom@mozilla@@PAPAVnsIProperties@@@Z
 ?IsThirdPartyTrackingResourceWindow@nsContentUtils@@SA_NPAVnsPIDOMWindowInner@@@Z
+?MaybeIsFirstPartyStorageAccessGrantedFor@AntiTrackingCommon@mozilla@@SA_NPAVnsPIDOMWindowInner@@PAVnsIURI@@@Z
 ??$CreateAndResolve@_N@?$MozPromise@H_N$00@mozilla@@SA?AV?$RefPtr@V?$MozPromise@H_N$00@mozilla@@@@$$QA_NPBD@Z
 ?AdjustPriority@HttpBaseChannel@net@mozilla@@UAG?AW4nsresult@@H@Z
 ?SetTimingEnabled@imgRequestProxy@@UAG?AW4nsresult@@_N@Z
 ?s_HashKey@?$nsTHashtable@V?$nsBaseHashtableET@VnsURIHashKey@@V?$RefPtr@VimgIRequest@@@@@@@@KAIPBX@Z
 ?s_InitEntry@?$nsTHashtable@V?$nsBaseHashtableET@VnsURIHashKey@@V?$RefPtr@VimgIRequest@@@@@@@@KAXPAUPLDHashEntryHdr@@PBX@Z
 ?UpdateEffectProperties@EffectCompositor@mozilla@@QAEXPBVComputedStyle@2@PAVElement@dom@2@W4PseudoStyleType@2@@Z
 ??$?8UnsTArrayInfallibleAllocator@@@?$nsTArray_Impl@UAnimationPropertySegment@mozilla@@UnsTArrayInfallibleAllocator@@@@QBE_NABV0@@Z
 ??8AnimationPropertySegment@mozilla@@QBE_NABU01@@Z
--- a/build/win64/orderfile.txt
+++ b/build/win64/orderfile.txt
@@ -19317,16 +19317,17 @@ Gecko_BeginWritingCString
 ?MaybeCreate@UrlClassifierFeatureFingerprintingProtection@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureFingerprintingProtection@net@mozilla@@@@PEAVnsIChannel@@@Z
 ?MaybeCreate@UrlClassifierFeatureTrackingProtection@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureTrackingProtection@net@mozilla@@@@PEAVnsIChannel@@@Z
 ?MaybeCreate@UrlClassifierFeatureCryptominingAnnotation@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureCryptominingAnnotation@net@mozilla@@@@PEAVnsIChannel@@@Z
 ?MaybeCreate@UrlClassifierFeatureFingerprintingAnnotation@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureFingerprintingAnnotation@net@mozilla@@@@PEAVnsIChannel@@@Z
 ?MaybeCreate@UrlClassifierFeatureTrackingAnnotation@net@mozilla@@SA?AU?$already_AddRefed@VUrlClassifierFeatureTrackingAnnotation@net@mozilla@@@@PEAVnsIChannel@@@Z
 ?ShouldEnableClassifier@UrlClassifierCommon@net@mozilla@@SA_NPEAVnsIChannel@@@Z
 ?AddonMayLoad@UrlClassifierCommon@net@mozilla@@SA_NPEAVnsIChannel@@PEAVnsIURI@@@Z
 ?GetTopWindowURI@HttpBaseChannel@net@mozilla@@UEAA?AW4nsresult@@PEAPEAVnsIURI@@@Z
+?MaybeGetDocumentURIBeingLoaded@AntiTrackingCommon@mozilla@@SA?AU?$already_AddRefed@VnsIURI@@@@PEAVnsIChannel@@@Z
 ?GetTopWindowURI@HttpBaseChannel@net@mozilla@@IEAA?AW4nsresult@@PEAVnsIURI@@PEAPEAV5@@Z
 XPCOMService_GetThirdPartyUtil
 ?GetTopWindowForChannel@ThirdPartyUtil@@UEAA?AW4nsresult@@PEAVnsIChannel@@PEAVnsIURI@@PEAPEAVmozIDOMWindowProxy@@@Z
 ?GetTopExcludingExtensionAccessibleContentFrames@nsGlobalWindowOuter@@QEAA?AU?$already_AddRefed@VnsPIDOMWindowOuter@@@@PEAVnsIURI@@@Z
 ?AddonAllowsLoad@BasePrincipal@mozilla@@QEAA_NPEAVnsIURI@@_N@Z
 ?GetURIFromWindow@ThirdPartyUtil@@UEAA?AW4nsresult@@PEAVmozIDOMWindowProxy@@PEAPEAVnsIURI@@@Z
 ?GetPrincipalFromWindow@ThirdPartyUtil@@UEAA?AW4nsresult@@PEAVmozIDOMWindowProxy@@PEAPEAVnsIPrincipal@@@Z
 ?MaybeCreate@UrlClassifierFeatureFlash@net@mozilla@@SAXPEAVnsIChannel@@AEAV?$nsTArray@V?$nsCOMPtr@VnsIUrlClassifierFeature@@@@@@@Z
@@ -19437,16 +19438,17 @@ XPCOMService_GetThirdPartyUtil
 ?GetCookieStringFromHttp@nsCookieService@@UEAA?AW4nsresult@@PEAVnsIURI@@0PEAVnsIChannel@@PEAPEAD@Z
 ?GetCookieStringCommon@nsCookieService@@IEAA?AW4nsresult@@PEAVnsIURI@@PEAVnsIChannel@@_NPEAPEAD@Z
 ?IsThirdPartyChannel@ThirdPartyUtil@@UEAA?AW4nsresult@@PEAVnsIChannel@@PEAVnsIURI@@PEA_N@Z
 ?GetThirdPartyFlags@HttpBaseChannel@net@mozilla@@UEAA?AW4nsresult@@PEAI@Z
 ?GetIsInThirdPartyContext@LoadInfo@net@mozilla@@UEAA?AW4nsresult@@PEA_N@Z
 ?IsThirdPartyInternal@ThirdPartyUtil@@AEAA?AW4nsresult@@AEBV?$nsTString@D@@PEAVnsIURI@@PEA_N@Z
 ?IsTrackingResource@HttpBaseChannel@net@mozilla@@UEAA?AW4nsresult@@PEA_N@Z
 ?IsTrackingClassificationFlag@UrlClassifierCommon@net@mozilla@@SA_NI@Z
+?IsFirstPartyStorageAccessGrantedFor@AntiTrackingCommon@mozilla@@SA_NPEAVnsIHttpChannel@@PEAVnsIURI@@PEAI@Z
 ?GetTopLevelPrincipal@LoadInfo@net@mozilla@@UEAAPEAVnsIPrincipal@@XZ
 ?GetIsMainDocumentChannel@HttpBaseChannel@net@mozilla@@UEAA?AW4nsresult@@PEA_N@Z
 ?GetIsContentPrincipal@BasePrincipal@mozilla@@UEAA?AW4nsresult@@PEA_N@Z
 ?CookiePermission@CookieSettings@net@mozilla@@UEAA?AW4nsresult@@PEAVnsIPrincipal@@PEAI@Z
 ?GetInstance@nsPermissionManager@@SAPEAV1@XZ
 ?Run@?$RunnableMethodImpl@PEAVnsHostResolver@@P81@EAAXXZ$00$0A@$$V@detail@mozilla@@UEAA?AW4nsresult@@XZ
 ?ThreadFunc@nsHostResolver@@AEAAXXZ
 ?GetHostToLookup@nsHostResolver@@AEAA_NPEAPEAVAddrHostRecord@@@Z
@@ -19457,20 +19459,22 @@ XPCOMService_GetThirdPartyUtil
 ?GetAddrInfo@net@mozilla@@YA?AW4nsresult@@AEBV?$nsTSubstring@D@@GGPEAPEAVAddrInfo@12@_N@Z
 ??0nsPermission@@IEAA@PEAVnsIPrincipal@@AEBV?$nsTSubstring@D@@II_J@Z
 ?AddRef@nsPermission@@UEAAKXZ
 ??$AppendElement@AEAV?$nsCOMPtr@VnsIPermission@@@@UnsTArrayInfallibleAllocator@@@?$nsTArray_Impl@V?$RefPtr@VnsIPermission@@@@UnsTArrayInfallibleAllocator@@@@IEAAPEAV?$RefPtr@VnsIPermission@@@@AEAV?$nsCOMPtr@VnsIPermission@@@@@Z
 ?Release@nsPermission@@UEAAKXZ
 ?extensions_cookiesBehavior_overrideOnTopLevel@StaticPrefs@mozilla@@SA_NXZ
 ?GetChannelId@HttpBaseChannel@net@mozilla@@UEAA?AW4nsresult@@PEA_K@Z
 ??$?0PEAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@V?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@mozilla@@@?$PairHelper@PEAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@V?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@mozilla@@$00$0A@@detail@mozilla@@IEAA@$$QEAPEAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@$$QEAV?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@2@@Z
+?OnAntiTrackingSettingsChanged@AntiTrackingCommon@mozilla@@SAXAEBV?$function@$$A6AXXZ@std@@@Z
 ?first@?$PairHelper@PEAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@V?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@mozilla@@$00$0A@@detail@mozilla@@IEBAAEBQEAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@XZ
 ?reset@?$UniquePtr@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@V?$DefaultDelete@V?$nsTArray@V?$function@$$A6AXXZ@std@@@@@mozilla@@@mozilla@@QEAAXPEAV?$nsTArray@V?$function@$$A6AXXZ@std@@@@@Z
 ??$AppendElement@AEBV?$function@$$A6AXXZ@std@@UnsTArrayInfallibleAllocator@@@?$nsTArray_Impl@V?$function@$$A6AXXZ@std@@UnsTArrayInfallibleAllocator@@@@IEAAPEAV?$function@$$A6AXXZ@std@@AEBV12@@Z
 ??$EnsureCapacity@UnsTArrayInfallibleAllocator@@@?$nsTArray_base@UnsTArrayInfallibleAllocator@@U?$nsTArray_CopyWithConstructors@V?$function@$$A6AXXZ@std@@@@@@IEAA?AUnsTArrayInfallibleResult@@_K0@Z
+?IsOnContentBlockingAllowList@AntiTrackingCommon@mozilla@@SA?AW4nsresult@@PEAVnsIURI@@_NW4ContentBlockingAllowListPurpose@12@AEA_N@Z
 ?TestPermissionOriginNoSuffix@nsPermissionManager@@UEAA?AW4nsresult@@AEBV?$nsTSubstring@D@@0PEAI@Z
 ?NS_IsSafeTopLevelNav@@YA_NPEAVnsIChannel@@@Z
 ?IsSafeMethod@nsHttpRequestHead@net@mozilla@@QEAA_NXZ
 ?NS_IsSameSiteForeign@@YA_NPEAVnsIChannel@@PEAVnsIURI@@@Z
 ?GetCookieStringInternal@nsCookieService@@IEAAXPEAVnsIURI@@PEAVnsIChannel@@_N22222AEBVOriginAttributes@mozilla@@AEAV?$nsTString@D@@@Z
 ?GetCookiesForURI@nsCookieService@@QEAAXPEAVnsIURI@@PEAVnsIChannel@@_N22222AEBVOriginAttributes@mozilla@@AEAV?$nsTArray@PEAVnsCookie@@@@@Z
 ?EnsureReadComplete@nsCookieService@@IEAAX_N@Z
 ?GetBaseDomain@nsCookieService@@SA?AW4nsresult@@PEAVnsIEffectiveTLDService@@PEAVnsIURI@@AEAV?$nsTString@D@@AEA_N@Z
@@ -26326,16 +26330,17 @@ UnregisterWeakMemoryReporter
 ?nsStringInputStreamConstructor@@YA?AW4nsresult@@PEAVnsISupports@@AEBUnsID@@PEAPEAX@Z
 ?SetData@nsStringInputStream@@UEAA?AW4nsresult@@PEBDH@Z
 ?SetUploadStream@HttpBaseChannel@net@mozilla@@UEAA?AW4nsresult@@PEAVnsIInputStream@@AEBV?$nsTSubstring@D@@_J@Z
 ?ExplicitSetUploadStream@HttpBaseChannel@net@mozilla@@UEAA?AW4nsresult@@PEAVnsIInputStream@@AEBV?$nsTSubstring@D@@_J1_N@Z
 ?GetSyncLength@InputStreamLengthHelper@mozilla@@SA_NPEAVnsIInputStream@@PEA_J@Z
 ?ExplicitSetUploadStreamLength@HttpBaseChannel@net@mozilla@@AEAA?AW4nsresult@@_K_N@Z
 ??$ReplaceChar@_SX@?$nsTString@_S@@QEAAXPEBD_S@Z
 ?Set@URLParams@dom@mozilla@@QEAAXAEBV?$nsTSubstring@_S@@0@Z
+?NotifyBlockingDecision@AntiTrackingCommon@mozilla@@SAXPEAVnsIChannel@@W4BlockingDecision@12@I@Z
 ?ConstructorEnabled@ChannelWrapper_Binding@dom@mozilla@@YA_NPEAUJSContext@@V?$Handle@PEAVJSObject@@@JS@@@Z
 ?CreateInterfaceObjects@ChannelWrapper_Binding@dom@mozilla@@YAXPEAUJSContext@@V?$Handle@PEAVJSObject@@@JS@@AEAVProtoAndIfaceCache@23@_N@Z
 ?Id@ChannelWrapper@extensions@mozilla@@QEBA_KXZ
 ?Get@ChannelWrapper@extensions@mozilla@@SA?AU?$already_AddRefed@VChannelWrapper@extensions@mozilla@@@@AEBVGlobalObject@dom@3@PEAVnsIChannel@@@Z
 ??0ChannelWrapper@extensions@mozilla@@AEAA@PEAVnsISupports@@PEAVnsIChannel@@@Z
 ??0?$RefPtr@VChannelWrapper@extensions@mozilla@@@@QEAA@PEAVChannelWrapper@extensions@mozilla@@@Z
 ?assign_with_AddRef@?$RefPtr@VChannelWrapper@extensions@mozilla@@@@AEAAXPEAVChannelWrapper@extensions@mozilla@@@Z
 ?AddRef@ChannelWrapper@extensions@mozilla@@UEAAKXZ
@@ -26660,16 +26665,17 @@ Gecko_AppendPropertyValuePair
 ?ParseMetaDataEntry@Predictor@net@mozilla@@AEAA_NPEBD0AEAV?$nsTString@D@@AEAI22@Z
 ?PreloadImage@nsHtml5TreeOpExecutor@@QEAAXAEBV?$nsTSubstring@_S@@0000@Z
 ?ResolvePreloadImage@Document@dom@mozilla@@QEAA?AU?$already_AddRefed@VnsIURI@@@@PEAVnsIURI@@AEBV?$nsTSubstring@_S@@11PEA_N@Z
 ?SelectSourceForTagWithAttrs@HTMLImageElement@dom@mozilla@@SA_NPEAVDocument@23@_NAEBV?$nsTSubstring@_S@@2222AEAV5@@Z
 ?MaybePreLoadImage@Document@dom@mozilla@@QEAAXPEAVnsIURI@@AEBV?$nsTSubstring@_S@@W4ReferrerPolicy@net@3@_N@Z
 ?IsImageInCache@nsContentUtils@@SA_NPEAVnsIURI@@PEAVDocument@dom@mozilla@@@Z
 ?FindEntryProperties@imgLoader@@UEAA?AW4nsresult@@PEAVnsIURI@@PEAVDocument@dom@mozilla@@PEAPEAVnsIProperties@@@Z
 ?IsThirdPartyTrackingResourceWindow@nsContentUtils@@SA_NPEAVnsPIDOMWindowInner@@@Z
+?MaybeIsFirstPartyStorageAccessGrantedFor@AntiTrackingCommon@mozilla@@SA_NPEAVnsPIDOMWindowInner@@PEAVnsIURI@@@Z
 ??$CreateAndResolve@_N@?$MozPromise@H_N$00@mozilla@@SA?AV?$RefPtr@V?$MozPromise@H_N$00@mozilla@@@@$$QEA_NPEBD@Z
 ?AdjustPriority@HttpBaseChannel@net@mozilla@@UEAA?AW4nsresult@@H@Z
 ?SetTimingEnabled@imgRequestProxy@@UEAA?AW4nsresult@@_N@Z
 ?s_HashKey@?$nsTHashtable@V?$nsBaseHashtableET@VnsURIHashKey@@V?$RefPtr@VimgIRequest@@@@@@@@KAIPEBX@Z
 ?s_InitEntry@?$nsTHashtable@V?$nsBaseHashtableET@VnsURIHashKey@@V?$RefPtr@VimgIRequest@@@@@@@@KAXPEAUPLDHashEntryHdr@@PEBX@Z
 ?UpdateEffectProperties@EffectCompositor@mozilla@@QEAAXPEBVComputedStyle@2@PEAVElement@dom@2@W4PseudoStyleType@2@@Z
 ??$?8UnsTArrayInfallibleAllocator@@@?$nsTArray_Impl@UAnimationPropertySegment@mozilla@@UnsTArrayInfallibleAllocator@@@@QEBA_NAEBV0@@Z
 ??8AnimationPropertySegment@mozilla@@QEBA_NAEBU01@@Z
rename from toolkit/components/antitracking/ContentBlockingLog.cpp
rename to dom/base/ContentBlockingLog.cpp
--- a/toolkit/components/antitracking/ContentBlockingLog.cpp
+++ b/dom/base/ContentBlockingLog.cpp
@@ -25,16 +25,18 @@ namespace mozilla {
 using ipc::AutoIPCStream;
 
 static LazyLogModule gContentBlockingLog("ContentBlockingLog");
 #define LOG(fmt, ...) \
   MOZ_LOG(gContentBlockingLog, LogLevel::Debug, (fmt, ##__VA_ARGS__))
 
 typedef Telemetry::OriginMetricID OriginMetricID;
 
+namespace dom {
+
 // sync with TelemetryOriginData.inc
 NS_NAMED_LITERAL_CSTRING(ContentBlockingLog::kDummyOriginHash, "PAGELOAD");
 
 // randomly choose 1% users included in the content blocking measurement
 // based on their client id.
 static constexpr double kRatioReportUser = 0.01;
 
 // randomly choose 0.14% documents when the page is unload.
@@ -103,17 +105,17 @@ static void ReportOriginSingleHash(Origi
       Telemetry::MetricIDToString[static_cast<uint32_t>(aId)]);
   LOG("ReportOriginSingleHash origin=%s", PromiseFlatCString(aOrigin).get());
 
   Telemetry::RecordOrigin(aId, aOrigin);
 }
 
 Maybe<uint32_t> ContentBlockingLog::RecordLogParent(
     const nsACString& aOrigin, uint32_t aType, bool aBlocked,
-    const Maybe<ContentBlockingNotifier::StorageAccessGrantedReason>& aReason,
+    const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason,
     const nsTArray<nsCString>& aTrackingFullHashes) {
   MOZ_ASSERT(XRE_IsParentProcess());
 
   uint32_t events = GetContentBlockingEventsInLog();
 
   bool blockedValue = aBlocked;
   bool unblocked = false;
 
@@ -286,9 +288,10 @@ void ContentBlockingLog::ReportOrigins()
         lookupTable.AppendElement(key);
         ReportOriginSingleHash(metricId, hash);
       }
       break;
     }
   }
 }
 
+}  // namespace dom
 }  // namespace mozilla
rename from toolkit/components/antitracking/ContentBlockingLog.h
rename to dom/base/ContentBlockingLog.h
--- a/toolkit/components/antitracking/ContentBlockingLog.h
+++ b/dom/base/ContentBlockingLog.h
@@ -1,41 +1,40 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef mozilla_ContentBlockingLog_h
-#define mozilla_ContentBlockingLog_h
+#ifndef mozilla_dom_ContentBlockingLog_h
+#define mozilla_dom_ContentBlockingLog_h
 
-#include "mozilla/ContentBlockingNotifier.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/JSONWriter.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/Tuple.h"
 #include "mozilla/UniquePtr.h"
 #include "nsIWebProgressListener.h"
 #include "nsReadableUtils.h"
 #include "nsTArray.h"
 #include "nsWindowSizes.h"
 
-class nsIPrincipal;
-
 namespace mozilla {
+namespace dom {
 
 class ContentBlockingLog final {
-  typedef ContentBlockingNotifier::StorageAccessGrantedReason
+  typedef AntiTrackingCommon::StorageAccessGrantedReason
       StorageAccessGrantedReason;
 
   struct LogEntry {
     uint32_t mType;
     uint32_t mRepeatCount;
     bool mBlocked;
-    Maybe<ContentBlockingNotifier::StorageAccessGrantedReason> mReason;
+    Maybe<AntiTrackingCommon::StorageAccessGrantedReason> mReason;
     nsTArray<nsCString> mTrackingFullHashes;
   };
 
   struct OriginDataEntry {
     OriginDataEntry()
         : mHasLevel1TrackingContentLoaded(false),
           mHasLevel2TrackingContentLoaded(false) {}
 
@@ -83,22 +82,22 @@ class ContentBlockingLog final {
   ContentBlockingLog() = default;
   ~ContentBlockingLog() = default;
 
   // Record the log in the parent process. This should be called only in the
   // parent process and will replace the RecordLog below after we remove the
   // ContentBlockingLog from content processes.
   Maybe<uint32_t> RecordLogParent(
       const nsACString& aOrigin, uint32_t aType, bool aBlocked,
-      const Maybe<ContentBlockingNotifier::StorageAccessGrantedReason>& aReason,
+      const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason,
       const nsTArray<nsCString>& aTrackingFullHashes);
 
   void RecordLog(
       const nsACString& aOrigin, uint32_t aType, bool aBlocked,
-      const Maybe<ContentBlockingNotifier::StorageAccessGrantedReason>& aReason,
+      const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason,
       const nsTArray<nsCString>& aTrackingFullHashes) {
     RecordLogInternal(aOrigin, aType, aBlocked, aReason, aTrackingFullHashes);
   }
 
   void ReportOrigins();
   void ReportLog(nsIPrincipal* aFirstPartyPrincipal);
 
   nsAutoCString Stringify() {
@@ -237,18 +236,18 @@ class ContentBlockingLog final {
     }
 
     return events;
   }
 
  private:
   void RecordLogInternal(
       const nsACString& aOrigin, uint32_t aType, bool aBlocked,
-      const Maybe<ContentBlockingNotifier::StorageAccessGrantedReason>&
-          aReason = Nothing(),
+      const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason =
+          Nothing(),
       const nsTArray<nsCString>& aTrackingFullHashes = nsTArray<nsCString>()) {
     DebugOnly<bool> isCookiesBlockedTracker =
         aType == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
         aType == nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER;
     MOZ_ASSERT_IF(aBlocked, aReason.isNothing());
     MOZ_ASSERT_IF(!isCookiesBlockedTracker, aReason.isNothing());
     MOZ_ASSERT_IF(isCookiesBlockedTracker && !aBlocked, aReason.isSome());
 
@@ -420,11 +419,12 @@ class ContentBlockingLog final {
       aWriter.EndArray();
     }
   }
 
  private:
   OriginDataTable mLog;
 };
 
+}  // namespace dom
 }  // namespace mozilla
 
 #endif
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -6,23 +6,21 @@
 
 /*
  * Base class for all our document implementations.
  */
 
 #include "AudioChannelService.h"
 #include "mozilla/dom/Document.h"
 #include "DocumentInlines.h"
-#include "mozilla/AntiTrackingUtils.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/BinarySearch.h"
-#include "mozilla/ContentBlocking.h"
 #include "mozilla/ContentBlockingAllowList.h"
-#include "mozilla/ContentBlockingUserInteraction.h"
 #include "mozilla/CSSEnabledState.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/EditorCommands.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/EnumSet.h"
 #include "mozilla/HTMLEditor.h"
 #include "mozilla/IdentifierMapEntry.h"
 #include "mozilla/IntegerRange.h"
@@ -15061,19 +15059,19 @@ void Document::MaybeAllowStorageForOpene
   // should not continue.
   if (!nsContentUtils::IsThirdPartyWindowOrChannel(inner, nullptr, openerURI) &&
       !nsContentUtils::IsThirdPartyWindowOrChannel(openerInner, nullptr,
                                                    nullptr)) {
     return;
   }
 
   // We don't care when the asynchronous work finishes here.
-  Unused << ContentBlocking::AllowAccessFor(
+  Unused << AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(
       NodePrincipal(), openerInner,
-      ContentBlockingNotifier::eOpenerAfterUserInteraction);
+      AntiTrackingCommon::eOpenerAfterUserInteraction);
 }
 
 namespace {
 
 // Documents can stay alive for days. We don't want to update the permission
 // value at any user-interaction, and, using a timer triggered any X seconds
 // should be good enough. 'X' is taken from
 // privacy.userInteraction.document.interval pref.
@@ -15163,17 +15161,17 @@ class UserIntractionTimer final : public
     nsCOMPtr<nsIAsyncShutdownClient> phase = GetShutdownPhase();
     if (phase) {
       phase->RemoveBlocker(this);
     }
 
     // If the document is not gone, let's reset its timer flag.
     nsCOMPtr<Document> document = do_QueryReferent(mDocument);
     if (document) {
-      ContentBlockingUserInteraction::Observe(mPrincipal);
+      AntiTrackingCommon::StoreUserInteractionFor(mPrincipal);
       document->ResetUserInteractionTimer();
     }
   }
 
   void CancelTimerAndStoreUserInteraction() {
     if (mTimer) {
       mTimer->Cancel();
       mTimer = nullptr;
@@ -15209,17 +15207,17 @@ NS_IMPL_ISUPPORTS_INHERITED(UserIntracti
 void Document::MaybeStoreUserInteractionAsPermission() {
   // We care about user-interaction stored only for top-level documents.
   if (!IsTopLevelContentDocument()) {
     return;
   }
 
   if (!mUserHasInteracted) {
     // First interaction, let's store this info now.
-    ContentBlockingUserInteraction::Observe(NodePrincipal());
+    AntiTrackingCommon::StoreUserInteractionFor(NodePrincipal());
     return;
   }
 
   if (mHasUserInteractionTimerScheduled) {
     return;
   }
 
   nsCOMPtr<nsIRunnable> task = new UserIntractionTimer(this);
@@ -15634,30 +15632,29 @@ already_AddRefed<mozilla::dom::Promise> 
       DebugOnly<bool> isOnAllowList = false;
       MOZ_ASSERT_IF(NS_SUCCEEDED(ContentBlockingAllowList::Check(
                         parent->GetContentBlockingAllowListPrincipal(), false,
                         isOnAllowList)),
                     !isOnAllowList);
 
       RefPtr<Document> self(this);
 
-      auto performFinalChecks =
-          [inner,
-           self]() -> RefPtr<ContentBlocking::StorageAccessFinalCheckPromise> {
-        RefPtr<ContentBlocking::StorageAccessFinalCheckPromise::Private> p =
-            new ContentBlocking::StorageAccessFinalCheckPromise::Private(
+      auto performFinalChecks = [inner, self]()
+          -> RefPtr<AntiTrackingCommon::StorageAccessFinalCheckPromise> {
+        RefPtr<AntiTrackingCommon::StorageAccessFinalCheckPromise::Private> p =
+            new AntiTrackingCommon::StorageAccessFinalCheckPromise::Private(
                 __func__);
         RefPtr<StorageAccessPermissionRequest> sapr =
             StorageAccessPermissionRequest::Create(
                 inner,
                 // Allow
                 [p] {
                   Telemetry::AccumulateCategorical(
                       Telemetry::LABELS_STORAGE_ACCESS_API_UI::Allow);
-                  p->Resolve(ContentBlocking::eAllow, __func__);
+                  p->Resolve(AntiTrackingCommon::eAllow, __func__);
                 },
                 // Block
                 [p] {
                   Telemetry::AccumulateCategorical(
                       Telemetry::LABELS_STORAGE_ACCESS_API_UI::Deny);
                   p->Reject(false, __func__);
                 });
 
@@ -15692,20 +15689,20 @@ already_AddRefed<mozilla::dom::Promise> 
                     Telemetry::LABELS_STORAGE_ACCESS_API_UI::
                         AllowAutomatically);
               }
 
               if (pr2 != PromptResult::Pending) {
                 MOZ_ASSERT_IF(pr2 != PromptResult::Granted,
                               pr2 == PromptResult::Denied);
                 if (pr2 == PromptResult::Granted) {
-                  ContentBlocking::StorageAccessPromptChoices choice =
-                      ContentBlocking::eAllow;
+                  AntiTrackingCommon::StorageAccessPromptChoices choice =
+                      AntiTrackingCommon::eAllow;
                   if (autoGrant) {
-                    choice = ContentBlocking::eAllowAutoGrant;
+                    choice = AntiTrackingCommon::eAllowAutoGrant;
                   }
                   if (!autoGrant) {
                     p->Resolve(choice, __func__);
                   } else {
                     sapr->MaybeDelayAutomaticGrants()->Then(
                         GetCurrentThreadSerialEventTarget(), __func__,
                         [p, choice] { p->Resolve(choice, __func__); },
                         [p] { p->Reject(false, __func__); });
@@ -15718,18 +15715,18 @@ already_AddRefed<mozilla::dom::Promise> 
 
               sapr->RequestDelayedTask(
                   inner->EventTargetFor(TaskCategory::Other),
                   ContentPermissionRequestBase::DelayedTaskType::Request);
             });
 
         return std::move(p);
       };
-      ContentBlocking::AllowAccessFor(
-          NodePrincipal(), inner, ContentBlockingNotifier::eStorageAccessAPI,
+      AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(
+          NodePrincipal(), inner, AntiTrackingCommon::eStorageAccessAPI,
           performFinalChecks)
           ->Then(
               GetCurrentThreadSerialEventTarget(), __func__,
               [outer, promise] {
                 // Step 10. Grant the document access to cookies and store
                 // that fact for
                 //          the purposes of future calls to
                 //          hasStorageAccess() and requestStorageAccess().
@@ -15782,17 +15779,17 @@ Document::AutomaticStorageAccessCanBeGra
         AutomaticStorageAccessCanBeGranted(NodePrincipal()), __func__);
   }
 
   return AutomaticStorageAccessGrantPromise::CreateAndReject(false, __func__);
 }
 
 bool Document::AutomaticStorageAccessCanBeGranted(nsIPrincipal* aPrincipal) {
   nsAutoCString prefix;
-  AntiTrackingUtils::CreateStoragePermissionKey(aPrincipal, prefix);
+  AntiTrackingCommon::CreateStoragePermissionKey(aPrincipal, prefix);
 
   nsPermissionManager* permManager = nsPermissionManager::GetInstance();
   if (NS_WARN_IF(!permManager)) {
     return false;
   }
 
   typedef nsTArray<RefPtr<nsIPermission>> Permissions;
   Permissions perms;
@@ -16042,21 +16039,21 @@ nsIPrincipal* Document::EffectiveStorage
     return NodePrincipal();
   }
 
   // Return our cached storage principal if one exists.
   if (mActiveStoragePrincipal) {
     return mActiveStoragePrincipal;
   }
 
-  // We use the lower-level ContentBlocking API here to ensure this
+  // We use the lower-level AntiTrackingCommon API here to ensure this
   // check doesn't send notifications.
   uint32_t rejectedReason = 0;
-  if (ContentBlocking::ShouldAllowAccessFor(inner, GetDocumentURI(),
-                                            &rejectedReason)) {
+  if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+          inner, GetDocumentURI(), &rejectedReason)) {
     return mActiveStoragePrincipal = NodePrincipal();
   }
 
   // Let's use the storage principal only if we need to partition the cookie
   // jar. When the permission is granted, access will be different and the
   // normal principal will be used.
   if (ShouldPartitionStorage(rejectedReason) &&
       !StoragePartitioningEnabled(
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -43,21 +43,21 @@
 #include "nsURIHashKey.h"
 #include "mozilla/ServoBindingTypes.h"
 #include "mozilla/UseCounter.h"
 #include "mozilla/WeakPtr.h"
 #include "Units.h"
 #include "nsContentListDeclarations.h"
 #include "nsExpirationTracker.h"
 #include "nsClassHashtable.h"
-#include "nsWindowSizes.h"
 #include "ReferrerInfo.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CallState.h"
 #include "mozilla/CORSMode.h"
+#include "mozilla/dom/ContentBlockingLog.h"
 #include "mozilla/dom/DispatcherTrait.h"
 #include "mozilla/dom/DocumentOrShadowRoot.h"
 #include "mozilla/dom/ViewportMetaData.h"
 #include "mozilla/HashTable.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/SegmentedVector.h"
 #include "mozilla/TimeStamp.h"
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -6,18 +6,17 @@
 
 // Needs to be first.
 #include "base/basictypes.h"
 
 #include "Navigator.h"
 #include "nsIXULAppInfo.h"
 #include "nsPluginArray.h"
 #include "nsMimeTypeArray.h"
-#include "mozilla/ContentBlocking.h"
-#include "mozilla/ContentBlockingNotifier.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/BodyExtractor.h"
 #include "mozilla/dom/FetchBinding.h"
 #include "mozilla/dom/File.h"
 #include "Geolocation.h"
 #include "nsIClassOfService.h"
 #include "nsIHttpProtocolHandler.h"
 #include "nsIContentPolicy.h"
@@ -523,23 +522,23 @@ bool Navigator::CookieEnabled() {
 
   if (!contentURI) {
     // Not a content, so technically can't set cookies, but let's
     // just return the default value.
     return cookieEnabled;
   }
 
   uint32_t rejectedReason = 0;
-  bool granted = ContentBlocking::ShouldAllowAccessFor(mWindow, contentURI,
-                                                       &rejectedReason);
+  bool granted = AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+      mWindow, contentURI, &rejectedReason);
 
-  ContentBlockingNotifier::OnDecision(
+  AntiTrackingCommon::NotifyBlockingDecision(
       mWindow,
-      granted ? ContentBlockingNotifier::BlockingDecision::eAllow
-              : ContentBlockingNotifier::BlockingDecision::eBlock,
+      granted ? AntiTrackingCommon::BlockingDecision::eAllow
+              : AntiTrackingCommon::BlockingDecision::eBlock,
       rejectedReason);
   return granted;
 }
 
 bool Navigator::OnLine() { return !NS_IsOffline(); }
 
 void Navigator::GetBuildID(nsAString& aBuildID, CallerType aCallerType,
                            ErrorResult& aRv) const {
--- a/dom/base/ThirdPartyUtil.cpp
+++ b/dom/base/ThirdPartyUtil.cpp
@@ -14,17 +14,16 @@
 #include "nsIHttpChannelInternal.h"
 #include "nsILoadContext.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIURI.h"
 #include "nsReadableUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/ClearOnShutdown.h"
-#include "mozilla/ContentBlocking.h"
 #include "mozilla/ContentBlockingAllowList.h"
 #include "mozilla/dom/Document.h"
 #include "mozilla/Logging.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/TextUtils.h"
 #include "mozilla/Unused.h"
 #include "nsGlobalWindowOuter.h"
 
@@ -489,23 +488,23 @@ ThirdPartyUtil::AnalyzeChannel(nsIChanne
     // foreign cookie behavior mode.
 
     // If the caller has requested third-party checks, we will only perform the
     // storage access check once we know we're in the third-party context.
     bool performStorageChecks =
         aRequireThirdPartyCheck ? result.contains(ThirdPartyAnalysis::IsForeign)
                                 : true;
     if (performStorageChecks &&
-        ContentBlocking::ShouldAllowAccessFor(aChannel, aURI ? aURI : uri.get(),
-                                              aRejectedReason)) {
+        AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+            aChannel, aURI ? aURI : uri.get(), aRejectedReason)) {
       result += ThirdPartyAnalysis::IsFirstPartyStorageAccessGranted;
     }
 
     if (aNotify && !result.contains(
                        ThirdPartyAnalysis::IsFirstPartyStorageAccessGranted)) {
-      ContentBlockingNotifier::OnDecision(
-          aChannel, ContentBlockingNotifier::BlockingDecision::eBlock,
+      AntiTrackingCommon::NotifyBlockingDecision(
+          aChannel, AntiTrackingCommon::BlockingDecision::eBlock,
           *aRejectedReason);
     }
   }
 
   return result;
 }
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -151,16 +151,17 @@ EXPORTS.mozilla.dom += [
     'CharacterData.h',
     'ChildIterator.h',
     'ChildProcessMessageManager.h',
     'ChromeMessageBroadcaster.h',
     'ChromeMessageSender.h',
     'ChromeNodeList.h',
     'ChromeUtils.h',
     'Comment.h',
+    'ContentBlockingLog.h',
     'ContentFrameMessageManager.h',
     'ContentProcessMessageManager.h',
     'CustomElementRegistry.h',
     'DirectionalityUtils.h',
     'DispatcherTrait.h',
     'DocGroup.h',
     'Document.h',
     'DocumentFragment.h',
@@ -274,16 +275,17 @@ UNIFIED_SOURCES += [
     'BorrowedAttrInfo.cpp',
     'CharacterData.cpp',
     'ChildIterator.cpp',
     'ChromeMessageBroadcaster.cpp',
     'ChromeMessageSender.cpp',
     'ChromeNodeList.cpp',
     'ChromeUtils.cpp',
     'Comment.cpp',
+    'ContentBlockingLog.cpp',
     'ContentFrameMessageManager.cpp',
     'ContentIterator.cpp',
     'ContentProcessMessageManager.cpp',
     'Crypto.cpp',
     'CustomElementRegistry.cpp',
     'DirectionalityUtils.cpp',
     'DispatcherTrait.cpp',
     'DocGroup.cpp',
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -28,16 +28,17 @@
 #include "Layers.h"
 #include "nsAppRunner.h"
 // nsNPAPIPluginInstance must be included before mozilla/dom/Document.h, which
 // is included in mozAutoDocUpdate.h.
 #include "nsNPAPIPluginInstance.h"
 #include "gfxDrawable.h"
 #include "ImageOps.h"
 #include "mozAutoDocUpdate.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/AutoTimelineMarker.h"
 #include "mozilla/BackgroundHangMonitor.h"
 #include "mozilla/Base64.h"
 #include "mozilla/BasePrincipal.h"
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -4395,18 +4395,18 @@ Storage* nsGlobalWindowInner::GetSession
 
     // SessionStorage is an ephemeral per-tab per-origin storage that only lives
     // as long as the tab is open, although it may survive browser restarts
     // thanks to the session store. So we interpret storage access differently
     // than we would for persistent per-origin storage like LocalStorage and so
     // it may be okay to provide SessionStorage even when we receive a value of
     // eDeny.
     //
-    // ContentBlocking::ShouldAllowAccessFor will return false for 3 main
-    // reasons.
+    // AntiTrackingCommon::IsFirstPartyStorageAccessGranted will return false
+    // for 3 main reasons.
     //
     // 1. Cookies are entirely blocked due to a per-origin permission
     // (nsICookiePermission::ACCESS_DENY for the top-level principal or this
     // window's principal) or the very broad BEHAVIOR_REJECT. This will return
     // eDeny with a reason of STATE_COOKIES_BLOCKED_BY_PERMISSION or
     // STATE_COOKIES_BLOCKED_ALL.
     //
     // 2. Third-party cookies are limited via BEHAVIOR_REJECT_FOREIGN and
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -16,18 +16,17 @@
 #include "nsScreen.h"
 #include "nsHistory.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsIDOMStorageManager.h"
 #include "nsIPermission.h"
 #include "nsIPermissionManager.h"
 #include "nsISecureBrowserUI.h"
 #include "nsIWebProgressListener.h"
-#include "mozilla/AntiTrackingUtils.h"
-#include "mozilla/ContentBlocking.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/BrowserChild.h"
 #include "mozilla/dom/BrowsingContextBinding.h"
 #include "mozilla/dom/ContentFrameMessageManager.h"
 #include "mozilla/dom/EventTarget.h"
 #include "mozilla/dom/LocalStorage.h"
 #include "mozilla/dom/LSObject.h"
 #include "mozilla/dom/Storage.h"
@@ -2477,18 +2476,18 @@ nsresult nsGlobalWindowOuter::SetNewDocu
       aDocument->CookieJarSettings()->GetRejectThirdPartyTrackers() &&
       nsContentUtils::IsThirdPartyWindowOrChannel(newInnerWindow, nullptr,
                                                   uri) &&
       nsContentUtils::IsThirdPartyTrackingResourceWindow(newInnerWindow)) {
     // Grant storage access by default if the first-party storage access
     // permission has been granted already.
     // Don't notify in this case, since we would be notifying the user
     // needlessly.
-    mHasStorageAccess =
-        ContentBlocking::ShouldAllowAccessFor(newInnerWindow, uri, nullptr);
+    mHasStorageAccess = AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+        newInnerWindow, uri, nullptr);
   }
 
   return NS_OK;
 }
 
 /* static */
 void nsGlobalWindowOuter::PrepareForProcessChange(JSObject* aProxy) {
   JS::Rooted<JSObject*> localProxy(RootingCx(), aProxy);
@@ -6863,17 +6862,17 @@ nsGlobalWindowOuter::Observe(nsISupports
     nsCOMPtr<nsIPermission> permission = do_QueryInterface(aSupports);
     if (!permission) {
       return NS_OK;
     }
     nsIPrincipal* principal = GetPrincipal();
     if (!principal) {
       return NS_OK;
     }
-    if (!AntiTrackingUtils::IsStorageAccessPermission(permission, principal)) {
+    if (!AntiTrackingCommon::IsStorageAccessPermission(permission, principal)) {
       return NS_OK;
     }
     if (!nsCRT::strcmp(aData, u"deleted")) {
       // The storage access permission was deleted.
       mHasStorageAccess = false;
       return NS_OK;
     }
     if (!nsCRT::strcmp(aData, u"added") || !nsCRT::strcmp(aData, u"changed")) {
@@ -7179,18 +7178,18 @@ void nsGlobalWindowOuter::MaybeAllowStor
   Document* doc = inner->GetDoc();
   if (!doc) {
     return;
   }
   nsCOMPtr<nsIPrincipal> principal = BasePrincipal::CreateContentPrincipal(
       aURI, doc->NodePrincipal()->OriginAttributesRef());
 
   // We don't care when the asynchronous work finishes here.
-  Unused << ContentBlocking::AllowAccessFor(principal, inner,
-                                            ContentBlockingNotifier::eOpener);
+  Unused << AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(
+      principal, inner, AntiTrackingCommon::eOpener);
 }
 
 //*****************************************************************************
 // nsGlobalWindowOuter: Helper Functions
 //*****************************************************************************
 
 already_AddRefed<nsIDocShellTreeOwner> nsPIDOMWindowOuter::GetTreeOwner() {
   // If there's no docShellAsItem, this window must have been closed,
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -8,16 +8,17 @@
 #define nsPIDOMWindow_h__
 
 #include "nsIDOMWindow.h"
 #include "mozIDOMWindow.h"
 
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 #include "mozilla/dom/EventTarget.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/TaskCategory.h"
 #include "js/TypeDecls.h"
 #include "nsRefPtrHashtable.h"
 
 // Only fired for inner windows.
 #define DOM_WINDOW_DESTROYED_TOPIC "dom-window-destroyed"
 #define DOM_WINDOW_FROZEN_TOPIC "dom-window-frozen"
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/BasicEvents.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventListenerManager.h"
-#include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/dom/WindowRootBinding.h"
 #include "nsCOMPtr.h"
 #include "nsWindowRoot.h"
 #include "nsPIDOMWindow.h"
 #include "nsPresContext.h"
 #include "nsLayoutCID.h"
 #include "nsContentCID.h"
 #include "nsString.h"
--- a/dom/ipc/BrowserChild.cpp
+++ b/dom/ipc/BrowserChild.cpp
@@ -4043,17 +4043,17 @@ BrowserChild::DoesWindowSupportProtected
           });
 }
 #endif
 
 void BrowserChild::NotifyContentBlockingEvent(
     uint32_t aEvent, nsIChannel* aChannel, bool aBlocked,
     const nsACString& aTrackingOrigin,
     const nsTArray<nsCString>& aTrackingFullHashes,
-    const Maybe<mozilla::ContentBlockingNotifier::StorageAccessGrantedReason>&
+    const Maybe<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>&
         aReason) {
   if (!IPCOpen()) {
     return;
   }
 
   Maybe<WebProgressData> webProgressData;
   RequestData requestData;
   nsresult rv = PrepareProgressListenerData(nullptr, aChannel, webProgressData,
--- a/dom/ipc/BrowserChild.h
+++ b/dom/ipc/BrowserChild.h
@@ -694,18 +694,17 @@ class BrowserChild final : public nsMess
 
   // Notify the content blocking event in the parent process. This sends an IPC
   // message to the BrowserParent in the parent. The BrowserParent will find the
   // top-level WindowGlobalParent and notify the event from it.
   void NotifyContentBlockingEvent(
       uint32_t aEvent, nsIChannel* aChannel, bool aBlocked,
       const nsACString& aTrackingOrigin,
       const nsTArray<nsCString>& aTrackingFullHashes,
-      const Maybe<ContentBlockingNotifier::StorageAccessGrantedReason>&
-          aReason);
+      const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason);
 
  protected:
   virtual ~BrowserChild();
 
   mozilla::ipc::IPCResult RecvDestroy();
 
   mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive);
 
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -2690,17 +2690,17 @@ mozilla::ipc::IPCResult BrowserParent::R
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult BrowserParent::RecvNotifyContentBlockingEvent(
     const uint32_t& aEvent, const RequestData& aRequestData,
     const bool aBlocked, const nsACString& aTrackingOrigin,
     nsTArray<nsCString>&& aTrackingFullHashes,
-    const Maybe<mozilla::ContentBlockingNotifier::StorageAccessGrantedReason>&
+    const Maybe<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>&
         aReason) {
   MOZ_ASSERT(aRequestData.elapsedLoadTimeMS().isNothing());
 
   RefPtr<BrowsingContext> bc = GetBrowsingContext();
 
   if (!bc || bc->IsDiscarded()) {
     return IPC_OK();
   }
--- a/dom/ipc/BrowserParent.h
+++ b/dom/ipc/BrowserParent.h
@@ -312,17 +312,17 @@ class BrowserParent final : public PBrow
       const Maybe<WebProgressData>& aWebProgressData,
       const RequestData& aRequestData, const uint32_t aState,
       const Maybe<WebProgressSecurityChangeData>& aSecurityChangeData);
 
   mozilla::ipc::IPCResult RecvNotifyContentBlockingEvent(
       const uint32_t& aEvent, const RequestData& aRequestData,
       const bool aBlocked, const nsACString& aTrackingOrigin,
       nsTArray<nsCString>&& aTrackingFullHashes,
-      const Maybe<mozilla::ContentBlockingNotifier::StorageAccessGrantedReason>&
+      const Maybe<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>&
           aReason);
 
   mozilla::ipc::IPCResult RecvNavigationFinished();
 
   bool GetWebProgressListener(nsIBrowser** aOutBrowser,
                               nsIWebProgress** aOutManager,
                               nsIWebProgressListener** aOutListener);
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -35,20 +35,19 @@
 #include "MMPrinter.h"
 #include "PreallocatedProcessManager.h"
 #include "ProcessPriorityManager.h"
 #include "SandboxHal.h"
 #include "SourceSurfaceRawData.h"
 #include "URIUtils.h"
 #include "gfxPlatform.h"
 #include "gfxPlatformFontList.h"
-#include "mozilla/ContentBlocking.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/BenchmarkStorageParent.h"
-#include "mozilla/ContentBlockingUserInteraction.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Components.h"
 #include "mozilla/DataStorage.h"
 #include "mozilla/GlobalStyleSheetCache.h"
 #include "mozilla/HangDetails.h"
 #include "mozilla/LoginReputationIPC.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/PerformanceMetricsCollector.h"
@@ -5817,33 +5816,33 @@ mozilla::ipc::IPCResult ContentParent::R
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvFirstPartyStorageAccessGrantedForOrigin(
     const Principal& aParentPrincipal, const Principal& aTrackingPrincipal,
     const nsCString& aTrackingOrigin, const int& aAllowMode,
     FirstPartyStorageAccessGrantedForOriginResolver&& aResolver) {
-  ContentBlocking::SaveAccessForOriginOnParentProcess(
-      aParentPrincipal, aTrackingPrincipal, aTrackingOrigin, aAllowMode)
-      ->Then(
-          GetCurrentThreadSerialEventTarget(), __func__,
-          [aResolver = std::move(aResolver)](
-              ContentBlocking::ParentAccessGrantPromise::ResolveOrRejectValue&&
-                  aValue) {
-            bool success =
-                aValue.IsResolve() && NS_SUCCEEDED(aValue.ResolveValue());
-            aResolver(success);
-          });
+  AntiTrackingCommon::
+      SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(
+          aParentPrincipal, aTrackingPrincipal, aTrackingOrigin, aAllowMode)
+          ->Then(GetCurrentThreadSerialEventTarget(), __func__,
+                 [aResolver = std::move(aResolver)](
+                     AntiTrackingCommon::FirstPartyStorageAccessGrantPromise::
+                         ResolveOrRejectValue&& aValue) {
+                   bool success = aValue.IsResolve() &&
+                                  NS_SUCCEEDED(aValue.ResolveValue());
+                   aResolver(success);
+                 });
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult ContentParent::RecvStoreUserInteractionAsPermission(
     const Principal& aPrincipal) {
-  ContentBlockingUserInteraction::Observe(aPrincipal);
+  AntiTrackingCommon::StoreUserInteractionFor(aPrincipal);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult ContentParent::RecvNotifyMediaStateChanged(
     const MaybeDiscarded<BrowsingContext>& aContext,
     ControlledMediaState aState) {
   if (aContext.IsNullOrDiscarded()) {
     return IPC_OK();
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -90,17 +90,17 @@ using mozilla::a11y::IAccessibleHolder f
 using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
 using mozilla::dom::EffectsInfo from "mozilla/dom/TabMessageUtils.h";
 using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
 using mozilla::ScrollAxis from "mozilla/PresShellForwards.h";
 using mozilla::ScrollFlags from "mozilla/PresShellForwards.h";
 using struct InputFormData from "mozilla/dom/SessionStoreMessageUtils.h";
 using struct CollectedInputDataValue from "mozilla/dom/SessionStoreMessageUtils.h";
 using refcounted class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
-using mozilla::ContentBlockingNotifier::StorageAccessGrantedReason from "mozilla/ContentBlockingNotifier.h";
+using mozilla::AntiTrackingCommon::StorageAccessGrantedReason from "mozilla/AntiTrackingCommon.h";
 using CallerType from "mozilla/dom/BindingDeclarations.h";
 
 namespace mozilla {
 namespace dom {
 
 struct WebProgressData
 {
   bool isTopLevel;
--- a/dom/ipc/WindowGlobalParent.cpp
+++ b/dom/ipc/WindowGlobalParent.cpp
@@ -306,17 +306,17 @@ const nsAString& WindowGlobalParent::Get
 
   return VoidString();
 }
 
 void WindowGlobalParent::NotifyContentBlockingEvent(
     uint32_t aEvent, nsIRequest* aRequest, bool aBlocked,
     const nsACString& aTrackingOrigin,
     const nsTArray<nsCString>& aTrackingFullHashes,
-    const Maybe<ContentBlockingNotifier::StorageAccessGrantedReason>& aReason) {
+    const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason) {
   MOZ_ASSERT(NS_IsMainThread());
   DebugOnly<bool> isCookiesBlockedTracker =
       aEvent == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
       aEvent == nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER;
   MOZ_ASSERT_IF(aBlocked, aReason.isNothing());
   MOZ_ASSERT_IF(!isCookiesBlockedTracker, aReason.isNothing());
   MOZ_ASSERT_IF(isCookiesBlockedTracker && !aBlocked, aReason.isSome());
   MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
--- a/dom/ipc/WindowGlobalParent.h
+++ b/dom/ipc/WindowGlobalParent.h
@@ -2,28 +2,28 @@
 /* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_WindowGlobalParent_h
 #define mozilla_dom_WindowGlobalParent_h
 
-#include "mozilla/ContentBlockingLog.h"
-#include "mozilla/ContentBlockingNotifier.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/dom/DOMRect.h"
 #include "mozilla/dom/PWindowGlobalParent.h"
 #include "mozilla/dom/BrowserParent.h"
 #include "mozilla/dom/WindowContext.h"
 #include "nsRefPtrHashtable.h"
 #include "nsWrapperCache.h"
 #include "nsISupports.h"
 #include "mozilla/dom/WindowGlobalActor.h"
 #include "mozilla/dom/CanonicalBrowsingContext.h"
+#include "mozilla/dom/ContentBlockingLog.h"
 
 class nsIPrincipal;
 class nsIURI;
 class nsFrameLoader;
 
 namespace mozilla {
 
 namespace gfx {
@@ -141,18 +141,18 @@ class WindowGlobalParent final : public 
   nsIGlobalObject* GetParentObject();
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 
   void NotifyContentBlockingEvent(
       uint32_t aEvent, nsIRequest* aRequest, bool aBlocked,
       const nsACString& aTrackingOrigin,
       const nsTArray<nsCString>& aTrackingFullHashes,
-      const Maybe<ContentBlockingNotifier::StorageAccessGrantedReason>&
-          aReason = Nothing());
+      const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason =
+          Nothing());
 
   ContentBlockingLog* GetContentBlockingLog() { return &mContentBlockingLog; }
 
  protected:
   const nsAString& GetRemoteType() override;
   JSWindowActor::Type GetSide() override { return JSWindowActor::Type::Parent; }
 
   // IPC messages
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -14,17 +14,16 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/ErrorNames.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
-#include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/StaticPrefs_media.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/Telemetry.h"
 #include "nsContentUtils.h"
 #include "nsINetworkLinkService.h"
 #include "nsIObserverService.h"
 #include "nsPrintfCString.h"
 #include "nsProxyRelease.h"
--- a/dom/reporting/CrashReport.cpp
+++ b/dom/reporting/CrashReport.cpp
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/CrashReport.h"
 
 #include "mozilla/dom/Navigator.h"
 #include "mozilla/dom/ReportingHeader.h"
 #include "mozilla/dom/ReportDeliver.h"
-#include "mozilla/JSONWriter.h"
 #include "nsIPrincipal.h"
 #include "nsIURIMutator.h"
 #include "nsString.h"
 
 namespace mozilla {
 namespace dom {
 
 struct StringWriteFunc : public JSONWriteFunc {
--- a/dom/security/ReferrerInfo.cpp
+++ b/dom/security/ReferrerInfo.cpp
@@ -13,18 +13,18 @@
 #include "nsIURL.h"
 
 #include "nsWhitespaceTokenizer.h"
 #include "nsAlgorithm.h"
 #include "nsContentUtils.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "ReferrerInfo.h"
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/BasePrincipal.h"
-#include "mozilla/ContentBlocking.h"
 #include "mozilla/net/CookieJarSettings.h"
 #include "mozilla/net/HttpBaseChannel.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/StaticPrefs_network.h"
 #include "mozilla/StyleSheet.h"
 
 static mozilla::LazyLogModule gReferrerInfoLog("ReferrerInfo");
 #define LOG(msg) MOZ_LOG(gReferrerInfoLog, mozilla::LogLevel::Debug, msg)
@@ -200,17 +200,18 @@ ReferrerPolicy ReferrerInfo::GetDefaultR
     Unused << loadInfo->GetCookieJarSettings(getter_AddRefs(cjs));
   }
   if (!cjs) {
     cjs = net::CookieJarSettings::Create();
   }
   if (aChannel && aURI && cjs->GetRejectThirdPartyTrackers()) {
     uint32_t rejectedReason = 0;
     thirdPartyTrackerIsolated =
-        !ContentBlocking::ShouldAllowAccessFor(aChannel, aURI, &rejectedReason);
+        !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+            aChannel, aURI, &rejectedReason);
     // Here we intentionally do not notify about the rejection reason, if any
     // in order to avoid this check to have any visible side-effects (e.g. a
     // web console report.)
   }
 
   uint32_t defaultToUse;
   if (thirdPartyTrackerIsolated) {
     if (privateBrowsing) {
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -20,16 +20,17 @@
 
 #include <algorithm>
 #include "mozilla/ipc/BackgroundChild.h"
 #include "GeckoProfiler.h"
 #include "jsfriendapi.h"
 #include "js/ContextOptions.h"
 #include "js/LocaleSensitive.h"
 #include "mozilla/AbstractThread.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CycleCollectedJSContext.h"
 #include "mozilla/CycleCollectedJSRuntime.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/AtomList.h"
--- a/extensions/permissions/nsPermissionManager.cpp
+++ b/extensions/permissions/nsPermissionManager.cpp
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Attributes.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/BasePrincipal.h"
-#include "mozilla/ContentBlockingUserInteraction.h"
 #include "mozilla/ContentPrincipal.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Pair.h"
 #include "mozilla/Services.h"
 #include "mozilla/SystemGroup.h"
 #include "nsPermissionManager.h"
 #include "nsPermission.h"
 #include "nsCRT.h"
--- a/image/ImageCacheKey.cpp
+++ b/image/ImageCacheKey.cpp
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ImageCacheKey.h"
 
 #include <utility>
 
-#include "mozilla/ContentBlocking.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/StorageAccess.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/Document.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/ServiceWorkerManager.h"
 #include "nsContentUtils.h"
@@ -180,17 +180,17 @@ nsCString ImageCacheKey::GetTopLevelBase
   }
 
   // Another scenario is if this image is a 3rd party resource loaded by a
   // first party context. In this case, we should check if the nsIChannel has
   // been marked as tracking resource, but we don't have the channel yet at
   // this point.  The best approach here is to be conservative: if we are sure
   // that the permission is granted, let's return 0. Otherwise, let's make a
   // unique image cache per the top-level document eTLD+1.
-  if (!ContentBlocking::ApproximateAllowAccessForWithoutChannel(
+  if (!AntiTrackingCommon::MaybeIsFirstPartyStorageAccessGrantedFor(
           aDocument->GetInnerWindow(), aURI)) {
     nsPIDOMWindowOuter* top =
         aDocument->GetInnerWindow()->GetInProcessScriptableTop();
     nsPIDOMWindowInner* topInner = top ? top->GetCurrentInnerWindow() : nullptr;
     if (!topInner) {
       return aDocument
           ->GetBaseDomain();  // because we don't have anything better!
     }
--- a/image/imgFrame.cpp
+++ b/image/imgFrame.cpp
@@ -22,17 +22,16 @@
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/gfx/Tools.h"
 #include "mozilla/gfx/SourceSurfaceRawData.h"
 #include "mozilla/image/RecyclingSourceSurface.h"
 #include "mozilla/layers/SourceSurfaceSharedData.h"
 #include "mozilla/layers/SourceSurfaceVolatileData.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
-#include "mozilla/StaticPrefs_browser.h"
 #include "nsMargin.h"
 #include "nsRefreshDriver.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 
 using namespace gfx;
 
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -23,17 +23,16 @@
 #include "nsPIDOMWindow.h"
 #include "nsPrintfCString.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Services.h"
 #ifdef FUZZING
 #  include "mozilla/StaticPrefs_fuzzing.h"
 #endif
-#include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/StaticPrefs_javascript.h"
 #include "mozilla/dom/ScriptSettings.h"
 
 #include "nsContentUtils.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsCycleCollectionNoteRootCallback.h"
 #include "nsCycleCollector.h"
 #include "jsapi.h"
--- a/layout/style/GeckoBindings.cpp
+++ b/layout/style/GeckoBindings.cpp
@@ -50,17 +50,16 @@
 #include "mozilla/EventStates.h"
 #include "mozilla/FontPropertyTypes.h"
 #include "mozilla/Keyframe.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ServoElementSnapshot.h"
 #include "mozilla/ShadowParts.h"
 #include "mozilla/StaticPresData.h"
-#include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/StaticPrefs_layout.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/SizeOfState.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoTraversalStatistics.h"
 #include "mozilla/Telemetry.h"
--- a/media/webrtc/signaling/src/peerconnection/RTCStatsReport.h
+++ b/media/webrtc/signaling/src/peerconnection/RTCStatsReport.h
@@ -13,17 +13,16 @@
 #include "nsPIDOMWindow.h"               // nsPIDOMWindowInner
 #include "mozilla/dom/ScriptSettings.h"  // AutoEntryScript
 #include "nsIGlobalObject.h"
 #include "js/RootingAPI.h"  // JS::Rooted
 #include "js/Value.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/UniquePtr.h"
 #include "prtime.h"  // PR_Now
-#include "mozilla/MozPromise.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/RTCStatsReportBinding.h"  // RTCStatsCollection
 
 namespace mozilla {
 namespace dom {
 
 class RTCStatsTimestampMaker {
  public:
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // HttpLog.h should generally be included first
 #include "HttpLog.h"
 
 #include "nsNetUtil.h"
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Encoding.h"
 #include "mozilla/LoadContext.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/StaticPrefs_network.h"
 #include "mozilla/StaticPrefs_privacy.h"
--- a/netwerk/cookie/CookieServiceChild.cpp
+++ b/netwerk/cookie/CookieServiceChild.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/net/CookieServiceChild.h"
 #include "mozilla/net/NeckoChannelParams.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/StaticPrefs_network.h"
 #include "mozilla/SystemGroup.h"
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=2 ts=8 et tw=80 : */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ClearOnShutdown.h"
-#include "mozilla/ContentBlockingNotifier.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Printf.h"
 #include "mozilla/StorageAccess.h"
 #include "mozilla/Unused.h"
 
 #include "mozilla/net/CookieJarSettings.h"
 #include "mozilla/net/CookieServiceChild.h"
@@ -2260,36 +2260,35 @@ void nsCookieService::SetCookieStringInt
   while (SetCookieInternal(aHostURI, key, requireHostMatch, cookieStatus,
                            aCookieHeader, serverTime, aFromHttp, aChannel)) {
     // document.cookie can only set one cookie at a time
     if (!aFromHttp) break;
   }
 }
 
 void nsCookieService::NotifyAccepted(nsIChannel* aChannel) {
-  ContentBlockingNotifier::OnDecision(
-      aChannel, ContentBlockingNotifier::BlockingDecision::eAllow, 0);
+  AntiTrackingCommon::NotifyBlockingDecision(
+      aChannel, AntiTrackingCommon::BlockingDecision::eAllow, 0);
 }
 
 // notify observers that a cookie was rejected due to the users' prefs.
 void nsCookieService::NotifyRejected(nsIURI* aHostURI, nsIChannel* aChannel,
                                      uint32_t aRejectedReason,
                                      CookieOperation aOperation) {
   if (aOperation == OPERATION_WRITE) {
     nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     if (os) {
       os->NotifyObservers(aHostURI, "cookie-rejected", nullptr);
     }
   } else {
     MOZ_ASSERT(aOperation == OPERATION_READ);
   }
 
-  ContentBlockingNotifier::OnDecision(
-      aChannel, ContentBlockingNotifier::BlockingDecision::eBlock,
-      aRejectedReason);
+  AntiTrackingCommon::NotifyBlockingDecision(
+      aChannel, AntiTrackingCommon::BlockingDecision::eBlock, aRejectedReason);
 }
 
 // notify observers that the cookie list changed. there are five possible
 // values for aData:
 // "deleted" means a cookie was deleted. aSubject is the deleted cookie.
 // "added"   means a cookie was added. aSubject is the added cookie.
 // "changed" means a cookie was altered. aSubject is the new cookie.
 // "cleared" means the entire cookie list was cleared. aSubject is null.
--- a/netwerk/ipc/DocumentLoadListener.cpp
+++ b/netwerk/ipc/DocumentLoadListener.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=2 ts=8 et tw=80 : */
 
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DocumentLoadListener.h"
-#include "mozilla/AntiTrackingUtils.h"
 #include "mozilla/ContentBlockingAllowList.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/MozPromiseInlines.h"  // For MozPromise::FromDomPromise
 #include "mozilla/dom/CanonicalBrowsingContext.h"
 #include "mozilla/dom/ClientChannelHelper.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentProcessManager.h"
@@ -377,17 +376,17 @@ bool DocumentLoadListener::Open(
           aLoadState, loadInfo, mParentChannelListener, nullptr, attrs,
           aLoadFlags, aLoadType, aCacheKey, aIsActive, aIsTopLevelDoc,
           aHasNonEmptySandboxingFlags, *aRv, getter_AddRefs(mChannel))) {
     mParentChannelListener = nullptr;
     return false;
   }
 
   nsCOMPtr<nsIURI> uriBeingLoaded =
-      AntiTrackingUtils::MaybeGetDocumentURIBeingLoaded(mChannel);
+      AntiTrackingCommon::MaybeGetDocumentURIBeingLoaded(mChannel);
   CanonicalBrowsingContext* bc = GetBrowsingContext();
   RefPtr<WindowGlobalParent> topWindow =
       GetTopWindowExcludingExtensionAccessibleContentFrames(bc, uriBeingLoaded);
 
   RefPtr<HttpBaseChannel> httpBaseChannel = do_QueryObject(mChannel, aRv);
   if (httpBaseChannel) {
     nsCOMPtr<nsIURI> topWindowURI;
     nsCOMPtr<nsIPrincipal> contentBlockingAllowListPrincipal;
--- a/netwerk/protocol/http/ClassifierDummyChannel.cpp
+++ b/netwerk/protocol/http/ClassifierDummyChannel.cpp
@@ -2,17 +2,17 @@
 /* vim: set sw=2 ts=8 et tw=80 : */
 
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ClassifierDummyChannel.h"
 
-#include "mozilla/ContentBlocking.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/ClassifierDummyChannelChild.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "nsContentSecurityManager.h"
 #include "nsIChannel.h"
 #include "nsIURI.h"
@@ -55,17 +55,18 @@ ClassifierDummyChannel::StorageAllowed(
 
     if (!ClassifierDummyChannelChild::Create(httpChannel, uri, aCallback)) {
       return eStorageDenied;
     }
 
     return eAsyncNeeded;
   }
 
-  if (ContentBlocking::ShouldAllowAccessFor(httpChannel, uri, nullptr)) {
+  if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel, uri,
+                                                              nullptr)) {
     return eStorageGranted;
   }
 
   return eStorageDenied;
 }
 
 NS_IMPL_ADDREF(ClassifierDummyChannel)
 NS_IMPL_RELEASE(ClassifierDummyChannel)
--- a/netwerk/protocol/http/ClassifierDummyChannelChild.cpp
+++ b/netwerk/protocol/http/ClassifierDummyChannelChild.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ClassifierDummyChannelChild.h"
-#include "mozilla/ContentBlocking.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "nsIURI.h"
 
 namespace mozilla {
 namespace net {
 
 /* static */
@@ -81,16 +80,16 @@ mozilla::ipc::IPCResult ClassifierDummyC
     return IPC_OK();
   }
 
   nsCOMPtr<nsIHttpChannel> channel = std::move(mChannel);
 
   RefPtr<HttpBaseChannel> httpChannel = do_QueryObject(channel);
   httpChannel->AddClassificationFlags(aClassificationFlags, mIsThirdParty);
 
-  bool storageGranted =
-      ContentBlocking::ShouldAllowAccessFor(httpChannel, mURI, nullptr);
+  bool storageGranted = AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+      httpChannel, mURI, nullptr);
   mCallback(storageGranted);
   return IPC_OK();
 }
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -10,17 +10,17 @@
 
 #include <algorithm>
 #include <utility>
 
 #include "HttpBaseChannel.h"
 #include "HttpLog.h"
 #include "LoadInfo.h"
 #include "mozIThirdPartyUtil.h"
-#include "mozilla/AntiTrackingUtils.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/BinarySearch.h"
 #include "mozilla/ConsoleReportCollector.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/InputStreamLengthHelper.h"
 #include "mozilla/NullPrincipal.h"
 #include "mozilla/Services.h"
 #include "mozilla/Telemetry.h"
@@ -2009,17 +2009,17 @@ HttpBaseChannel::SetTopWindowURIIfUnknow
 
   mTopWindowURI = aTopWindowURI;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpBaseChannel::GetTopWindowURI(nsIURI** aTopWindowURI) {
   nsCOMPtr<nsIURI> uriBeingLoaded =
-      AntiTrackingUtils::MaybeGetDocumentURIBeingLoaded(this);
+      AntiTrackingCommon::MaybeGetDocumentURIBeingLoaded(this);
   return GetTopWindowURI(uriBeingLoaded, aTopWindowURI);
 }
 
 nsresult HttpBaseChannel::GetTopWindowURI(nsIURI* aURIBeingLoaded,
                                           nsIURI** aTopWindowURI) {
   nsresult rv = NS_OK;
   nsCOMPtr<mozIThirdPartyUtil> util;
   // Only compute the top window URI once. In e10s, this must be computed in the
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -5,16 +5,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // HttpLog.h should generally be included first
 #include "HttpLog.h"
 
 #include "nsHttp.h"
 #include "nsICacheEntry.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/DocGroup.h"
 #include "mozilla/dom/ServiceWorkerUtils.h"
 #include "mozilla/dom/BrowserChild.h"
 #include "mozilla/dom/TabGroup.h"
 #include "mozilla/extensions/StreamFilterParent.h"
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -50,19 +50,19 @@
 #include "mozilla/TimeStamp.h"
 #include "nsError.h"
 #include "nsPrintfCString.h"
 #include "nsAlgorithm.h"
 #include "nsQueryObject.h"
 #include "nsThreadUtils.h"
 #include "GeckoProfiler.h"
 #include "nsIConsoleService.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/BasePrincipal.h"
-#include "mozilla/ContentBlocking.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/StaticPrefs_fission.h"
 #include "mozilla/StaticPrefs_network.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "mozilla/StaticPrefs_security.h"
@@ -4020,17 +4020,18 @@ nsresult nsHttpChannel::OpenCacheEntry(b
 }
 
 bool nsHttpChannel::IsIsolated() {
   if (mHasBeenIsolatedChecked) {
     return mIsIsolated;
   }
   mIsIsolated = StaticPrefs::browser_cache_cache_isolation() ||
                 (IsThirdPartyTrackingResource() &&
-                 !ContentBlocking::ShouldAllowAccessFor(this, mURI, nullptr));
+                 !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+                     this, mURI, nullptr));
   mHasBeenIsolatedChecked = true;
   return mIsIsolated;
 }
 
 const nsCString& nsHttpChannel::GetTopWindowOrigin() {
   if (mTopWindowOriginComputed) {
     return mTopWindowOrigin;
   }
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -58,17 +58,17 @@
 #include "mozilla/net/HttpConnectionMgrParent.h"
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/net/NeckoParent.h"
 #include "mozilla/net/RequestContextService.h"
 #include "mozilla/net/SocketProcessParent.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
-#include "mozilla/AntiTrackingRedirectHeuristic.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/LazyIdleThread.h"
 #include "mozilla/SyncRunnable.h"
 
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/Navigator.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/network/Connection.h"
@@ -833,17 +833,17 @@ nsresult nsHttpHandler::AsyncOnChannelRe
   nsCOMPtr<nsIURI> oldURI;
   oldChan->GetURI(getter_AddRefs(oldURI));
   MOZ_ASSERT(oldURI);
 
   nsCOMPtr<nsIURI> newURI;
   newChan->GetURI(getter_AddRefs(newURI));
   MOZ_ASSERT(newURI);
 
-  AntiTrackingRedirectHeuristic(oldChan, oldURI, newChan, newURI);
+  AntiTrackingCommon::RedirectHeuristic(oldChan, oldURI, newChan, newURI);
 
   // TODO E10S This helper has to be initialized on the other process
   RefPtr<nsAsyncRedirectVerifyHelper> redirectCallbackHelper =
       new nsAsyncRedirectVerifyHelper();
 
   return redirectCallbackHelper->Init(oldChan, newChan, flags,
                                       mainThreadEventTarget);
 }
--- a/netwerk/url-classifier/UrlClassifierCommon.cpp
+++ b/netwerk/url-classifier/UrlClassifierCommon.cpp
@@ -2,20 +2,19 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/net/UrlClassifierCommon.h"
 
 #include "ClassifierDummyChannel.h"
-#include "mozilla/AntiTrackingUtils.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/ContentBlockingAllowList.h"
-#include "mozilla/ContentBlockingNotifier.h"
 #include "mozilla/dom/WindowGlobalParent.h"
 #include "mozilla/net/HttpBaseChannel.h"
 #include "mozilla/net/UrlClassifierFeatureFactory.h"
 #include "mozilla/StaticPrefs_network.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "mozilla/StaticPrefs_channelclassifier.h"
 #include "mozIThirdPartyUtil.h"
 #include "nsContentUtils.h"
@@ -207,33 +206,33 @@ nsresult UrlClassifierCommon::SetBlocked
       parentChannel->SetClassifierMatchedInfo(aList, aProvider, aFullHash);
     }
 
     unsigned state =
         UrlClassifierFeatureFactory::GetClassifierBlockingEventCode(aErrorCode);
     if (!state) {
       state = nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
     }
-    ContentBlockingNotifier::OnEvent(channel, state);
+    AntiTrackingCommon::NotifyContentBlockingEvent(channel, state);
 
     return NS_OK;
   }
 
   // TODO: ReportToConsole is called in the child process,
   // If nsContentUtils::ReportToConsole is not fission compatiable(cannot report
   // to correct top-level window), we need to do this in the parent process
   // instead (find the top-level window in the parent and send an IPC to child
   // processes to report console).
   nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
   if (NS_WARN_IF(!thirdPartyUtil)) {
     return NS_OK;
   }
 
   nsCOMPtr<nsIURI> uriBeingLoaded =
-      AntiTrackingUtils::MaybeGetDocumentURIBeingLoaded(channel);
+      AntiTrackingCommon::MaybeGetDocumentURIBeingLoaded(channel);
   nsCOMPtr<mozIDOMWindowProxy> win;
   rv = thirdPartyUtil->GetTopWindowForChannel(channel, uriBeingLoaded,
                                               getter_AddRefs(win));
   NS_ENSURE_SUCCESS(rv, NS_OK);
   auto* pwin = nsPIDOMWindowOuter::From(win);
   nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
   if (!docShell) {
     return NS_OK;
@@ -439,17 +438,17 @@ void UrlClassifierCommon::AnnotateChanne
 
   // We consider valid tracking flags (based on the current strict vs basic list
   // prefs) and cryptomining (which is not considered as tracking).
   bool validClassificationFlags =
       IsTrackingClassificationFlag(aClassificationFlags) ||
       IsCryptominingClassificationFlag(aClassificationFlags);
 
   if (validClassificationFlags && isThirdPartyWithTopLevelWinURI) {
-    ContentBlockingNotifier::OnEvent(aChannel, aLoadingState);
+    AntiTrackingCommon::NotifyContentBlockingEvent(aChannel, aLoadingState);
   }
 
   if (isThirdPartyWithTopLevelWinURI &&
       StaticPrefs::privacy_trackingprotection_lower_network_priority()) {
     LowerPriorityHelper(aChannel);
   }
 }
 
--- a/netwerk/url-classifier/UrlClassifierCommon.h
+++ b/netwerk/url-classifier/UrlClassifierCommon.h
@@ -2,18 +2,18 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_net_UrlClassifierCommon_h
 #define mozilla_net_UrlClassifierCommon_h
 
-#include "mozilla/Logging.h"
 #include "nsString.h"
+#include "mozilla/AntiTrackingCommon.h"
 
 #include <vector>
 
 class nsIChannel;
 class nsIURI;
 
 #define UC_LOG(args) MOZ_LOG(UrlClassifierCommon::sLog, LogLevel::Info, args)
 #define UC_LOG_DEBUG(args) \
--- a/netwerk/url-classifier/UrlClassifierFeatureBase.h
+++ b/netwerk/url-classifier/UrlClassifierFeatureBase.h
@@ -6,16 +6,17 @@
 
 #ifndef mozilla_net_UrlClassifierFeatureBase_h
 #define mozilla_net_UrlClassifierFeatureBase_h
 
 #include "nsIUrlClassifierFeature.h"
 #include "nsIUrlClassifierSkipListService.h"
 #include "nsTArray.h"
 #include "nsString.h"
+#include "mozilla/AntiTrackingCommon.h"
 
 namespace mozilla {
 namespace net {
 
 class UrlClassifierFeatureBase : public nsIUrlClassifierFeature,
                                  public nsIUrlClassifierSkipListObserver {
  public:
   NS_DECL_ISUPPORTS
--- a/netwerk/url-classifier/UrlClassifierFeatureCryptominingAnnotation.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureCryptominingAnnotation.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "UrlClassifierFeatureCryptominingAnnotation.h"
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "nsIClassifiedChannel.h"
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 namespace net {
 
--- a/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "UrlClassifierFeatureCryptominingProtection.h"
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 namespace net {
 
--- a/netwerk/url-classifier/UrlClassifierFeatureFingerprintingAnnotation.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureFingerprintingAnnotation.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "UrlClassifierFeatureFingerprintingAnnotation.h"
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "nsIClassifiedChannel.h"
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 namespace net {
 
--- a/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "UrlClassifierFeatureFingerprintingProtection.h"
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 namespace net {
 
--- a/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingAnnotation.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingAnnotation.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "UrlClassifierFeatureSocialTrackingAnnotation.h"
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "nsIClassifiedChannel.h"
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 namespace net {
 
--- a/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "UrlClassifierFeatureSocialTrackingProtection.h"
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 namespace net {
 
--- a/netwerk/url-classifier/UrlClassifierFeatureTrackingAnnotation.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureTrackingAnnotation.cpp
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "UrlClassifierFeatureTrackingAnnotation.h"
 
 #include "Classifier.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/Logging.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "nsIClassifiedChannel.h"
 #include "nsContentUtils.h"
 
 namespace mozilla {
--- a/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp
+++ b/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "UrlClassifierFeatureTrackingProtection.h"
 
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/net/UrlClassifierCommon.h"
 #include "nsContentUtils.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsILoadContext.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 namespace net {
rename from toolkit/components/antitracking/ContentBlocking.cpp
rename to toolkit/components/antitracking/AntiTrackingCommon.cpp
--- a/toolkit/components/antitracking/ContentBlocking.cpp
+++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp
@@ -1,48 +1,73 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "AntiTrackingLog.h"
-#include "ContentBlocking.h"
-#include "AntiTrackingUtils.h"
-#include "TemporaryAccessGrantObserver.h"
+#include "AntiTrackingCommon.h"
 
 #include "mozilla/ContentBlockingAllowList.h"
-#include "mozilla/ContentBlockingUserInteraction.h"
 #include "mozilla/dom/BrowsingContext.h"
+#include "mozilla/dom/CanonicalBrowsingContext.h"
 #include "mozilla/dom/ContentChild.h"
+#include "mozilla/dom/WindowGlobalParent.h"
+#include "mozilla/net/UrlClassifierCommon.h"
+#include "mozilla/ipc/MessageChannel.h"
+#include "mozilla/AbstractThread.h"
+#include "mozilla/HashFunctions.h"
+#include "mozilla/IntegerPrintfMacros.h"
+#include "mozilla/Logging.h"
+#include "mozilla/MruCache.h"
+#include "mozilla/Pair.h"
+#include "mozilla/ScopeExit.h"
+#include "mozilla/StaticPrefs_extensions.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "mozIThirdPartyUtil.h"
 #include "nsContentUtils.h"
 #include "nsGlobalWindowInner.h"
 #include "nsIClassifiedChannel.h"
 #include "nsICookiePermission.h"
 #include "nsICookieService.h"
+#include "nsIDocShell.h"
+#include "nsIHttpChannelInternal.h"
+#include "nsIParentChannel.h"
 #include "nsIPermission.h"
+#include "nsPermissionManager.h"
 #include "nsIPrincipal.h"
+#include "nsIRedirectHistoryEntry.h"
+#include "nsIScriptError.h"
 #include "nsIURI.h"
+#include "nsIURIFixup.h"
 #include "nsIWebProgressListener.h"
-#include "nsPermissionManager.h"
+#include "nsNetUtil.h"
+#include "nsPIDOMWindow.h"
+#include "nsPrintfCString.h"
 #include "nsScriptSecurityManager.h"
+#include "nsSandboxFlags.h"
+#include "prtime.h"
+
+#define ANTITRACKING_PERM_KEY "3rdPartyStorage"
+#define ANTITRACKING_CONSOLE_CATEGORY NS_LITERAL_CSTRING("Content Blocking")
 
 namespace mozilla {
 
 LazyLogModule gAntiTrackingLog("AntiTracking");
 
 }
 
 using namespace mozilla;
 using mozilla::dom::BrowsingContext;
 using mozilla::dom::ContentChild;
 using mozilla::dom::Document;
 
+static const uint32_t kMaxConsoleOutputDelayMs = 100;
+
 namespace {
 
 bool GetParentPrincipalAndTrackingOrigin(
     nsGlobalWindowInner* a3rdPartyTrackingWindow, uint32_t aBehavior,
     nsIPrincipal** aTopLevelStoragePrincipal, nsACString& aTrackingOrigin,
     nsIPrincipal** aTrackingPrincipal) {
   // Now we need the principal and the origin of the parent window.
   nsCOMPtr<nsIPrincipal> topLevelStoragePrincipal =
@@ -70,16 +95,28 @@ bool GetParentPrincipalAndTrackingOrigin
 
   topLevelStoragePrincipal.forget(aTopLevelStoragePrincipal);
   if (aTrackingPrincipal) {
     trackingPrincipal.forget(aTrackingPrincipal);
   }
   return true;
 };
 
+void CreatePermissionKey(const nsCString& aTrackingOrigin,
+                         nsACString& aPermissionKey) {
+  MOZ_ASSERT(aPermissionKey.IsEmpty());
+
+  static const nsLiteralCString prefix =
+      NS_LITERAL_CSTRING(ANTITRACKING_PERM_KEY "^");
+
+  aPermissionKey.SetCapacity(prefix.Length() + aTrackingOrigin.Length());
+  aPermissionKey.Append(prefix);
+  aPermissionKey.Append(aTrackingOrigin);
+}
+
 // This internal method returns ACCESS_DENY if the access is denied,
 // ACCESS_DEFAULT if unknown, some other access code if granted.
 uint32_t CheckCookiePermissionForPrincipal(
     nsICookieJarSettings* aCookieJarSettings, nsIPrincipal* aPrincipal) {
   MOZ_ASSERT(aCookieJarSettings);
   MOZ_ASSERT(aPrincipal);
 
   uint32_t cookiePermission = nsICookiePermission::ACCESS_DEFAULT;
@@ -138,16 +175,370 @@ int32_t CookiesBehavior(nsIPrincipal* aP
   // (See Bug 1406675 for rationale).
   if (BasePrincipal::Cast(aPrincipal)->AddonPolicy()) {
     return nsICookieService::BEHAVIOR_ACCEPT;
   }
 
   return aCookieJarSettings->GetCookieBehavior();
 }
 
+void RunConsoleReportingRunnable(already_AddRefed<nsIRunnable>&& aRunnable) {
+  if (StaticPrefs::privacy_restrict3rdpartystorage_console_lazy()) {
+    nsresult rv = NS_DispatchToCurrentThreadQueue(std::move(aRunnable),
+                                                  kMaxConsoleOutputDelayMs,
+                                                  EventQueuePriority::Idle);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return;
+    }
+  } else {
+    nsCOMPtr<nsIRunnable> runnable(std::move(aRunnable));
+    nsresult rv = runnable->Run();
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return;
+    }
+  }
+}
+
+void ReportBlockingToConsole(uint64_t aWindowID, nsIURI* aURI,
+                             uint32_t aRejectedReason) {
+  MOZ_ASSERT(aWindowID);
+  MOZ_ASSERT(aURI);
+  MOZ_ASSERT(
+      aRejectedReason == 0 ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN ||
+      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
+      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
+
+  nsAutoString sourceLine;
+  uint32_t lineNumber = 0, columnNumber = 0;
+  JSContext* cx = nsContentUtils::GetCurrentJSContext();
+  if (cx) {
+    nsJSUtils::GetCallingLocation(cx, sourceLine, &lineNumber, &columnNumber);
+  }
+
+  nsCOMPtr<nsIURI> uri(aURI);
+
+  RefPtr<Runnable> runnable = NS_NewRunnableFunction(
+      "ReportBlockingToConsoleDelayed", [aWindowID, sourceLine, lineNumber,
+                                         columnNumber, uri, aRejectedReason]() {
+        const char* message = nullptr;
+        nsAutoCString category;
+        // When changing this list, please make sure to update the corresponding
+        // code in antitracking_head.js (inside _createTask).
+        switch (aRejectedReason) {
+          case nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION:
+            message = "CookieBlockedByPermission";
+            category = NS_LITERAL_CSTRING("cookieBlockedPermission");
+            break;
+
+          case nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER:
+            message = "CookieBlockedTracker";
+            category = NS_LITERAL_CSTRING("cookieBlockedTracker");
+            break;
+
+          case nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL:
+            message = "CookieBlockedAll";
+            category = NS_LITERAL_CSTRING("cookieBlockedAll");
+            break;
+
+          case nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN:
+            message = "CookieBlockedForeign";
+            category = NS_LITERAL_CSTRING("cookieBlockedForeign");
+            break;
+
+          default:
+            return;
+        }
+
+        MOZ_ASSERT(message);
+
+        // Strip the URL of any possible username/password and make it ready
+        // to be presented in the UI.
+        nsCOMPtr<nsIURIFixup> urifixup = services::GetURIFixup();
+        NS_ENSURE_TRUE_VOID(urifixup);
+        nsCOMPtr<nsIURI> exposableURI;
+        nsresult rv =
+            urifixup->CreateExposableURI(uri, getter_AddRefs(exposableURI));
+        NS_ENSURE_SUCCESS_VOID(rv);
+
+        AutoTArray<nsString, 1> params;
+        CopyUTF8toUTF16(exposableURI->GetSpecOrDefault(),
+                        *params.AppendElement());
+
+        nsAutoString errorText;
+        rv = nsContentUtils::FormatLocalizedString(
+            nsContentUtils::eNECKO_PROPERTIES, message, params, errorText);
+        NS_ENSURE_SUCCESS_VOID(rv);
+
+        nsContentUtils::ReportToConsoleByWindowID(
+            errorText, nsIScriptError::warningFlag, category, aWindowID,
+            nullptr, sourceLine, lineNumber, columnNumber);
+      });
+
+  RunConsoleReportingRunnable(runnable.forget());
+}
+
+void ReportBlockingToConsole(nsIChannel* aChannel, nsIURI* aURI,
+                             uint32_t aRejectedReason) {
+  MOZ_ASSERT(aChannel && aURI);
+
+  uint64_t windowID;
+
+  if (XRE_IsParentProcess()) {
+    // Get the top-level window ID from the top-level BrowsingContext
+    nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
+    RefPtr<dom::BrowsingContext> bc;
+    loadInfo->GetBrowsingContext(getter_AddRefs(bc));
+
+    if (!bc || bc->IsDiscarded()) {
+      return;
+    }
+
+    bc = bc->Top();
+    RefPtr<dom::WindowGlobalParent> wgp =
+        bc->Canonical()->GetCurrentWindowGlobal();
+    if (!wgp) {
+      return;
+    }
+
+    windowID = wgp->InnerWindowId();
+  } else {
+    nsresult rv;
+    nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel, &rv);
+
+    if (!httpChannel) {
+      return;
+    }
+
+    rv = httpChannel->GetTopLevelContentWindowId(&windowID);
+    if (NS_FAILED(rv) || !windowID) {
+      windowID = nsContentUtils::GetInnerWindowID(httpChannel);
+    }
+  }
+
+  ReportBlockingToConsole(windowID, aURI, aRejectedReason);
+}
+
+void ReportUnblockingToConsole(
+    nsPIDOMWindowInner* aWindow, const nsAString& aTrackingOrigin,
+    AntiTrackingCommon::StorageAccessGrantedReason aReason) {
+  nsCOMPtr<nsIPrincipal> principal =
+      nsGlobalWindowInner::Cast(aWindow)->GetPrincipal();
+  if (NS_WARN_IF(!principal)) {
+    return;
+  }
+
+  RefPtr<Document> doc = aWindow->GetExtantDoc();
+  if (NS_WARN_IF(!doc)) {
+    return;
+  }
+
+  nsAutoString trackingOrigin(aTrackingOrigin);
+
+  nsAutoString sourceLine;
+  uint32_t lineNumber = 0, columnNumber = 0;
+  JSContext* cx = nsContentUtils::GetCurrentJSContext();
+  if (cx) {
+    nsJSUtils::GetCallingLocation(cx, sourceLine, &lineNumber, &columnNumber);
+  }
+
+  RefPtr<Runnable> runnable = NS_NewRunnableFunction(
+      "ReportUnblockingToConsoleDelayed",
+      [doc, principal, trackingOrigin, sourceLine, lineNumber, columnNumber,
+       aReason]() {
+        nsAutoString origin;
+        nsresult rv = nsContentUtils::GetUTFOrigin(principal, origin);
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+          return;
+        }
+
+        // Not adding grantedOrigin yet because we may not want it later.
+        AutoTArray<nsString, 3> params = {origin, trackingOrigin};
+        const char* messageWithSameOrigin = nullptr;
+
+        switch (aReason) {
+          case AntiTrackingCommon::eStorageAccessAPI:
+            messageWithSameOrigin = "CookieAllowedForTrackerByStorageAccessAPI";
+            break;
+
+          case AntiTrackingCommon::eOpenerAfterUserInteraction:
+            [[fallthrough]];
+          case AntiTrackingCommon::eOpener:
+            messageWithSameOrigin = "CookieAllowedForTrackerByHeuristic";
+            break;
+        }
+
+        nsContentUtils::ReportToConsole(
+            nsIScriptError::warningFlag, ANTITRACKING_CONSOLE_CATEGORY, doc,
+            nsContentUtils::eNECKO_PROPERTIES, messageWithSameOrigin, params,
+            nullptr, sourceLine, lineNumber, columnNumber);
+      });
+
+  RunConsoleReportingRunnable(runnable.forget());
+}
+
+already_AddRefed<nsPIDOMWindowOuter> GetTopWindow(nsPIDOMWindowInner* aWindow) {
+  Document* document = aWindow->GetExtantDoc();
+  if (!document) {
+    return nullptr;
+  }
+
+  nsIChannel* channel = document->GetChannel();
+  if (!channel) {
+    return nullptr;
+  }
+
+  nsCOMPtr<nsPIDOMWindowOuter> pwin =
+      aWindow->GetBrowsingContext()->Top()->GetDOMWindow();
+
+  if (!pwin) {
+    return nullptr;
+  }
+
+  return pwin.forget();
+}
+
+class TemporaryAccessGrantCacheKey : public PLDHashEntryHdr {
+ public:
+  typedef Pair<nsCOMPtr<nsIPrincipal>, nsCString> KeyType;
+  typedef const KeyType* KeyTypePointer;
+
+  explicit TemporaryAccessGrantCacheKey(KeyTypePointer aKey)
+      : mPrincipal(aKey->first()), mType(aKey->second()) {}
+  TemporaryAccessGrantCacheKey(TemporaryAccessGrantCacheKey&& aOther) = default;
+
+  ~TemporaryAccessGrantCacheKey() = default;
+
+  KeyType GetKey() const { return MakePair(mPrincipal, mType); }
+  bool KeyEquals(KeyTypePointer aKey) const {
+    return !!mPrincipal == !!aKey->first() && mType == aKey->second() &&
+           (mPrincipal ? (mPrincipal->Equals(aKey->first())) : true);
+  }
+
+  static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
+  static PLDHashNumber HashKey(KeyTypePointer aKey) {
+    if (!aKey) {
+      return 0;
+    }
+
+    BasePrincipal* bp = BasePrincipal::Cast(aKey->first());
+    return HashGeneric(bp->GetOriginNoSuffixHash(), bp->GetOriginSuffixHash(),
+                       HashString(aKey->second()));
+  }
+
+  enum { ALLOW_MEMMOVE = true };
+
+ private:
+  nsCOMPtr<nsIPrincipal> mPrincipal;
+  nsCString mType;
+};
+
+class TemporaryAccessGrantObserver final : public nsIObserver {
+ public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIOBSERVER
+
+  static void Create(nsPermissionManager* aPM, nsIPrincipal* aPrincipal,
+                     const nsACString& aType) {
+    MOZ_ASSERT(XRE_IsParentProcess());
+
+    if (!sObservers) {
+      sObservers = MakeUnique<ObserversTable>();
+    }
+    Unused << sObservers
+                  ->LookupForAdd(MakePair(nsCOMPtr<nsIPrincipal>(aPrincipal),
+                                          nsCString(aType)))
+                  .OrInsert([&]() -> nsITimer* {
+                    // Only create a new observer if we don't have a matching
+                    // entry in our hashtable.
+                    nsCOMPtr<nsITimer> timer;
+                    RefPtr<TemporaryAccessGrantObserver> observer =
+                        new TemporaryAccessGrantObserver(aPM, aPrincipal,
+                                                         aType);
+                    nsresult rv = NS_NewTimerWithObserver(
+                        getter_AddRefs(timer), observer,
+                        24 * 60 * 60 * 1000,  // 24 hours
+                        nsITimer::TYPE_ONE_SHOT);
+
+                    if (NS_SUCCEEDED(rv)) {
+                      observer->SetTimer(timer);
+                      return timer;
+                    }
+                    timer->Cancel();
+                    return nullptr;
+                  });
+  }
+
+  void SetTimer(nsITimer* aTimer) {
+    mTimer = aTimer;
+    nsCOMPtr<nsIObserverService> observerService =
+        mozilla::services::GetObserverService();
+    if (observerService) {
+      observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
+    }
+  }
+
+ private:
+  TemporaryAccessGrantObserver(nsPermissionManager* aPM,
+                               nsIPrincipal* aPrincipal,
+                               const nsACString& aType)
+      : mPM(aPM), mPrincipal(aPrincipal), mType(aType) {
+    MOZ_ASSERT(XRE_IsParentProcess(),
+               "Enforcing temporary access grant lifetimes can only be done in "
+               "the parent process");
+  }
+
+  ~TemporaryAccessGrantObserver() = default;
+
+ private:
+  typedef nsDataHashtable<TemporaryAccessGrantCacheKey, nsCOMPtr<nsITimer>>
+      ObserversTable;
+  static UniquePtr<ObserversTable> sObservers;
+  nsCOMPtr<nsITimer> mTimer;
+  RefPtr<nsPermissionManager> mPM;
+  nsCOMPtr<nsIPrincipal> mPrincipal;
+  nsCString mType;
+};
+
+UniquePtr<TemporaryAccessGrantObserver::ObserversTable>
+    TemporaryAccessGrantObserver::sObservers;
+
+NS_IMPL_ISUPPORTS(TemporaryAccessGrantObserver, nsIObserver)
+
+NS_IMETHODIMP
+TemporaryAccessGrantObserver::Observe(nsISupports* aSubject, const char* aTopic,
+                                      const char16_t* aData) {
+  if (strcmp(aTopic, NS_TIMER_CALLBACK_TOPIC) == 0) {
+    Unused << mPM->RemoveFromPrincipal(mPrincipal, mType);
+
+    MOZ_ASSERT(sObservers);
+    sObservers->Remove(MakePair(mPrincipal, mType));
+  } else if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
+    nsCOMPtr<nsIObserverService> observerService =
+        mozilla::services::GetObserverService();
+    if (observerService) {
+      observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
+    }
+    if (mTimer) {
+      mTimer->Cancel();
+      mTimer = nullptr;
+    }
+    sObservers.reset();
+  }
+
+  return NS_OK;
+}
+
 bool CheckAntiTrackingPermission(nsIPrincipal* aPrincipal,
                                  const nsAutoCString& aType,
                                  bool aIsInPrivateBrowsing,
                                  uint32_t* aRejectedReason,
                                  uint32_t aBlockedReason) {
   nsPermissionManager* permManager = nsPermissionManager::GetInstance();
   if (NS_WARN_IF(!permManager)) {
     LOG(("Failed to obtain the permission manager"));
@@ -240,37 +631,195 @@ bool CheckAntiTrackingPermission(nsIPrin
       }
       return false;
     }
   }
 
   return true;
 }
 
+// This API finishes the remaining work left in NotifyBlockingDecisionInternal.
+void NotifyAllowDecisionInternal(nsIChannel* aReportingChannel,
+                                 nsIChannel* aTrackingChannel, nsIURI* aURI,
+                                 nsPIDOMWindowOuter* aWindow) {
+  nsAutoCString trackingOrigin;
+  if (aURI) {
+    Unused << nsContentUtils::GetASCIIOrigin(aURI, trackingOrigin);
+  }
+
+  // This can be called in either the parent process or the child processes.
+
+  // Now send the generic "cookies loaded" notifications, from the most generic
+  // to the most specific.
+  AntiTrackingCommon::NotifyContentBlockingEvent(
+      aWindow, aReportingChannel, aTrackingChannel, false,
+      nsIWebProgressListener::STATE_COOKIES_LOADED, trackingOrigin);
+
+  nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
+      do_QueryInterface(aTrackingChannel);
+  if (!classifiedChannel) {
+    return;
+  }
+
+  uint32_t classificationFlags =
+      classifiedChannel->GetThirdPartyClassificationFlags();
+  if (classificationFlags &
+      nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_TRACKING) {
+    AntiTrackingCommon::NotifyContentBlockingEvent(
+        aWindow, aReportingChannel, aTrackingChannel, false,
+        nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER, trackingOrigin);
+  }
+
+  if (classificationFlags &
+      nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_SOCIALTRACKING) {
+    AntiTrackingCommon::NotifyContentBlockingEvent(
+        aWindow, aReportingChannel, aTrackingChannel, false,
+        nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER,
+        trackingOrigin);
+  }
+}
+
+void NotifyBlockingDecisionInternal(
+    nsIChannel* aReportingChannel, nsIChannel* aTrackingChannel,
+    AntiTrackingCommon::BlockingDecision aDecision, uint32_t aRejectedReason,
+    nsIURI* aURI, nsPIDOMWindowOuter* aWindow) {
+  MOZ_ASSERT(aWindow);
+
+  // When this is called with system priviledged, the decision should always be
+  // ALLOW, and we can also stop processing this event.
+  if (nsGlobalWindowOuter::Cast(aWindow)->GetPrincipal() ==
+      nsContentUtils::GetSystemPrincipal()) {
+    MOZ_DIAGNOSTIC_ASSERT(aDecision ==
+                          AntiTrackingCommon::BlockingDecision::eAllow);
+    return;
+  }
+
+  nsAutoCString trackingOrigin;
+  if (aURI) {
+    Unused << nsContentUtils::GetASCIIOrigin(aURI, trackingOrigin);
+  }
+
+  if (aDecision == AntiTrackingCommon::BlockingDecision::eBlock) {
+    AntiTrackingCommon::NotifyContentBlockingEvent(
+        aWindow, aReportingChannel, aTrackingChannel, true, aRejectedReason,
+        trackingOrigin);
+
+    ReportBlockingToConsole(aReportingChannel, aURI, aRejectedReason);
+  }
+
+  NotifyAllowDecisionInternal(aReportingChannel, aTrackingChannel, aURI,
+                              aWindow);
+}
+
+void NotifyBlockingDecisionInternal(
+    nsIChannel* aReportingChannel, nsIChannel* aTrackingChannel,
+    AntiTrackingCommon::BlockingDecision aDecision, uint32_t aRejectedReason,
+    nsIURI* aURI) {
+  // Can be called only in the parent process when there is no window.
+  MOZ_ASSERT(XRE_IsParentProcess());
+
+  nsAutoCString trackingOrigin;
+  if (aURI) {
+    Unused << nsContentUtils::GetASCIIOrigin(aURI, trackingOrigin);
+  }
+
+  if (aDecision == AntiTrackingCommon::BlockingDecision::eBlock) {
+    AntiTrackingCommon::NotifyContentBlockingEvent(
+        nullptr, aReportingChannel, aTrackingChannel, true, aRejectedReason,
+        trackingOrigin);
+
+    ReportBlockingToConsole(aReportingChannel, aURI, aRejectedReason);
+  }
+
+  NotifyAllowDecisionInternal(aReportingChannel, aTrackingChannel, aURI,
+                              nullptr);
+}
+
+// Send a message to notify OnContentBlockingEvent in the parent, which will
+// update the ContentBlockingLog in the parent.
+void NotifyContentBlockingEventInChild(
+    nsPIDOMWindowOuter* aWindow, nsIChannel* aReportingChannel,
+    nsIChannel* aTrackingChannel, bool aBlocked, uint32_t aRejectedReason,
+    const nsACString& aTrackingOrigin,
+    const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason) {
+  MOZ_ASSERT(XRE_IsContentProcess());
+  MOZ_ASSERT(aWindow);
+
+  RefPtr<dom::BrowserChild> browserChild = dom::BrowserChild::GetFrom(aWindow);
+  NS_ENSURE_TRUE_VOID(browserChild);
+
+  nsTArray<nsCString> trackingFullHashes;
+  nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
+      do_QueryInterface(aTrackingChannel);
+
+  if (classifiedChannel) {
+    Unused << classifiedChannel->GetMatchedTrackingFullHashes(
+        trackingFullHashes);
+  }
+
+  browserChild->NotifyContentBlockingEvent(aRejectedReason, aReportingChannel,
+                                           aBlocked, aTrackingOrigin,
+                                           trackingFullHashes, aReason);
+}
+
+// Update the ContentBlockingLog of the top-level WindowGlobalParent of
+// the reporting channel.
+void NotifyContentBlockingEventInParent(
+    nsIChannel* aReportingChannel, nsIChannel* aTrackingChannel, bool aBlocked,
+    uint32_t aRejectedReason, const nsACString& aTrackingOrigin,
+    const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason) {
+  MOZ_ASSERT(XRE_IsParentProcess());
+
+  nsCOMPtr<nsILoadInfo> loadInfo = aReportingChannel->LoadInfo();
+  RefPtr<dom::BrowsingContext> bc;
+  loadInfo->GetBrowsingContext(getter_AddRefs(bc));
+
+  if (!bc || bc->IsDiscarded()) {
+    return;
+  }
+
+  bc = bc->Top();
+  RefPtr<dom::WindowGlobalParent> wgp =
+      bc->Canonical()->GetCurrentWindowGlobal();
+  NS_ENSURE_TRUE_VOID(wgp);
+
+  nsTArray<nsCString> trackingFullHashes;
+  nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
+      do_QueryInterface(aTrackingChannel);
+
+  if (classifiedChannel) {
+    Unused << classifiedChannel->GetMatchedTrackingFullHashes(
+        trackingFullHashes);
+  }
+
+  wgp->NotifyContentBlockingEvent(aRejectedReason, aReportingChannel, aBlocked,
+                                  aTrackingOrigin, trackingFullHashes, aReason);
+}
+
 }  // namespace
 
-/* static */ RefPtr<ContentBlocking::StorageAccessGrantPromise>
-ContentBlocking::AllowAccessFor(
+/* static */ RefPtr<AntiTrackingCommon::StorageAccessGrantPromise>
+AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(
     nsIPrincipal* aPrincipal, nsPIDOMWindowInner* aParentWindow,
-    ContentBlockingNotifier::StorageAccessGrantedReason aReason,
-    const ContentBlocking::PerformFinalChecks& aPerformFinalChecks) {
+    StorageAccessGrantedReason aReason,
+    const AntiTrackingCommon::PerformFinalChecks& aPerformFinalChecks) {
   MOZ_ASSERT(aParentWindow);
 
   switch (aReason) {
-    case ContentBlockingNotifier::eOpener:
+    case eOpener:
       if (!StaticPrefs::
               privacy_restrict3rdpartystorage_heuristic_window_open()) {
         LOG(
             ("Bailing out early because the "
              "privacy.restrict3rdpartystorage.heuristic.window_open preference "
              "has been disabled"));
         return StorageAccessGrantPromise::CreateAndReject(false, __func__);
       }
       break;
-    case ContentBlockingNotifier::eOpenerAfterUserInteraction:
+    case eOpenerAfterUserInteraction:
       if (!StaticPrefs::
               privacy_restrict3rdpartystorage_heuristic_opened_window_after_interaction()) {
         LOG(
             ("Bailing out early because the "
              "privacy.restrict3rdpartystorage.heuristic.opened_window_after_"
              "interaction preference has been disabled"));
         return StorageAccessGrantPromise::CreateAndReject(false, __func__);
       }
@@ -417,66 +966,63 @@ ContentBlocking::AllowAccessFor(
   enum : uint32_t {
     blockReason = nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER
   };
   bool isInPrefList = false;
   trackingPrincipal->IsURIInPrefList(
       "privacy.restrict3rdpartystorage."
       "userInteractionRequiredForHosts",
       &isInPrefList);
-  if (isInPrefList &&
-      !ContentBlockingUserInteraction::Exists(trackingPrincipal)) {
+  if (isInPrefList && !HasUserInteraction(trackingPrincipal)) {
     LOG_PRIN(("Tracking principal (%s) hasn't been interacted with before, "
               "refusing to add a first-party storage permission to access it",
               _spec),
              trackingPrincipal);
-    ContentBlockingNotifier::OnDecision(
-        aParentWindow, ContentBlockingNotifier::BlockingDecision::eBlock,
-        blockReason);
+    NotifyBlockingDecision(aParentWindow, BlockingDecision::eBlock,
+                           blockReason);
     return StorageAccessGrantPromise::CreateAndReject(false, __func__);
   }
 
-  nsCOMPtr<nsPIDOMWindowOuter> pwin =
-      AntiTrackingUtils::GetTopWindow(parentWindow);
+  nsCOMPtr<nsPIDOMWindowOuter> pwin = GetTopWindow(parentWindow);
   if (!pwin) {
     LOG(("Couldn't get the top window"));
     return StorageAccessGrantPromise::CreateAndReject(false, __func__);
   }
 
   auto storePermission =
       [pwin, parentWindow, trackingOrigin, trackingPrincipal, topInnerWindow,
        topLevelStoragePrincipal,
        aReason](int aAllowMode) -> RefPtr<StorageAccessGrantPromise> {
     nsAutoCString permissionKey;
-    AntiTrackingUtils::CreateStoragePermissionKey(trackingOrigin,
-                                                  permissionKey);
+    CreatePermissionKey(trackingOrigin, permissionKey);
 
     // Let's store the permission in the current parent window.
     topInnerWindow->SaveStorageAccessGranted(permissionKey);
 
     // Let's inform the parent window.
     parentWindow->StorageAccessGranted();
 
     nsIChannel* channel =
         pwin->GetCurrentInnerWindow()->GetExtantDoc()->GetChannel();
 
-    ContentBlockingNotifier::OnEvent(
+    NotifyContentBlockingEvent(
         pwin, channel, parentWindow->GetExtantDoc()->GetChannel(), false,
         blockReason, trackingOrigin, Some(aReason));
 
-    ContentBlockingNotifier::ReportUnblockingToConsole(
-        parentWindow, NS_ConvertUTF8toUTF16(trackingOrigin), aReason);
+    ReportUnblockingToConsole(parentWindow,
+                              NS_ConvertUTF8toUTF16(trackingOrigin), aReason);
 
     if (XRE_IsParentProcess()) {
       LOG(("Saving the permission: trackingOrigin=%s", trackingOrigin.get()));
-      return SaveAccessForOriginOnParentProcess(topLevelStoragePrincipal,
-                                                trackingPrincipal,
-                                                trackingOrigin, aAllowMode)
+      return SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(
+                 topLevelStoragePrincipal, trackingPrincipal, trackingOrigin,
+                 aAllowMode)
           ->Then(GetCurrentThreadSerialEventTarget(), __func__,
-                 [](ParentAccessGrantPromise::ResolveOrRejectValue&& aValue) {
+                 [](FirstPartyStorageAccessGrantPromise::ResolveOrRejectValue&&
+                        aValue) {
                    if (aValue.IsResolve()) {
                      return StorageAccessGrantPromise::CreateAndResolve(
                          eAllow, __func__);
                    }
                    return StorageAccessGrantPromise::CreateAndReject(false,
                                                                      __func__);
                  });
     }
@@ -518,44 +1064,47 @@ ContentBlocking::AllowAccessFor(
           }
           return StorageAccessGrantPromise::CreateAndReject(false, __func__);
         });
   }
   return storePermission(false);
 }
 
 /* static */
-RefPtr<mozilla::ContentBlocking::ParentAccessGrantPromise>
-ContentBlocking::SaveAccessForOriginOnParentProcess(
+RefPtr<mozilla::AntiTrackingCommon::FirstPartyStorageAccessGrantPromise>
+AntiTrackingCommon::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(
     nsIPrincipal* aParentPrincipal, nsIPrincipal* aTrackingPrincipal,
     const nsCString& aTrackingOrigin, int aAllowMode,
     uint64_t aExpirationTime) {
   MOZ_ASSERT(XRE_IsParentProcess());
   MOZ_ASSERT(aAllowMode == eAllow || aAllowMode == eAllowAutoGrant);
 
   if (!aParentPrincipal || !aTrackingPrincipal) {
     LOG(("Invalid input arguments passed"));
-    return ParentAccessGrantPromise::CreateAndReject(false, __func__);
+    return FirstPartyStorageAccessGrantPromise::CreateAndReject(false,
+                                                                __func__);
   };
 
   LOG_PRIN(("Saving a first-party storage permission on %s for "
             "trackingOrigin=%s",
             _spec, aTrackingOrigin.get()),
            aParentPrincipal);
 
   if (NS_WARN_IF(!aParentPrincipal)) {
     // The child process is sending something wrong. Let's ignore it.
     LOG(("aParentPrincipal is null, bailing out early"));
-    return ParentAccessGrantPromise::CreateAndReject(false, __func__);
+    return FirstPartyStorageAccessGrantPromise::CreateAndReject(false,
+                                                                __func__);
   }
 
   nsPermissionManager* permManager = nsPermissionManager::GetInstance();
   if (NS_WARN_IF(!permManager)) {
     LOG(("Permission manager is null, bailing out early"));
-    return ParentAccessGrantPromise::CreateAndReject(false, __func__);
+    return FirstPartyStorageAccessGrantPromise::CreateAndReject(false,
+                                                                __func__);
   }
 
   // Remember that this pref is stored in seconds!
   uint32_t expirationType = nsIPermissionManager::EXPIRE_TIME;
   uint32_t expirationTime = aExpirationTime * 1000;
   int64_t when = (PR_Now() / PR_USEC_PER_MSEC) + expirationTime;
 
   uint32_t privateBrowsingId = 0;
@@ -565,17 +1114,17 @@ ContentBlocking::SaveAccessForOriginOnPa
     // If we are coming from a private window or are automatically granting a
     // permission, make sure to store a session-only permission which won't
     // get persisted to disk.
     expirationType = nsIPermissionManager::EXPIRE_SESSION;
     when = 0;
   }
 
   nsAutoCString type;
-  AntiTrackingUtils::CreateStoragePermissionKey(aTrackingOrigin, type);
+  CreatePermissionKey(aTrackingOrigin, type);
 
   LOG(
       ("Computed permission key: %s, expiry: %u, proceeding to save in the "
        "permission manager",
        type.get(), expirationTime));
 
   rv = permManager->AddFromPrincipal(aParentPrincipal, type,
                                      nsIPermissionManager::ALLOW_ACTION,
@@ -583,22 +1132,69 @@ ContentBlocking::SaveAccessForOriginOnPa
   Unused << NS_WARN_IF(NS_FAILED(rv));
 
   if (NS_SUCCEEDED(rv) && (aAllowMode == eAllowAutoGrant)) {
     // Make sure temporary access grants do not survive more than 24 hours.
     TemporaryAccessGrantObserver::Create(permManager, aParentPrincipal, type);
   }
 
   LOG(("Result: %s", NS_SUCCEEDED(rv) ? "success" : "failure"));
-  return ParentAccessGrantPromise::CreateAndResolve(rv, __func__);
+  return FirstPartyStorageAccessGrantPromise::CreateAndResolve(rv, __func__);
+}
+
+// static
+bool AntiTrackingCommon::CreateStoragePermissionKey(nsIPrincipal* aPrincipal,
+                                                    nsACString& aKey) {
+  if (!aPrincipal) {
+    return false;
+  }
+
+  nsAutoCString origin;
+  nsresult rv = aPrincipal->GetOriginNoSuffix(origin);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
+
+  CreatePermissionKey(origin, aKey);
+  return true;
 }
 
-bool ContentBlocking::ShouldAllowAccessFor(nsPIDOMWindowInner* aWindow,
-                                           nsIURI* aURI,
-                                           uint32_t* aRejectedReason) {
+// static
+bool AntiTrackingCommon::IsStorageAccessPermission(nsIPermission* aPermission,
+                                                   nsIPrincipal* aPrincipal) {
+  MOZ_ASSERT(aPermission);
+  MOZ_ASSERT(aPrincipal);
+
+  // The permission key may belong either to a tracking origin on the same
+  // origin as the granted origin, or on another origin as the granted origin
+  // (for example when a tracker in a third-party context uses window.open to
+  // open another origin where that second origin would be the granted origin.)
+  // But even in the second case, the type of the permission would still be
+  // formed by concatenating the granted origin to the end of the type name
+  // (see CreatePermissionKey).  Therefore, we pass in the same argument to
+  // both tracking origin and granted origin here in order to compute the
+  // shorter permission key and will then do a prefix match on the type of the
+  // input permission to see if it is a storage access permission or not.
+  nsAutoCString permissionKey;
+  bool result = CreateStoragePermissionKey(aPrincipal, permissionKey);
+  if (NS_WARN_IF(!result)) {
+    return false;
+  }
+
+  nsAutoCString type;
+  nsresult rv = aPermission->GetType(type);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
+
+  return StringBeginsWith(type, permissionKey);
+}
+
+bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+    nsPIDOMWindowInner* aWindow, nsIURI* aURI, uint32_t* aRejectedReason) {
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aURI);
 
   // Let's avoid a null check on aRejectedReason everywhere else.
   uint32_t rejectedReason = 0;
   if (!aRejectedReason) {
     aRejectedReason = &rejectedReason;
   }
@@ -778,30 +1374,30 @@ bool ContentBlocking::ShouldAllowAccessF
           nsGlobalWindowInner::Cast(aWindow), behavior,
           getter_AddRefs(parentPrincipal), trackingOrigin, nullptr)) {
     LOG(("Failed to obtain the parent principal and the tracking origin"));
     *aRejectedReason = blockedReason;
     return false;
   }
 
   nsAutoCString type;
-  AntiTrackingUtils::CreateStoragePermissionKey(trackingOrigin, type);
+  CreatePermissionKey(trackingOrigin, type);
 
   if (topInnerWindow->HasStorageAccessGranted(type)) {
     LOG(("Permission stored in the window. All good."));
     return true;
   }
 
   return CheckAntiTrackingPermission(
       parentPrincipal, type, nsContentUtils::IsInPrivateBrowsing(document),
       aRejectedReason, blockedReason);
 }
 
-bool ContentBlocking::ShouldAllowAccessFor(nsIChannel* aChannel, nsIURI* aURI,
-                                           uint32_t* aRejectedReason) {
+bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+    nsIChannel* aChannel, nsIURI* aURI, uint32_t* aRejectedReason) {
   MOZ_ASSERT(aURI);
   MOZ_ASSERT(aChannel);
 
   // Let's avoid a null check on aRejectedReason everywhere else.
   uint32_t rejectedReason = 0;
   if (!aRejectedReason) {
     aRejectedReason = &rejectedReason;
   }
@@ -1041,30 +1637,30 @@ bool ContentBlocking::ShouldAllowAccessF
   nsAutoCString trackingOrigin;
   rv = nsContentUtils::GetASCIIOrigin(trackingURI, trackingOrigin);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG_SPEC(("Failed to compute the origin from %s", _spec), trackingURI);
     return false;
   }
 
   nsAutoCString type;
-  AntiTrackingUtils::CreateStoragePermissionKey(trackingOrigin, type);
+  CreatePermissionKey(trackingOrigin, type);
 
   uint32_t privateBrowsingId = 0;
   rv = channelPrincipal->GetPrivateBrowsingId(&privateBrowsingId);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG(("Failed to get the channel principal's private browsing ID"));
     return false;
   }
 
   return CheckAntiTrackingPermission(parentPrincipal, type, !!privateBrowsingId,
                                      aRejectedReason, blockedReason);
 }
 
-bool ContentBlocking::ShouldAllowAccessFor(
+bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
     nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings) {
   MOZ_ASSERT(aPrincipal);
   MOZ_ASSERT(aCookieJarSettings);
 
   uint32_t access = nsICookiePermission::ACCESS_DEFAULT;
   if (aPrincipal->GetIsContentPrincipal()) {
     nsPermissionManager* permManager = nsPermissionManager::GetInstance();
     if (permManager) {
@@ -1077,17 +1673,17 @@ bool ContentBlocking::ShouldAllowAccessF
     return access != nsICookiePermission::ACCESS_DENY;
   }
 
   int32_t behavior = CookiesBehavior(aPrincipal, aCookieJarSettings);
   return behavior != nsICookieService::BEHAVIOR_REJECT;
 }
 
 /* static */
-bool ContentBlocking::ApproximateAllowAccessForWithoutChannel(
+bool AntiTrackingCommon::MaybeIsFirstPartyStorageAccessGrantedFor(
     nsPIDOMWindowInner* aFirstPartyWindow, nsIURI* aURI) {
   MOZ_ASSERT(aFirstPartyWindow);
   MOZ_ASSERT(aURI);
 
   LOG_SPEC(
       ("Computing a best guess as to whether window %p has access to URI %s",
        aFirstPartyWindow, _spec),
       aURI);
@@ -1132,14 +1728,436 @@ bool ContentBlocking::ApproximateAllowAc
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG_SPEC(("Failed to compute the origin from %s", _spec), aURI);
     return false;
   }
 
   nsIPrincipal* parentPrincipal = parentDocument->NodePrincipal();
 
   nsAutoCString type;
-  AntiTrackingUtils::CreateStoragePermissionKey(origin, type);
+  CreatePermissionKey(origin, type);
 
   return CheckAntiTrackingPermission(
       parentPrincipal, type,
       nsContentUtils::IsInPrivateBrowsing(parentDocument), nullptr, 0);
 }
+
+/* static */
+void AntiTrackingCommon::NotifyBlockingDecision(nsIChannel* aChannel,
+                                                BlockingDecision aDecision,
+                                                uint32_t aRejectedReason) {
+  MOZ_ASSERT(
+      aRejectedReason == 0 ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN ||
+      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
+      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
+  MOZ_ASSERT(aDecision == BlockingDecision::eBlock ||
+             aDecision == BlockingDecision::eAllow);
+
+  if (!aChannel) {
+    return;
+  }
+
+  nsCOMPtr<nsIURI> uri;
+  aChannel->GetURI(getter_AddRefs(uri));
+
+  // Can be called in EITHER the parent or child process.
+  // Window is only needed while in child processes.
+  if (XRE_IsParentProcess()) {
+    NotifyBlockingDecisionInternal(aChannel, aChannel, aDecision,
+                                   aRejectedReason, uri);
+    return;
+  }
+
+  MOZ_ASSERT(XRE_IsContentProcess());
+
+  nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
+  if (!thirdPartyUtil) {
+    return;
+  }
+
+  nsCOMPtr<nsIURI> uriBeingLoaded = MaybeGetDocumentURIBeingLoaded(aChannel);
+  nsCOMPtr<mozIDOMWindowProxy> win;
+  nsresult rv = thirdPartyUtil->GetTopWindowForChannel(aChannel, uriBeingLoaded,
+                                                       getter_AddRefs(win));
+  NS_ENSURE_SUCCESS_VOID(rv);
+
+  nsCOMPtr<nsPIDOMWindowOuter> pwin = nsPIDOMWindowOuter::From(win);
+  if (!pwin) {
+    return;
+  }
+
+  NotifyBlockingDecisionInternal(aChannel, aChannel, aDecision, aRejectedReason,
+                                 uri, pwin);
+}
+
+/* static */
+void AntiTrackingCommon::NotifyBlockingDecision(nsPIDOMWindowInner* aWindow,
+                                                BlockingDecision aDecision,
+                                                uint32_t aRejectedReason) {
+  MOZ_ASSERT(aWindow);
+  MOZ_ASSERT(
+      aRejectedReason == 0 ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER ||
+      aRejectedReason ==
+          nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN ||
+      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
+      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
+  MOZ_ASSERT(aDecision == BlockingDecision::eBlock ||
+             aDecision == BlockingDecision::eAllow);
+
+  nsCOMPtr<nsPIDOMWindowOuter> pwin = GetTopWindow(aWindow);
+  if (!pwin) {
+    return;
+  }
+
+  nsPIDOMWindowInner* inner = pwin->GetCurrentInnerWindow();
+  if (!inner) {
+    return;
+  }
+  Document* pwinDoc = inner->GetExtantDoc();
+  if (!pwinDoc) {
+    return;
+  }
+  nsIChannel* channel = pwinDoc->GetChannel();
+  if (!channel) {
+    return;
+  }
+
+  Document* document = aWindow->GetExtantDoc();
+  if (!document) {
+    return;
+  }
+  nsIURI* uri = document->GetDocumentURI();
+  nsIChannel* trackingChannel = document->GetChannel();
+
+  NotifyBlockingDecisionInternal(channel, trackingChannel, aDecision,
+                                 aRejectedReason, uri, pwin);
+}
+
+/* static */
+void AntiTrackingCommon::StoreUserInteractionFor(nsIPrincipal* aPrincipal) {
+  if (!aPrincipal) {
+    // The content process may have sent us garbage data.
+    return;
+  }
+
+  if (XRE_IsParentProcess()) {
+    LOG_PRIN(("Saving the userInteraction for %s", _spec), aPrincipal);
+
+    nsPermissionManager* permManager = nsPermissionManager::GetInstance();
+    if (NS_WARN_IF(!permManager)) {
+      LOG(("Permission manager is null, bailing out early"));
+      return;
+    }
+
+    // Remember that this pref is stored in seconds!
+    uint32_t expirationType = nsIPermissionManager::EXPIRE_TIME;
+    uint32_t expirationTime =
+        StaticPrefs::privacy_userInteraction_expiration() * 1000;
+    int64_t when = (PR_Now() / PR_USEC_PER_MSEC) + expirationTime;
+
+    uint32_t privateBrowsingId = 0;
+    nsresult rv = aPrincipal->GetPrivateBrowsingId(&privateBrowsingId);
+    if (!NS_WARN_IF(NS_FAILED(rv)) && privateBrowsingId > 0) {
+      // If we are coming from a private window, make sure to store a
+      // session-only permission which won't get persisted to disk.
+      expirationType = nsIPermissionManager::EXPIRE_SESSION;
+      when = 0;
+    }
+
+    rv = permManager->AddFromPrincipal(aPrincipal, USER_INTERACTION_PERM,
+                                       nsIPermissionManager::ALLOW_ACTION,
+                                       expirationType, when);
+    Unused << NS_WARN_IF(NS_FAILED(rv));
+    return;
+  }
+
+  ContentChild* cc = ContentChild::GetSingleton();
+  MOZ_ASSERT(cc);
+
+  LOG_PRIN(("Asking the parent process to save the user-interaction for us: %s",
+            _spec),
+           aPrincipal);
+  cc->SendStoreUserInteractionAsPermission(IPC::Principal(aPrincipal));
+}
+
+/* static */
+bool AntiTrackingCommon::HasUserInteraction(nsIPrincipal* aPrincipal) {
+  nsPermissionManager* permManager = nsPermissionManager::GetInstance();
+  if (NS_WARN_IF(!permManager)) {
+    return false;
+  }
+
+  uint32_t result = 0;
+  nsresult rv = permManager->TestPermissionWithoutDefaultsFromPrincipal(
+      aPrincipal, USER_INTERACTION_PERM, &result);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
+
+  return result == nsIPermissionManager::ALLOW_ACTION;
+}
+
+/* static */
+already_AddRefed<nsIURI> AntiTrackingCommon::MaybeGetDocumentURIBeingLoaded(
+    nsIChannel* aChannel) {
+  nsCOMPtr<nsIURI> uriBeingLoaded;
+  nsLoadFlags loadFlags = 0;
+  nsresult rv = aChannel->GetLoadFlags(&loadFlags);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return nullptr;
+  }
+  if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) {
+    // If the channel being loaded is a document channel, this call may be
+    // coming from an OnStopRequest notification, which might mean that our
+    // document may still be in the loading process, so we may need to pass in
+    // the uriBeingLoaded argument explicitly.
+    rv = aChannel->GetURI(getter_AddRefs(uriBeingLoaded));
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return nullptr;
+    }
+  }
+  return uriBeingLoaded.forget();
+}
+
+/* static */
+void AntiTrackingCommon::NotifyContentBlockingEvent(nsIChannel* aChannel,
+                                                    uint32_t aRejectedReason) {
+  MOZ_ASSERT(XRE_IsParentProcess() && aChannel);
+
+  nsCOMPtr<nsIURI> uri;
+  aChannel->GetURI(getter_AddRefs(uri));
+
+  nsAutoCString trackingOrigin;
+  if (uri) {
+    Unused << nsContentUtils::GetASCIIOrigin(uri, trackingOrigin);
+  }
+
+  return AntiTrackingCommon::NotifyContentBlockingEvent(
+      nullptr, aChannel, aChannel, true, aRejectedReason, trackingOrigin);
+}
+
+/* static */
+void AntiTrackingCommon::NotifyContentBlockingEvent(
+    nsPIDOMWindowOuter* aWindow, nsIChannel* aReportingChannel,
+    nsIChannel* aTrackingChannel, bool aBlocked, uint32_t aRejectedReason,
+    const nsACString& aTrackingOrigin,
+    const Maybe<StorageAccessGrantedReason>& aReason) {
+  if (XRE_IsParentProcess()) {
+    NotifyContentBlockingEventInParent(aReportingChannel, aTrackingChannel,
+                                       aBlocked, aRejectedReason,
+                                       aTrackingOrigin, aReason);
+  } else {
+    NotifyContentBlockingEventInChild(
+        aWindow, aReportingChannel, aTrackingChannel, aBlocked, aRejectedReason,
+        aTrackingOrigin, aReason);
+  }
+}
+
+/* static */
+void AntiTrackingCommon::RedirectHeuristic(nsIChannel* aOldChannel,
+                                           nsIURI* aOldURI,
+                                           nsIChannel* aNewChannel,
+                                           nsIURI* aNewURI) {
+  MOZ_ASSERT(aOldChannel);
+  MOZ_ASSERT(aOldURI);
+  MOZ_ASSERT(aNewChannel);
+  MOZ_ASSERT(aNewURI);
+
+  nsresult rv;
+
+  if (!StaticPrefs::privacy_restrict3rdpartystorage_heuristic_redirect()) {
+    return;
+  }
+
+  nsCOMPtr<nsIHttpChannel> newChannel = do_QueryInterface(aNewChannel);
+  if (!newChannel) {
+    return;
+  }
+
+  LOG_SPEC(("Checking redirect-heuristic for %s", _spec), aOldURI);
+
+  nsCOMPtr<nsILoadInfo> oldLoadInfo = aOldChannel->LoadInfo();
+  MOZ_ASSERT(oldLoadInfo);
+
+  nsCOMPtr<nsILoadInfo> newLoadInfo = aNewChannel->LoadInfo();
+  MOZ_ASSERT(newLoadInfo);
+
+  nsContentPolicyType contentType = oldLoadInfo->GetExternalContentPolicyType();
+  if (contentType != nsIContentPolicy::TYPE_DOCUMENT ||
+      !aOldChannel->IsDocument()) {
+    LOG_SPEC(("Ignoring redirect for %s because it's not a document", _spec),
+             aOldURI);
+    // We care about document redirects only.
+    return;
+  }
+
+  nsCOMPtr<nsIClassifiedChannel> classifiedOldChannel =
+      do_QueryInterface(aOldChannel);
+  nsCOMPtr<nsIClassifiedChannel> classifiedNewChannel =
+      do_QueryInterface(aNewChannel);
+  if (!classifiedOldChannel || !classifiedNewChannel) {
+    LOG_SPEC2(("Ignoring redirect for %s to %s because there is not "
+               "nsIClassifiedChannel interface",
+               _spec1, _spec2),
+              aOldURI, aNewURI);
+    return;
+  }
+
+  bool allowedByPreviousRedirect =
+      oldLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain();
+
+  // We're looking at the first-party classification flags because we're
+  // interested in first-party redirects.
+  uint32_t newClassificationFlags =
+      classifiedNewChannel->GetFirstPartyClassificationFlags();
+
+  if (net::UrlClassifierCommon::IsTrackingClassificationFlag(
+          newClassificationFlags)) {
+    // This is not a tracking -> non-tracking redirect.
+    LOG_SPEC2(("Redirect for %s to %s because it's not tracking to "
+               "non-tracking. Part of a chain of granted redirects: %d",
+               _spec1, _spec2, allowedByPreviousRedirect),
+              aOldURI, aNewURI);
+    newLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain(
+        allowedByPreviousRedirect);
+    return;
+  }
+
+  uint32_t oldClassificationFlags =
+      classifiedOldChannel->GetFirstPartyClassificationFlags();
+
+  if (!net::UrlClassifierCommon::IsTrackingClassificationFlag(
+          oldClassificationFlags) &&
+      !allowedByPreviousRedirect) {
+    // This is not a tracking -> non-tracking redirect.
+    LOG_SPEC2(
+        ("Redirect for %s to %s because it's not tracking to non-tracking.",
+         _spec1, _spec2),
+        aOldURI, aNewURI);
+    return;
+  }
+
+  nsIScriptSecurityManager* ssm =
+      nsScriptSecurityManager::GetScriptSecurityManager();
+  MOZ_ASSERT(ssm);
+
+  nsCOMPtr<nsIPrincipal> trackingPrincipal;
+
+  const nsTArray<nsCOMPtr<nsIRedirectHistoryEntry>>& chain =
+      oldLoadInfo->RedirectChain();
+
+  if (allowedByPreviousRedirect && !chain.IsEmpty()) {
+    rv = chain[0]->GetPrincipal(getter_AddRefs(trackingPrincipal));
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      LOG(("Can't obtain the principal from the redirect chain"));
+      return;
+    }
+  } else {
+    rv = ssm->GetChannelResultPrincipal(aOldChannel,
+                                        getter_AddRefs(trackingPrincipal));
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      LOG(("Can't obtain the principal from the tracking"));
+      return;
+    }
+  }
+
+  nsCOMPtr<nsIPrincipal> redirectedPrincipal;
+  rv = ssm->GetChannelResultPrincipal(aNewChannel,
+                                      getter_AddRefs(redirectedPrincipal));
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    LOG(("Can't obtain the principal from the redirected"));
+    return;
+  }
+
+  if (!AntiTrackingCommon::HasUserInteraction(trackingPrincipal)) {
+    LOG_SPEC2(("Ignoring redirect for %s to %s because no user-interaction on "
+               "tracker",
+               _spec1, _spec2),
+              aOldURI, aNewURI);
+    return;
+  }
+
+  nsAutoCString trackingOrigin;
+  rv = trackingPrincipal->GetOrigin(trackingOrigin);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    LOG(("Can't get the origin from the Principal"));
+    return;
+  }
+
+  nsAutoCString redirectedOrigin;
+  rv = nsContentUtils::GetASCIIOrigin(aNewURI, redirectedOrigin);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    LOG(("Can't get the origin from the URI"));
+    return;
+  }
+
+  LOG(("Adding a first-party storage exception for %s...",
+       PromiseFlatCString(redirectedOrigin).get()));
+
+  nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
+  rv = oldLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    LOG(("Can't get the cookieJarSettings"));
+    return;
+  }
+
+  int32_t behavior = cookieJarSettings->GetCookieBehavior();
+
+  if (!cookieJarSettings->GetRejectThirdPartyTrackers()) {
+    LOG(
+        ("Disabled by network.cookie.cookieBehavior pref (%d), bailing out "
+         "early",
+         behavior));
+    return;
+  }
+
+  MOZ_ASSERT(
+      behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER ||
+      behavior ==
+          nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN);
+
+  if (ContentBlockingAllowList::Check(newChannel)) {
+    return;
+  }
+
+  LOG(("Saving the permission: trackingOrigin=%s, grantedOrigin=%s",
+       trackingOrigin.get(), redirectedOrigin.get()));
+
+  // Any new redirect from this loadInfo must be considered as granted.
+  newLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain(true);
+
+  uint64_t innerWindowID;
+  Unused << newChannel->GetTopLevelContentWindowId(&innerWindowID);
+
+  nsAutoString errorText;
+  AutoTArray<nsString, 2> params = {NS_ConvertUTF8toUTF16(redirectedOrigin),
+                                    NS_ConvertUTF8toUTF16(trackingOrigin)};
+  rv = nsContentUtils::FormatLocalizedString(
+      nsContentUtils::eNECKO_PROPERTIES, "CookieAllowedForTrackerByHeuristic",
+      params, errorText);
+  if (NS_SUCCEEDED(rv)) {
+    nsContentUtils::ReportToConsoleByWindowID(
+        errorText, nsIScriptError::warningFlag, ANTITRACKING_CONSOLE_CATEGORY,
+        innerWindowID);
+  }
+
+  // We don't care about this promise because the operation is actually sync.
+  RefPtr<FirstPartyStorageAccessGrantPromise> promise =
+      SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(
+          redirectedPrincipal, trackingPrincipal, trackingOrigin,
+          StorageAccessPromptChoices::eAllow,
+          StaticPrefs::privacy_restrict3rdpartystorage_expiration_redirect());
+  Unused << promise;
+}
rename from toolkit/components/antitracking/ContentBlocking.h
rename to toolkit/components/antitracking/AntiTrackingCommon.h
--- a/toolkit/components/antitracking/ContentBlocking.h
+++ b/toolkit/components/antitracking/AntiTrackingCommon.h
@@ -3,71 +3,86 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_antitrackingservice_h
 #define mozilla_antitrackingservice_h
 
 #include "nsString.h"
-#include "mozilla/ContentBlockingNotifier.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/StaticPrefs_privacy.h"
 
+#define USER_INTERACTION_PERM NS_LITERAL_CSTRING("storageAccessAPI")
+
 class nsIChannel;
 class nsICookieJarSettings;
 class nsIPermission;
 class nsIPrincipal;
 class nsIURI;
 class nsPIDOMWindowInner;
 class nsPIDOMWindowOuter;
 
 namespace mozilla {
 
 class OriginAttributes;
 
-class ContentBlocking final {
+class AntiTrackingCommon final {
  public:
+  // Normally we would include PContentParent.h here and use the
+  // ipc::FirstPartyStorageAccessGrantedForOriginResolver type which maps to
+  // the same underlying type, but that results in Windows compilation errors,
+  // so we use the underlying type to avoid the #include here.
+  typedef std::function<void(const bool&)>
+      FirstPartyStorageAccessGrantedForOriginResolver;
+
   // This method returns true if the URI has first party storage access when
   // loaded inside the passed 3rd party context tracking resource window.
   // If the window is first party context, please use
-  // ApproximateAllowAccessForWithoutChannel();
+  // MaybeIsFirstPartyStorageAccessGrantedFor();
   //
   // aRejectedReason could be set to one of these values if passed and if the
   // storage permission is not granted:
   //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION
   //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER
   //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER
   //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL
   //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
-  static bool ShouldAllowAccessFor(nsPIDOMWindowInner* a3rdPartyTrackingWindow,
-                                   nsIURI* aURI, uint32_t* aRejectedReason);
+  static bool IsFirstPartyStorageAccessGrantedFor(
+      nsPIDOMWindowInner* a3rdPartyTrackingWindow, nsIURI* aURI,
+      uint32_t* aRejectedReason);
 
-  // Note: you should use ShouldAllowAccessFor() passing the nsIChannel! Use
-  // this method _only_ if the channel is not available.  For first party
-  // window, it's impossible to know if the aURI is a tracking resource
-  // synchronously, so here we return the best guest: if we are sure that the
-  // permission is granted for the origin of aURI, this method returns true,
-  // otherwise false.
-  static bool ApproximateAllowAccessForWithoutChannel(
+  // Note: you should use IsFirstPartyStorageAccessGrantedFor() passing the
+  // nsIChannel! Use this method _only_ if the channel is not available.
+  // For first party window, it's impossible to know if the aURI is a tracking
+  // resource synchronously, so here we return the best guest: if we are sure
+  // that the permission is granted for the origin of aURI, this method returns
+  // true, otherwise false.
+  static bool MaybeIsFirstPartyStorageAccessGrantedFor(
       nsPIDOMWindowInner* aFirstPartyWindow, nsIURI* aURI);
 
   // It returns true if the URI has access to the first party storage.
   // aChannel can be a 3rd party channel, or not.
-  // See ShouldAllowAccessFor(window) to see the possible values of
-  // aRejectedReason.
-  static bool ShouldAllowAccessFor(nsIChannel* aChannel, nsIURI* aURI,
-                                   uint32_t* aRejectedReason);
+  // See IsFirstPartyStorageAccessGrantedFor(window) to see the possible values
+  // of aRejectedReason.
+  static bool IsFirstPartyStorageAccessGrantedFor(nsIChannel* aChannel,
+                                                  nsIURI* aURI,
+                                                  uint32_t* aRejectedReason);
 
   // This method checks if the principal has the permission to access to the
   // first party storage.
-  static bool ShouldAllowAccessFor(nsIPrincipal* aPrincipal,
-                                   nsICookieJarSettings* aCookieJarSettings);
+  static bool IsFirstPartyStorageAccessGrantedFor(
+      nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings);
 
+  enum StorageAccessGrantedReason {
+    eStorageAccessAPI,
+    eOpenerAfterUserInteraction,
+    eOpener
+  };
   enum StorageAccessPromptChoices { eAllow, eAllowAutoGrant };
 
   // Grant the permission for aOrigin to have access to the first party storage.
   // This method can handle 2 different scenarios:
   // - aParentWindow is a 3rd party context, it opens an aOrigin window and the
   //   user interacts with it. We want to grant the permission at the
   //   combination: top-level + aParentWindow + aOrigin.
   //   Ex: example.net loads an iframe tracker.com, which opens a popup
@@ -79,25 +94,83 @@ class ContentBlocking final {
   //   the first party stoage when loaded in aParentWindow.
   //   Ex: example.net import tracker.com/script.js which does opens a popup and
   //   the user interacts with it. tracker.com is allowed when loaded by
   //   example.net.
   typedef MozPromise<int, bool, true> StorageAccessFinalCheckPromise;
   typedef std::function<RefPtr<StorageAccessFinalCheckPromise>()>
       PerformFinalChecks;
   typedef MozPromise<int, bool, true> StorageAccessGrantPromise;
-  static MOZ_MUST_USE RefPtr<StorageAccessGrantPromise> AllowAccessFor(
+  static MOZ_MUST_USE RefPtr<StorageAccessGrantPromise>
+  AddFirstPartyStorageAccessGrantedFor(
       nsIPrincipal* aPrincipal, nsPIDOMWindowInner* aParentWindow,
-      ContentBlockingNotifier::StorageAccessGrantedReason aReason,
+      StorageAccessGrantedReason aReason,
       const PerformFinalChecks& aPerformFinalChecks = nullptr);
 
+  // Given a principal, returns the storage permission key that will be used for
+  // the principal.  Returns true on success.
+  static bool CreateStoragePermissionKey(nsIPrincipal* aPrincipal,
+                                         nsACString& aKey);
+
+  // Returns true if the permission passed in is a storage access permission
+  // for the passed in principal argument.
+  static bool IsStorageAccessPermission(nsIPermission* aPermission,
+                                        nsIPrincipal* aPrincipal);
+
+  static void StoreUserInteractionFor(nsIPrincipal* aPrincipal);
+
+  static bool HasUserInteraction(nsIPrincipal* aPrincipal);
+
   // For IPC only.
-  typedef MozPromise<nsresult, bool, true> ParentAccessGrantPromise;
-  static RefPtr<ParentAccessGrantPromise> SaveAccessForOriginOnParentProcess(
+  typedef MozPromise<nsresult, bool, true> FirstPartyStorageAccessGrantPromise;
+  static RefPtr<FirstPartyStorageAccessGrantPromise>
+  SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(
       nsIPrincipal* aPrincipal, nsIPrincipal* aTrackingPrinciapl,
       const nsCString& aTrackingOrigin, int aAllowMode,
       uint64_t aExpirationTime =
           StaticPrefs::privacy_restrict3rdpartystorage_expiration());
+
+  enum class BlockingDecision {
+    eBlock,
+    eAllow,
+  };
+
+  // This method can be called on the parent process or on the content process.
+  // The notification is propagated to the child channel if aChannel is a parent
+  // channel proxy.
+  //
+  // aDecision can be eBlock if we have decided to block some content, or eAllow
+  // if we have decided to allow the content through.
+  //
+  // aRejectedReason must be one of these values:
+  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION
+  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER
+  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER
+  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL
+  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
+  static void NotifyBlockingDecision(nsIChannel* aChannel,
+                                     BlockingDecision aDecision,
+                                     uint32_t aRejectedReason);
+
+  static void NotifyBlockingDecision(nsPIDOMWindowInner* aWindow,
+                                     BlockingDecision aDecision,
+                                     uint32_t aRejectedReason);
+
+  // Get the current document URI from a document channel as it is being loaded.
+  static already_AddRefed<nsIURI> MaybeGetDocumentURIBeingLoaded(
+      nsIChannel* aChannel);
+
+  static void NotifyContentBlockingEvent(nsIChannel* aChannel,
+                                         uint32_t aRejectedReason);
+
+  static void NotifyContentBlockingEvent(
+      nsPIDOMWindowOuter* aWindow, nsIChannel* aReportingChannel,
+      nsIChannel* aTrackingChannel, bool aBlocked, uint32_t aRejectedReason,
+      const nsACString& aTrackingOrigin,
+      const Maybe<StorageAccessGrantedReason>& aReason = Nothing());
+
+  static void RedirectHeuristic(nsIChannel* aOldChannel, nsIURI* aOldURI,
+                                nsIChannel* aNewChannel, nsIURI* aNewURI);
 };
 
 }  // namespace mozilla
 
 #endif  // mozilla_antitrackingservice_h
--- a/toolkit/components/antitracking/AntiTrackingIPCUtils.h
+++ b/toolkit/components/antitracking/AntiTrackingIPCUtils.h
@@ -4,26 +4,25 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_antitrackingipcutils_h
 #define mozilla_antitrackingipcutils_h
 
 #include "ipc/IPCMessageUtils.h"
 
-#include "mozilla/ContentBlockingNotifier.h"
+#include "mozilla/AntiTrackingCommon.h"
 
 namespace IPC {
 
-// For allowing passing the enum
-// ContentBlockingNotifier::StorageAccessGrantedReason over IPC.
+// For allowing passing the enum AntiTrackingCommon::StorageAccessGrantedReason
+// over IPC.
 template <>
-struct ParamTraits<mozilla::ContentBlockingNotifier::StorageAccessGrantedReason>
+struct ParamTraits<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>
     : public ContiguousEnumSerializerInclusive<
-          mozilla::ContentBlockingNotifier::StorageAccessGrantedReason,
-          mozilla::ContentBlockingNotifier::StorageAccessGrantedReason::
+          mozilla::AntiTrackingCommon::StorageAccessGrantedReason,
+          mozilla::AntiTrackingCommon::StorageAccessGrantedReason::
               eStorageAccessAPI,
-          mozilla::ContentBlockingNotifier::StorageAccessGrantedReason::
-              eOpener> {};
+          mozilla::AntiTrackingCommon::StorageAccessGrantedReason::eOpener> {};
 
 }  // namespace IPC
 
 #endif  // mozilla_antitrackingipcutils_h
deleted file mode 100644
--- a/toolkit/components/antitracking/AntiTrackingRedirectHeuristic.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "AntiTrackingLog.h"
-#include "AntiTrackingRedirectHeuristic.h"
-#include "ContentBlocking.h"
-#include "ContentBlockingAllowList.h"
-#include "ContentBlockingUserInteraction.h"
-
-#include "mozilla/dom/BrowsingContext.h"
-#include "mozilla/dom/Document.h"
-#include "mozilla/net/UrlClassifierCommon.h"
-#include "nsContentUtils.h"
-#include "nsIChannel.h"
-#include "nsIClassifiedChannel.h"
-#include "nsICookieService.h"
-#include "nsIRedirectHistoryEntry.h"
-#include "nsIScriptError.h"
-#include "nsIURI.h"
-#include "nsPIDOMWindow.h"
-#include "nsScriptSecurityManager.h"
-
-namespace mozilla {
-
-void AntiTrackingRedirectHeuristic(nsIChannel* aOldChannel, nsIURI* aOldURI,
-                                   nsIChannel* aNewChannel, nsIURI* aNewURI) {
-  MOZ_ASSERT(aOldChannel);
-  MOZ_ASSERT(aOldURI);
-  MOZ_ASSERT(aNewChannel);
-  MOZ_ASSERT(aNewURI);
-
-  nsresult rv;
-
-  if (!StaticPrefs::privacy_restrict3rdpartystorage_heuristic_redirect()) {
-    return;
-  }
-
-  nsCOMPtr<nsIHttpChannel> newChannel = do_QueryInterface(aNewChannel);
-  if (!newChannel) {
-    return;
-  }
-
-  LOG_SPEC(("Checking redirect-heuristic for %s", _spec), aOldURI);
-
-  nsCOMPtr<nsILoadInfo> oldLoadInfo = aOldChannel->LoadInfo();
-  MOZ_ASSERT(oldLoadInfo);
-
-  nsCOMPtr<nsILoadInfo> newLoadInfo = aNewChannel->LoadInfo();
-  MOZ_ASSERT(newLoadInfo);
-
-  nsContentPolicyType contentType = oldLoadInfo->GetExternalContentPolicyType();
-  if (contentType != nsIContentPolicy::TYPE_DOCUMENT ||
-      !aOldChannel->IsDocument()) {
-    LOG_SPEC(("Ignoring redirect for %s because it's not a document", _spec),
-             aOldURI);
-    // We care about document redirects only.
-    return;
-  }
-
-  nsCOMPtr<nsIClassifiedChannel> classifiedOldChannel =
-      do_QueryInterface(aOldChannel);
-  nsCOMPtr<nsIClassifiedChannel> classifiedNewChannel =
-      do_QueryInterface(aNewChannel);
-  if (!classifiedOldChannel || !classifiedNewChannel) {
-    LOG_SPEC2(("Ignoring redirect for %s to %s because there is not "
-               "nsIClassifiedChannel interface",
-               _spec1, _spec2),
-              aOldURI, aNewURI);
-    return;
-  }
-
-  bool allowedByPreviousRedirect =
-      oldLoadInfo->GetAllowListFutureDocumentsCreatedFromThisRedirectChain();
-
-  // We're looking at the first-party classification flags because we're
-  // interested in first-party redirects.
-  uint32_t newClassificationFlags =
-      classifiedNewChannel->GetFirstPartyClassificationFlags();
-
-  if (net::UrlClassifierCommon::IsTrackingClassificationFlag(
-          newClassificationFlags)) {
-    // This is not a tracking -> non-tracking redirect.
-    LOG_SPEC2(("Redirect for %s to %s because it's not tracking to "
-               "non-tracking. Part of a chain of granted redirects: %d",
-               _spec1, _spec2, allowedByPreviousRedirect),
-              aOldURI, aNewURI);
-    newLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain(
-        allowedByPreviousRedirect);
-    return;
-  }
-
-  uint32_t oldClassificationFlags =
-      classifiedOldChannel->GetFirstPartyClassificationFlags();
-
-  if (!net::UrlClassifierCommon::IsTrackingClassificationFlag(
-          oldClassificationFlags) &&
-      !allowedByPreviousRedirect) {
-    // This is not a tracking -> non-tracking redirect.
-    LOG_SPEC2(
-        ("Redirect for %s to %s because it's not tracking to non-tracking.",
-         _spec1, _spec2),
-        aOldURI, aNewURI);
-    return;
-  }
-
-  nsIScriptSecurityManager* ssm =
-      nsScriptSecurityManager::GetScriptSecurityManager();
-  MOZ_ASSERT(ssm);
-
-  nsCOMPtr<nsIPrincipal> trackingPrincipal;
-
-  const nsTArray<nsCOMPtr<nsIRedirectHistoryEntry>>& chain =
-      oldLoadInfo->RedirectChain();
-
-  if (allowedByPreviousRedirect && !chain.IsEmpty()) {
-    rv = chain[0]->GetPrincipal(getter_AddRefs(trackingPrincipal));
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      LOG(("Can't obtain the principal from the redirect chain"));
-      return;
-    }
-  } else {
-    rv = ssm->GetChannelResultPrincipal(aOldChannel,
-                                        getter_AddRefs(trackingPrincipal));
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      LOG(("Can't obtain the principal from the tracking"));
-      return;
-    }
-  }
-
-  nsCOMPtr<nsIPrincipal> redirectedPrincipal;
-  rv = ssm->GetChannelResultPrincipal(aNewChannel,
-                                      getter_AddRefs(redirectedPrincipal));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    LOG(("Can't obtain the principal from the redirected"));
-    return;
-  }
-
-  if (!ContentBlockingUserInteraction::Exists(trackingPrincipal)) {
-    LOG_SPEC2(("Ignoring redirect for %s to %s because no user-interaction on "
-               "tracker",
-               _spec1, _spec2),
-              aOldURI, aNewURI);
-    return;
-  }
-
-  nsAutoCString trackingOrigin;
-  rv = trackingPrincipal->GetOrigin(trackingOrigin);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    LOG(("Can't get the origin from the Principal"));
-    return;
-  }
-
-  nsAutoCString redirectedOrigin;
-  rv = nsContentUtils::GetASCIIOrigin(aNewURI, redirectedOrigin);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    LOG(("Can't get the origin from the URI"));
-    return;
-  }
-
-  LOG(("Adding a first-party storage exception for %s...",
-       PromiseFlatCString(redirectedOrigin).get()));
-
-  nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
-  rv = oldLoadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    LOG(("Can't get the cookieJarSettings"));
-    return;
-  }
-
-  int32_t behavior = cookieJarSettings->GetCookieBehavior();
-
-  if (!cookieJarSettings->GetRejectThirdPartyTrackers()) {
-    LOG(
-        ("Disabled by network.cookie.cookieBehavior pref (%d), bailing out "
-         "early",
-         behavior));
-    return;
-  }
-
-  MOZ_ASSERT(
-      behavior == nsICookieService::BEHAVIOR_REJECT_TRACKER ||
-      behavior ==
-          nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN);
-
-  if (ContentBlockingAllowList::Check(newChannel)) {
-    return;
-  }
-
-  LOG(("Saving the permission: trackingOrigin=%s, grantedOrigin=%s",
-       trackingOrigin.get(), redirectedOrigin.get()));
-
-  // Any new redirect from this loadInfo must be considered as granted.
-  newLoadInfo->SetAllowListFutureDocumentsCreatedFromThisRedirectChain(true);
-
-  uint64_t innerWindowID;
-  Unused << newChannel->GetTopLevelContentWindowId(&innerWindowID);
-
-  nsAutoString errorText;
-  AutoTArray<nsString, 2> params = {NS_ConvertUTF8toUTF16(redirectedOrigin),
-                                    NS_ConvertUTF8toUTF16(trackingOrigin)};
-  rv = nsContentUtils::FormatLocalizedString(
-      nsContentUtils::eNECKO_PROPERTIES, "CookieAllowedForTrackerByHeuristic",
-      params, errorText);
-  if (NS_SUCCEEDED(rv)) {
-    nsContentUtils::ReportToConsoleByWindowID(
-        errorText, nsIScriptError::warningFlag, ANTITRACKING_CONSOLE_CATEGORY,
-        innerWindowID);
-  }
-
-  // We don't care about this promise because the operation is actually sync.
-  RefPtr<ContentBlocking::ParentAccessGrantPromise> promise =
-      ContentBlocking::SaveAccessForOriginOnParentProcess(
-          redirectedPrincipal, trackingPrincipal, trackingOrigin,
-          ContentBlocking::StorageAccessPromptChoices::eAllow,
-          StaticPrefs::privacy_restrict3rdpartystorage_expiration_redirect());
-  Unused << promise;
-}
-
-}  // namespace mozilla
deleted file mode 100644
--- a/toolkit/components/antitracking/AntiTrackingRedirectHeuristic.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_antitrackingredirectheuristic_h
-#define mozilla_antitrackingredirectheuristic_h
-
-class nsIChannel;
-class nsIURI;
-
-namespace mozilla {
-
-void AntiTrackingRedirectHeuristic(nsIChannel* aOldChannel, nsIURI* aOldURI,
-                                   nsIChannel* aNewChannel, nsIURI* aNewURI);
-
-}  // namespace mozilla
-
-#endif  // mozilla_antitrackingredirectheuristic_h
deleted file mode 100644
--- a/toolkit/components/antitracking/AntiTrackingUtils.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "AntiTrackingUtils.h"
-
-#include "mozilla/dom/BrowsingContext.h"
-#include "mozilla/dom/Document.h"
-#include "nsIChannel.h"
-#include "nsIPermission.h"
-#include "nsIURI.h"
-#include "nsPIDOMWindow.h"
-
-#define ANTITRACKING_PERM_KEY "3rdPartyStorage"
-
-using namespace mozilla;
-using namespace mozilla::dom;
-
-/* static */ already_AddRefed<nsPIDOMWindowOuter>
-AntiTrackingUtils::GetTopWindow(nsPIDOMWindowInner* aWindow) {
-  Document* document = aWindow->GetExtantDoc();
-  if (!document) {
-    return nullptr;
-  }
-
-  nsIChannel* channel = document->GetChannel();
-  if (!channel) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsPIDOMWindowOuter> pwin =
-      aWindow->GetBrowsingContext()->Top()->GetDOMWindow();
-
-  if (!pwin) {
-    return nullptr;
-  }
-
-  return pwin.forget();
-}
-
-/* static */
-already_AddRefed<nsIURI> AntiTrackingUtils::MaybeGetDocumentURIBeingLoaded(
-    nsIChannel* aChannel) {
-  nsCOMPtr<nsIURI> uriBeingLoaded;
-  nsLoadFlags loadFlags = 0;
-  nsresult rv = aChannel->GetLoadFlags(&loadFlags);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return nullptr;
-  }
-  if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) {
-    // If the channel being loaded is a document channel, this call may be
-    // coming from an OnStopRequest notification, which might mean that our
-    // document may still be in the loading process, so we may need to pass in
-    // the uriBeingLoaded argument explicitly.
-    rv = aChannel->GetURI(getter_AddRefs(uriBeingLoaded));
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return nullptr;
-    }
-  }
-  return uriBeingLoaded.forget();
-}
-
-// static
-void AntiTrackingUtils::CreateStoragePermissionKey(
-    const nsCString& aTrackingOrigin, nsACString& aPermissionKey) {
-  MOZ_ASSERT(aPermissionKey.IsEmpty());
-
-  static const nsLiteralCString prefix =
-      NS_LITERAL_CSTRING(ANTITRACKING_PERM_KEY "^");
-
-  aPermissionKey.SetCapacity(prefix.Length() + aTrackingOrigin.Length());
-  aPermissionKey.Append(prefix);
-  aPermissionKey.Append(aTrackingOrigin);
-}
-
-// static
-bool AntiTrackingUtils::CreateStoragePermissionKey(nsIPrincipal* aPrincipal,
-                                                   nsACString& aKey) {
-  if (!aPrincipal) {
-    return false;
-  }
-
-  nsAutoCString origin;
-  nsresult rv = aPrincipal->GetOriginNoSuffix(origin);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return false;
-  }
-
-  CreateStoragePermissionKey(origin, aKey);
-  return true;
-}
-
-// static
-bool AntiTrackingUtils::IsStorageAccessPermission(nsIPermission* aPermission,
-                                                  nsIPrincipal* aPrincipal) {
-  MOZ_ASSERT(aPermission);
-  MOZ_ASSERT(aPrincipal);
-
-  // The permission key may belong either to a tracking origin on the same
-  // origin as the granted origin, or on another origin as the granted origin
-  // (for example when a tracker in a third-party context uses window.open to
-  // open another origin where that second origin would be the granted origin.)
-  // But even in the second case, the type of the permission would still be
-  // formed by concatenating the granted origin to the end of the type name
-  // (see CreatePermissionKey).  Therefore, we pass in the same argument to
-  // both tracking origin and granted origin here in order to compute the
-  // shorter permission key and will then do a prefix match on the type of the
-  // input permission to see if it is a storage access permission or not.
-  nsAutoCString permissionKey;
-  bool result = CreateStoragePermissionKey(aPrincipal, permissionKey);
-  if (NS_WARN_IF(!result)) {
-    return false;
-  }
-
-  nsAutoCString type;
-  nsresult rv = aPermission->GetType(type);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return false;
-  }
-
-  return StringBeginsWith(type, permissionKey);
-}
deleted file mode 100644
--- a/toolkit/components/antitracking/AntiTrackingUtils.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_antitrackingutils_h
-#define mozilla_antitrackingutils_h
-
-#include "mozilla/AlreadyAddRefed.h"
-#include "nsStringFwd.h"
-
-class nsPIDOMWindowInner;
-class nsPIDOMWindowOuter;
-class nsIChannel;
-class nsIPermission;
-class nsIPrincipal;
-class nsIURI;
-
-namespace mozilla {
-
-class AntiTrackingUtils final {
- public:
-  static already_AddRefed<nsPIDOMWindowOuter> GetTopWindow(
-      nsPIDOMWindowInner* aWindow);
-
-  // Get the current document URI from a document channel as it is being loaded.
-  static already_AddRefed<nsIURI> MaybeGetDocumentURIBeingLoaded(
-      nsIChannel* aChannel);
-
-  static void CreateStoragePermissionKey(const nsCString& aTrackingOrigin,
-                                         nsACString& aPermissionKey);
-
-  // Given a principal, returns the storage permission key that will be used for
-  // the principal.  Returns true on success.
-  static bool CreateStoragePermissionKey(nsIPrincipal* aPrincipal,
-                                         nsACString& aKey);
-
-  // Returns true if the permission passed in is a storage access permission
-  // for the passed in principal argument.
-  static bool IsStorageAccessPermission(nsIPermission* aPermission,
-                                        nsIPrincipal* aPrincipal);
-};
-
-}  // namespace mozilla
-
-#endif  // mozilla_antitrackingutils_h
--- a/toolkit/components/antitracking/ContentBlockingAllowList.h
+++ b/toolkit/components/antitracking/ContentBlockingAllowList.h
@@ -21,35 +21,34 @@ class ContentBlockingAllowList final {
  public:
   // Check whether a principal is on the content blocking allow list.
   // aPrincipal should be a "content blocking allow list principal".
   // This principal can be obtained from the load info object for top-level
   // windows.
   static nsresult Check(nsIPrincipal* aContentBlockingAllowListPrincipal,
                         bool aIsPrivateBrowsing, bool& aIsAllowListed);
 
-  static bool Check(nsIHttpChannel* aChannel);
-
   // Computes the principal used to check the content blocking allow list for a
   // top-level document based on the document principal.  This function is used
   // right after setting up the document principal.
   static void ComputePrincipal(nsIPrincipal* aDocumentPrincipal,
                                nsIPrincipal** aPrincipal);
 
   static void RecomputePrincipal(nsIURI* aURIBeingLoaded,
                                  const OriginAttributes& aAttrs,
                                  nsIPrincipal** aPrincipal);
 
  private:
   // Get the cache of allow list lookups for recent window/channels passed to
   // Check().
   static ContentBlockingAllowListCache& Cache();
 
-  // Utility APIs for ContentBlocking.
+  // Utility APIs for AntiTrackingCommon.
   static bool Check(nsIPrincipal* aTopWinPrincipal, bool aIsPrivateBrowsing);
   static bool Check(nsPIDOMWindowInner* aWindow);
+  static bool Check(nsIHttpChannel* aChannel);
 
-  friend class ContentBlocking;
+  friend class AntiTrackingCommon;
 };
 
 }  // namespace mozilla
 
 #endif  // mozilla_contentblockingallowlist_h
deleted file mode 100644
--- a/toolkit/components/antitracking/ContentBlockingNotifier.cpp
+++ /dev/null
@@ -1,530 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "AntiTrackingLog.h"
-#include "ContentBlockingNotifier.h"
-#include "AntiTrackingUtils.h"
-
-#include "mozilla/AbstractEventQueue.h"
-#include "mozilla/StaticPrefs_privacy.h"
-#include "mozilla/dom/BrowserChild.h"
-#include "mozilla/dom/BrowsingContext.h"
-#include "mozilla/dom/WindowGlobalParent.h"
-#include "nsIClassifiedChannel.h"
-#include "nsIRunnable.h"
-#include "nsIScriptError.h"
-#include "nsIURI.h"
-#include "nsIURIFixup.h"
-#include "nsGlobalWindowInner.h"
-#include "nsJSUtils.h"
-#include "mozIThirdPartyUtil.h"
-
-using namespace mozilla;
-using mozilla::dom::BrowsingContext;
-using mozilla::dom::ContentChild;
-using mozilla::dom::Document;
-
-static const uint32_t kMaxConsoleOutputDelayMs = 100;
-
-namespace {
-
-void RunConsoleReportingRunnable(already_AddRefed<nsIRunnable>&& aRunnable) {
-  if (StaticPrefs::privacy_restrict3rdpartystorage_console_lazy()) {
-    nsresult rv = NS_DispatchToCurrentThreadQueue(std::move(aRunnable),
-                                                  kMaxConsoleOutputDelayMs,
-                                                  EventQueuePriority::Idle);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return;
-    }
-  } else {
-    nsCOMPtr<nsIRunnable> runnable(std::move(aRunnable));
-    nsresult rv = runnable->Run();
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return;
-    }
-  }
-}
-
-void ReportBlockingToConsole(uint64_t aWindowID, nsIURI* aURI,
-                             uint32_t aRejectedReason) {
-  MOZ_ASSERT(aWindowID);
-  MOZ_ASSERT(aURI);
-  MOZ_ASSERT(
-      aRejectedReason == 0 ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN ||
-      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
-      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
-
-  nsAutoString sourceLine;
-  uint32_t lineNumber = 0, columnNumber = 0;
-  JSContext* cx = nsContentUtils::GetCurrentJSContext();
-  if (cx) {
-    nsJSUtils::GetCallingLocation(cx, sourceLine, &lineNumber, &columnNumber);
-  }
-
-  nsCOMPtr<nsIURI> uri(aURI);
-
-  RefPtr<Runnable> runnable = NS_NewRunnableFunction(
-      "ReportBlockingToConsoleDelayed", [aWindowID, sourceLine, lineNumber,
-                                         columnNumber, uri, aRejectedReason]() {
-        const char* message = nullptr;
-        nsAutoCString category;
-        // When changing this list, please make sure to update the corresponding
-        // code in antitracking_head.js (inside _createTask).
-        switch (aRejectedReason) {
-          case nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION:
-            message = "CookieBlockedByPermission";
-            category = NS_LITERAL_CSTRING("cookieBlockedPermission");
-            break;
-
-          case nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER:
-            message = "CookieBlockedTracker";
-            category = NS_LITERAL_CSTRING("cookieBlockedTracker");
-            break;
-
-          case nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL:
-            message = "CookieBlockedAll";
-            category = NS_LITERAL_CSTRING("cookieBlockedAll");
-            break;
-
-          case nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN:
-            message = "CookieBlockedForeign";
-            category = NS_LITERAL_CSTRING("cookieBlockedForeign");
-            break;
-
-          default:
-            return;
-        }
-
-        MOZ_ASSERT(message);
-
-        // Strip the URL of any possible username/password and make it ready
-        // to be presented in the UI.
-        nsCOMPtr<nsIURIFixup> urifixup = services::GetURIFixup();
-        NS_ENSURE_TRUE_VOID(urifixup);
-        nsCOMPtr<nsIURI> exposableURI;
-        nsresult rv =
-            urifixup->CreateExposableURI(uri, getter_AddRefs(exposableURI));
-        NS_ENSURE_SUCCESS_VOID(rv);
-
-        AutoTArray<nsString, 1> params;
-        CopyUTF8toUTF16(exposableURI->GetSpecOrDefault(),
-                        *params.AppendElement());
-
-        nsAutoString errorText;
-        rv = nsContentUtils::FormatLocalizedString(
-            nsContentUtils::eNECKO_PROPERTIES, message, params, errorText);
-        NS_ENSURE_SUCCESS_VOID(rv);
-
-        nsContentUtils::ReportToConsoleByWindowID(
-            errorText, nsIScriptError::warningFlag, category, aWindowID,
-            nullptr, sourceLine, lineNumber, columnNumber);
-      });
-
-  RunConsoleReportingRunnable(runnable.forget());
-}
-
-void ReportBlockingToConsole(nsIChannel* aChannel, nsIURI* aURI,
-                             uint32_t aRejectedReason) {
-  MOZ_ASSERT(aChannel && aURI);
-
-  uint64_t windowID;
-
-  if (XRE_IsParentProcess()) {
-    // Get the top-level window ID from the top-level BrowsingContext
-    nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
-    RefPtr<dom::BrowsingContext> bc;
-    loadInfo->GetBrowsingContext(getter_AddRefs(bc));
-
-    if (!bc || bc->IsDiscarded()) {
-      return;
-    }
-
-    bc = bc->Top();
-    RefPtr<dom::WindowGlobalParent> wgp =
-        bc->Canonical()->GetCurrentWindowGlobal();
-    if (!wgp) {
-      return;
-    }
-
-    windowID = wgp->InnerWindowId();
-  } else {
-    nsresult rv;
-    nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel, &rv);
-
-    if (!httpChannel) {
-      return;
-    }
-
-    rv = httpChannel->GetTopLevelContentWindowId(&windowID);
-    if (NS_FAILED(rv) || !windowID) {
-      windowID = nsContentUtils::GetInnerWindowID(httpChannel);
-    }
-  }
-
-  ReportBlockingToConsole(windowID, aURI, aRejectedReason);
-}
-
-// This API finishes the remaining work left in NotifyBlockingDecision.
-void NotifyAllowDecision(nsIChannel* aReportingChannel,
-                         nsIChannel* aTrackingChannel, nsIURI* aURI,
-                         nsPIDOMWindowOuter* aWindow) {
-  nsAutoCString trackingOrigin;
-  if (aURI) {
-    Unused << nsContentUtils::GetASCIIOrigin(aURI, trackingOrigin);
-  }
-
-  // This can be called in either the parent process or the child processes.
-
-  // Now send the generic "cookies loaded" notifications, from the most generic
-  // to the most specific.
-  ContentBlockingNotifier::OnEvent(
-      aWindow, aReportingChannel, aTrackingChannel, false,
-      nsIWebProgressListener::STATE_COOKIES_LOADED, trackingOrigin);
-
-  nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
-      do_QueryInterface(aTrackingChannel);
-  if (!classifiedChannel) {
-    return;
-  }
-
-  uint32_t classificationFlags =
-      classifiedChannel->GetThirdPartyClassificationFlags();
-  if (classificationFlags &
-      nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_TRACKING) {
-    ContentBlockingNotifier::OnEvent(
-        aWindow, aReportingChannel, aTrackingChannel, false,
-        nsIWebProgressListener::STATE_COOKIES_LOADED_TRACKER, trackingOrigin);
-  }
-
-  if (classificationFlags &
-      nsIClassifiedChannel::ClassificationFlags::CLASSIFIED_SOCIALTRACKING) {
-    ContentBlockingNotifier::OnEvent(
-        aWindow, aReportingChannel, aTrackingChannel, false,
-        nsIWebProgressListener::STATE_COOKIES_LOADED_SOCIALTRACKER,
-        trackingOrigin);
-  }
-}
-
-void NotifyBlockingDecision(nsIChannel* aReportingChannel,
-                            nsIChannel* aTrackingChannel,
-                            ContentBlockingNotifier::BlockingDecision aDecision,
-                            uint32_t aRejectedReason, nsIURI* aURI,
-                            nsPIDOMWindowOuter* aWindow) {
-  MOZ_ASSERT(aWindow);
-
-  // When this is called with system priviledged, the decision should always be
-  // ALLOW, and we can also stop processing this event.
-  if (nsGlobalWindowOuter::Cast(aWindow)->GetPrincipal() ==
-      nsContentUtils::GetSystemPrincipal()) {
-    MOZ_DIAGNOSTIC_ASSERT(aDecision ==
-                          ContentBlockingNotifier::BlockingDecision::eAllow);
-    return;
-  }
-
-  nsAutoCString trackingOrigin;
-  if (aURI) {
-    Unused << nsContentUtils::GetASCIIOrigin(aURI, trackingOrigin);
-  }
-
-  if (aDecision == ContentBlockingNotifier::BlockingDecision::eBlock) {
-    ContentBlockingNotifier::OnEvent(aWindow, aReportingChannel,
-                                     aTrackingChannel, true, aRejectedReason,
-                                     trackingOrigin);
-
-    ReportBlockingToConsole(aReportingChannel, aURI, aRejectedReason);
-  }
-
-  NotifyAllowDecision(aReportingChannel, aTrackingChannel, aURI, aWindow);
-}
-
-void NotifyBlockingDecision(nsIChannel* aReportingChannel,
-                            nsIChannel* aTrackingChannel,
-                            ContentBlockingNotifier::BlockingDecision aDecision,
-                            uint32_t aRejectedReason, nsIURI* aURI) {
-  // Can be called only in the parent process when there is no window.
-  MOZ_ASSERT(XRE_IsParentProcess());
-
-  nsAutoCString trackingOrigin;
-  if (aURI) {
-    Unused << nsContentUtils::GetASCIIOrigin(aURI, trackingOrigin);
-  }
-
-  if (aDecision == ContentBlockingNotifier::BlockingDecision::eBlock) {
-    ContentBlockingNotifier::OnEvent(nullptr, aReportingChannel,
-                                     aTrackingChannel, true, aRejectedReason,
-                                     trackingOrigin);
-
-    ReportBlockingToConsole(aReportingChannel, aURI, aRejectedReason);
-  }
-
-  NotifyAllowDecision(aReportingChannel, aTrackingChannel, aURI, nullptr);
-}
-
-// Send a message to notify OnContentBlockingEvent in the parent, which will
-// update the ContentBlockingLog in the parent.
-void NotifyEventInChild(
-    nsPIDOMWindowOuter* aWindow, nsIChannel* aReportingChannel,
-    nsIChannel* aTrackingChannel, bool aBlocked, uint32_t aRejectedReason,
-    const nsACString& aTrackingOrigin,
-    const Maybe<ContentBlockingNotifier::StorageAccessGrantedReason>& aReason) {
-  MOZ_ASSERT(XRE_IsContentProcess());
-  MOZ_ASSERT(aWindow);
-
-  RefPtr<dom::BrowserChild> browserChild = dom::BrowserChild::GetFrom(aWindow);
-  NS_ENSURE_TRUE_VOID(browserChild);
-
-  nsTArray<nsCString> trackingFullHashes;
-  nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
-      do_QueryInterface(aTrackingChannel);
-
-  if (classifiedChannel) {
-    Unused << classifiedChannel->GetMatchedTrackingFullHashes(
-        trackingFullHashes);
-  }
-
-  browserChild->NotifyContentBlockingEvent(aRejectedReason, aReportingChannel,
-                                           aBlocked, aTrackingOrigin,
-                                           trackingFullHashes, aReason);
-}
-
-// Update the ContentBlockingLog of the top-level WindowGlobalParent of
-// the reporting channel.
-void NotifyEventInParent(
-    nsIChannel* aReportingChannel, nsIChannel* aTrackingChannel, bool aBlocked,
-    uint32_t aRejectedReason, const nsACString& aTrackingOrigin,
-    const Maybe<ContentBlockingNotifier::StorageAccessGrantedReason>& aReason) {
-  MOZ_ASSERT(XRE_IsParentProcess());
-
-  nsCOMPtr<nsILoadInfo> loadInfo = aReportingChannel->LoadInfo();
-  RefPtr<dom::BrowsingContext> bc;
-  loadInfo->GetBrowsingContext(getter_AddRefs(bc));
-
-  if (!bc || bc->IsDiscarded()) {
-    return;
-  }
-
-  bc = bc->Top();
-  RefPtr<dom::WindowGlobalParent> wgp =
-      bc->Canonical()->GetCurrentWindowGlobal();
-  NS_ENSURE_TRUE_VOID(wgp);
-
-  nsTArray<nsCString> trackingFullHashes;
-  nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
-      do_QueryInterface(aTrackingChannel);
-
-  if (classifiedChannel) {
-    Unused << classifiedChannel->GetMatchedTrackingFullHashes(
-        trackingFullHashes);
-  }
-
-  wgp->NotifyContentBlockingEvent(aRejectedReason, aReportingChannel, aBlocked,
-                                  aTrackingOrigin, trackingFullHashes, aReason);
-}
-
-}  // namespace
-
-/* static */ void ContentBlockingNotifier::ReportUnblockingToConsole(
-    nsPIDOMWindowInner* aWindow, const nsAString& aTrackingOrigin,
-    ContentBlockingNotifier::StorageAccessGrantedReason aReason) {
-  nsCOMPtr<nsIPrincipal> principal =
-      nsGlobalWindowInner::Cast(aWindow)->GetPrincipal();
-  if (NS_WARN_IF(!principal)) {
-    return;
-  }
-
-  RefPtr<Document> doc = aWindow->GetExtantDoc();
-  if (NS_WARN_IF(!doc)) {
-    return;
-  }
-
-  nsAutoString trackingOrigin(aTrackingOrigin);
-
-  nsAutoString sourceLine;
-  uint32_t lineNumber = 0, columnNumber = 0;
-  JSContext* cx = nsContentUtils::GetCurrentJSContext();
-  if (cx) {
-    nsJSUtils::GetCallingLocation(cx, sourceLine, &lineNumber, &columnNumber);
-  }
-
-  RefPtr<Runnable> runnable = NS_NewRunnableFunction(
-      "ReportUnblockingToConsoleDelayed",
-      [doc, principal, trackingOrigin, sourceLine, lineNumber, columnNumber,
-       aReason]() {
-        nsAutoString origin;
-        nsresult rv = nsContentUtils::GetUTFOrigin(principal, origin);
-        if (NS_WARN_IF(NS_FAILED(rv))) {
-          return;
-        }
-
-        // Not adding grantedOrigin yet because we may not want it later.
-        AutoTArray<nsString, 3> params = {origin, trackingOrigin};
-        const char* messageWithSameOrigin = nullptr;
-
-        switch (aReason) {
-          case ContentBlockingNotifier::eStorageAccessAPI:
-            messageWithSameOrigin = "CookieAllowedForTrackerByStorageAccessAPI";
-            break;
-
-          case ContentBlockingNotifier::eOpenerAfterUserInteraction:
-            [[fallthrough]];
-          case ContentBlockingNotifier::eOpener:
-            messageWithSameOrigin = "CookieAllowedForTrackerByHeuristic";
-            break;
-        }
-
-        nsContentUtils::ReportToConsole(
-            nsIScriptError::warningFlag, ANTITRACKING_CONSOLE_CATEGORY, doc,
-            nsContentUtils::eNECKO_PROPERTIES, messageWithSameOrigin, params,
-            nullptr, sourceLine, lineNumber, columnNumber);
-      });
-
-  RunConsoleReportingRunnable(runnable.forget());
-}
-
-/* static */
-void ContentBlockingNotifier::OnDecision(nsIChannel* aChannel,
-                                         BlockingDecision aDecision,
-                                         uint32_t aRejectedReason) {
-  MOZ_ASSERT(
-      aRejectedReason == 0 ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN ||
-      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
-      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
-  MOZ_ASSERT(aDecision == BlockingDecision::eBlock ||
-             aDecision == BlockingDecision::eAllow);
-
-  if (!aChannel) {
-    return;
-  }
-
-  nsCOMPtr<nsIURI> uri;
-  aChannel->GetURI(getter_AddRefs(uri));
-
-  // Can be called in EITHER the parent or child process.
-  // Window is only needed while in child processes.
-  if (XRE_IsParentProcess()) {
-    NotifyBlockingDecision(aChannel, aChannel, aDecision, aRejectedReason, uri);
-    return;
-  }
-
-  MOZ_ASSERT(XRE_IsContentProcess());
-
-  nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
-  if (!thirdPartyUtil) {
-    return;
-  }
-
-  nsCOMPtr<nsIURI> uriBeingLoaded =
-      AntiTrackingUtils::MaybeGetDocumentURIBeingLoaded(aChannel);
-  nsCOMPtr<mozIDOMWindowProxy> win;
-  nsresult rv = thirdPartyUtil->GetTopWindowForChannel(aChannel, uriBeingLoaded,
-                                                       getter_AddRefs(win));
-  NS_ENSURE_SUCCESS_VOID(rv);
-
-  nsCOMPtr<nsPIDOMWindowOuter> pwin = nsPIDOMWindowOuter::From(win);
-  if (!pwin) {
-    return;
-  }
-
-  NotifyBlockingDecision(aChannel, aChannel, aDecision, aRejectedReason, uri,
-                         pwin);
-}
-
-/* static */
-void ContentBlockingNotifier::OnDecision(nsPIDOMWindowInner* aWindow,
-                                         BlockingDecision aDecision,
-                                         uint32_t aRejectedReason) {
-  MOZ_ASSERT(aWindow);
-  MOZ_ASSERT(
-      aRejectedReason == 0 ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER ||
-      aRejectedReason ==
-          nsIWebProgressListener::STATE_COOKIES_PARTITIONED_FOREIGN ||
-      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
-      aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
-  MOZ_ASSERT(aDecision == BlockingDecision::eBlock ||
-             aDecision == BlockingDecision::eAllow);
-
-  nsCOMPtr<nsPIDOMWindowOuter> pwin = AntiTrackingUtils::GetTopWindow(aWindow);
-  if (!pwin) {
-    return;
-  }
-
-  nsPIDOMWindowInner* inner = pwin->GetCurrentInnerWindow();
-  if (!inner) {
-    return;
-  }
-  Document* pwinDoc = inner->GetExtantDoc();
-  if (!pwinDoc) {
-    return;
-  }
-  nsIChannel* channel = pwinDoc->GetChannel();
-  if (!channel) {
-    return;
-  }
-
-  Document* document = aWindow->GetExtantDoc();
-  if (!document) {
-    return;
-  }
-  nsIURI* uri = document->GetDocumentURI();
-  nsIChannel* trackingChannel = document->GetChannel();
-
-  NotifyBlockingDecision(channel, trackingChannel, aDecision, aRejectedReason,
-                         uri, pwin);
-}
-
-/* static */
-void ContentBlockingNotifier::OnEvent(nsIChannel* aChannel,
-                                      uint32_t aRejectedReason) {
-  MOZ_ASSERT(XRE_IsParentProcess() && aChannel);
-
-  nsCOMPtr<nsIURI> uri;
-  aChannel->GetURI(getter_AddRefs(uri));
-
-  nsAutoCString trackingOrigin;
-  if (uri) {
-    Unused << nsContentUtils::GetASCIIOrigin(uri, trackingOrigin);
-  }
-
-  return ContentBlockingNotifier::OnEvent(nullptr, aChannel, aChannel, true,
-                                          aRejectedReason, trackingOrigin);
-}
-
-/* static */
-void ContentBlockingNotifier::OnEvent(
-    nsPIDOMWindowOuter* aWindow, nsIChannel* aReportingChannel,
-    nsIChannel* aTrackingChannel, bool aBlocked, uint32_t aRejectedReason,
-    const nsACString& aTrackingOrigin,
-    const Maybe<StorageAccessGrantedReason>& aReason) {
-  if (XRE_IsParentProcess()) {
-    NotifyEventInParent(aReportingChannel, aTrackingChannel, aBlocked,
-                        aRejectedReason, aTrackingOrigin, aReason);
-  } else {
-    NotifyEventInChild(aWindow, aReportingChannel, aTrackingChannel, aBlocked,
-                       aRejectedReason, aTrackingOrigin, aReason);
-  }
-}
deleted file mode 100644
--- a/toolkit/components/antitracking/ContentBlockingNotifier.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_contentblockingnotifier_h
-#define mozilla_contentblockingnotifier_h
-
-#include "nsStringFwd.h"
-#include "mozilla/Maybe.h"
-
-#define ANTITRACKING_CONSOLE_CATEGORY NS_LITERAL_CSTRING("Content Blocking")
-
-class nsIChannel;
-class nsPIDOMWindowInner;
-class nsPIDOMWindowOuter;
-
-namespace mozilla {
-
-class ContentBlockingNotifier final {
- public:
-  enum class BlockingDecision {
-    eBlock,
-    eAllow,
-  };
-  enum StorageAccessGrantedReason {
-    eStorageAccessAPI,
-    eOpenerAfterUserInteraction,
-    eOpener
-  };
-
-  // This method can be called on the parent process or on the content process.
-  // The notification is propagated to the child channel if aChannel is a parent
-  // channel proxy.
-  //
-  // aDecision can be eBlock if we have decided to block some content, or eAllow
-  // if we have decided to allow the content through.
-  //
-  // aRejectedReason must be one of these values:
-  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION
-  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER
-  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER
-  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL
-  //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
-  static void OnDecision(nsIChannel* aChannel, BlockingDecision aDecision,
-                         uint32_t aRejectedReason);
-
-  static void OnDecision(nsPIDOMWindowInner* aWindow,
-                         BlockingDecision aDecision, uint32_t aRejectedReason);
-
-  static void OnEvent(nsIChannel* aChannel, uint32_t aRejectedReason);
-
-  static void OnEvent(
-      nsPIDOMWindowOuter* aWindow, nsIChannel* aReportingChannel,
-      nsIChannel* aTrackingChannel, bool aBlocked, uint32_t aRejectedReason,
-      const nsACString& aTrackingOrigin,
-      const Maybe<StorageAccessGrantedReason>& aReason = Nothing());
-
-  static void ReportUnblockingToConsole(nsPIDOMWindowInner* aWindow,
-                                        const nsAString& aTrackingOrigin,
-                                        StorageAccessGrantedReason aReason);
-};
-
-}  // namespace mozilla
-
-#endif  // mozilla_contentblockingnotifier_h
deleted file mode 100644
--- a/toolkit/components/antitracking/ContentBlockingUserInteraction.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "AntiTrackingLog.h"
-#include "ContentBlockingUserInteraction.h"
-#include "AntiTrackingUtils.h"
-
-#include "mozilla/dom/ContentChild.h"
-#include "nsIPrincipal.h"
-#include "nsPermissionManager.h"
-#include "nsXULAppAPI.h"
-#include "prtime.h"
-
-namespace mozilla {
-
-/* static */
-void ContentBlockingUserInteraction::Observe(nsIPrincipal* aPrincipal) {
-  if (!aPrincipal) {
-    // The content process may have sent us garbage data.
-    return;
-  }
-
-  if (XRE_IsParentProcess()) {
-    LOG_PRIN(("Saving the userInteraction for %s", _spec), aPrincipal);
-
-    nsPermissionManager* permManager = nsPermissionManager::GetInstance();
-    if (NS_WARN_IF(!permManager)) {
-      LOG(("Permission manager is null, bailing out early"));
-      return;
-    }
-
-    // Remember that this pref is stored in seconds!
-    uint32_t expirationType = nsIPermissionManager::EXPIRE_TIME;
-    uint32_t expirationTime =
-        StaticPrefs::privacy_userInteraction_expiration() * 1000;
-    int64_t when = (PR_Now() / PR_USEC_PER_MSEC) + expirationTime;
-
-    uint32_t privateBrowsingId = 0;
-    nsresult rv = aPrincipal->GetPrivateBrowsingId(&privateBrowsingId);
-    if (!NS_WARN_IF(NS_FAILED(rv)) && privateBrowsingId > 0) {
-      // If we are coming from a private window, make sure to store a
-      // session-only permission which won't get persisted to disk.
-      expirationType = nsIPermissionManager::EXPIRE_SESSION;
-      when = 0;
-    }
-
-    rv = permManager->AddFromPrincipal(aPrincipal, USER_INTERACTION_PERM,
-                                       nsIPermissionManager::ALLOW_ACTION,
-                                       expirationType, when);
-    Unused << NS_WARN_IF(NS_FAILED(rv));
-    return;
-  }
-
-  dom::ContentChild* cc = dom::ContentChild::GetSingleton();
-  MOZ_ASSERT(cc);
-
-  LOG_PRIN(("Asking the parent process to save the user-interaction for us: %s",
-            _spec),
-           aPrincipal);
-  cc->SendStoreUserInteractionAsPermission(IPC::Principal(aPrincipal));
-}
-
-/* static */
-bool ContentBlockingUserInteraction::Exists(nsIPrincipal* aPrincipal) {
-  nsPermissionManager* permManager = nsPermissionManager::GetInstance();
-  if (NS_WARN_IF(!permManager)) {
-    return false;
-  }
-
-  uint32_t result = 0;
-  nsresult rv = permManager->TestPermissionWithoutDefaultsFromPrincipal(
-      aPrincipal, USER_INTERACTION_PERM, &result);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return false;
-  }
-
-  return result == nsIPermissionManager::ALLOW_ACTION;
-}
-
-}  // namespace mozilla
deleted file mode 100644
--- a/toolkit/components/antitracking/ContentBlockingUserInteraction.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_contentblockinguserinteraction_h
-#define mozilla_contentblockinguserinteraction_h
-
-#define USER_INTERACTION_PERM NS_LITERAL_CSTRING("storageAccessAPI")
-
-class nsIPrincipal;
-
-namespace mozilla {
-
-class ContentBlockingUserInteraction final {
- public:
-  // Used to remember that we observed a user interaction that is significant
-  // for content blocking.
-  static void Observe(nsIPrincipal* aPrincipal);
-
-  // Used to query whether we've observed a user interaction that is significant
-  // for content blocking for the given principal in the past.
-  static bool Exists(nsIPrincipal* aPrincipal);
-};
-
-}  // namespace mozilla
-
-#endif  // mozilla_contentblockinguserinteraction_h
--- a/toolkit/components/antitracking/SettingsChangeObserver.cpp
+++ b/toolkit/components/antitracking/SettingsChangeObserver.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SettingsChangeObserver.h"
-#include "ContentBlockingUserInteraction.h"
+#include "AntiTrackingCommon.h"
 
 #include "mozilla/Services.h"
 #include "mozilla/Preferences.h"
 #include "nsIObserverService.h"
 #include "nsIPermission.h"
 #include "nsTArray.h"
 
 using namespace mozilla;
--- a/toolkit/components/antitracking/StorageAccess.cpp
+++ b/toolkit/components/antitracking/StorageAccess.cpp
@@ -1,31 +1,24 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/Document.h"
 #include "mozilla/net/CookieJarSettings.h"
-#include "mozilla/ContentBlocking.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/StaticPrefs_browser.h"
 #include "mozilla/StaticPrefs_network.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "mozilla/StorageAccess.h"
-#include "nsContentUtils.h"
-#include "nsICookiePermission.h"
 #include "nsICookieService.h"
 #include "nsICookieJarSettings.h"
-#include "nsIPermission.h"
 #include "nsIWebProgressListener.h"
-#include "nsSandboxFlags.h"
-
-using namespace mozilla;
-using namespace mozilla::dom;
 
 /**
  * Gets the cookie lifetime policy for a given cookieJarSettings and a given
  * principal by checking the permission value.
  *
  * Used in the implementation of InternalStorageAllowedCheck.
  */
 static void GetCookieLifetimePolicyFromCookieJarSettings(
@@ -170,33 +163,35 @@ static StorageAccess InternalStorageAllo
 static bool StorageDisabledByAntiTrackingInternal(
     nsPIDOMWindowInner* aWindow, nsIChannel* aChannel, nsIPrincipal* aPrincipal,
     nsIURI* aURI, nsICookieJarSettings* aCookieJarSettings,
     uint32_t& aRejectedReason) {
   MOZ_ASSERT(aWindow || aChannel || aPrincipal);
 
   if (aWindow) {
     nsIURI* documentURI = aURI ? aURI : aWindow->GetDocumentURI();
-    return !documentURI || !ContentBlocking::ShouldAllowAccessFor(
-                               aWindow, documentURI, &aRejectedReason);
+    return !documentURI ||
+           !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+               aWindow, documentURI, &aRejectedReason);
   }
 
   if (aChannel) {
     nsCOMPtr<nsIURI> uri;
     nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return false;
     }
 
-    return !ContentBlocking::ShouldAllowAccessFor(aChannel, uri,
-                                                  &aRejectedReason);
+    return !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+        aChannel, uri, &aRejectedReason);
   }
 
   MOZ_ASSERT(aPrincipal);
-  return !ContentBlocking::ShouldAllowAccessFor(aPrincipal, aCookieJarSettings);
+  return !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+      aPrincipal, aCookieJarSettings);
 }
 
 namespace mozilla {
 
 StorageAccess StorageAllowedForWindow(nsPIDOMWindowInner* aWindow,
                                       uint32_t* aRejectedReason) {
   uint32_t rejectedReason;
   if (!aRejectedReason) {
@@ -300,26 +295,26 @@ bool StorageDisabledByAntiTracking(nsPID
     Unused << loadInfo->GetCookieJarSettings(getter_AddRefs(cookieJarSettings));
   }
   if (!cookieJarSettings) {
     cookieJarSettings = net::CookieJarSettings::Create();
   }
   bool disabled = StorageDisabledByAntiTrackingInternal(
       aWindow, aChannel, aPrincipal, aURI, cookieJarSettings, aRejectedReason);
   if (aWindow) {
-    ContentBlockingNotifier::OnDecision(
+    AntiTrackingCommon::NotifyBlockingDecision(
         aWindow,
-        disabled ? ContentBlockingNotifier::BlockingDecision::eBlock
-                 : ContentBlockingNotifier::BlockingDecision::eAllow,
+        disabled ? AntiTrackingCommon::BlockingDecision::eBlock
+                 : AntiTrackingCommon::BlockingDecision::eAllow,
         aRejectedReason);
   } else if (aChannel) {
-    ContentBlockingNotifier::OnDecision(
+    AntiTrackingCommon::NotifyBlockingDecision(
         aChannel,
-        disabled ? ContentBlockingNotifier::BlockingDecision::eBlock
-                 : ContentBlockingNotifier::BlockingDecision::eAllow,
+        disabled ? AntiTrackingCommon::BlockingDecision::eBlock
+                 : AntiTrackingCommon::BlockingDecision::eAllow,
         aRejectedReason);
   }
   return disabled;
 }
 
 bool ShouldPartitionStorage(StorageAccess aAccess) {
   return aAccess == StorageAccess::ePartitionTrackersOrDeny ||
          aAccess == StorageAccess::ePartitionForeignOrDeny;
--- a/toolkit/components/antitracking/StoragePrincipalHelper.cpp
+++ b/toolkit/components/antitracking/StoragePrincipalHelper.cpp
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "StoragePrincipalHelper.h"
 
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
-#include "mozilla/ContentBlocking.h"
+#include "mozilla/AntiTrackingCommon.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/StorageAccess.h"
 #include "nsContentUtils.h"
 
 namespace mozilla {
 
 namespace {
 
@@ -27,22 +27,23 @@ bool ChooseOriginAttributes(nsIChannel* 
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
   if (NS_FAILED(rv)) {
     return false;
   }
 
   uint32_t rejectedReason = 0;
-  if (ContentBlocking::ShouldAllowAccessFor(aChannel, uri, &rejectedReason)) {
+  if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
+          aChannel, uri, &rejectedReason)) {
     return false;
   }
 
   // Let's use the storage principal only if we need to partition the cookie
-  // jar.  We use the lower-level ContentBlocking API here to ensure this
+  // jar.  We use the lower-level AntiTrackingCommon API here to ensure this
   // check doesn't send notifications.
   if (!ShouldPartitionStorage(rejectedReason) ||
       !StoragePartitioningEnabled(rejectedReason, cjs)) {
     return false;
   }
 
   nsCOMPtr<nsIPrincipal> toplevelPrincipal = loadInfo->GetTopLevelPrincipal();
   if (!toplevelPrincipal) {
--- a/toolkit/components/antitracking/StoragePrincipalHelper.h
+++ b/toolkit/components/antitracking/StoragePrincipalHelper.h
@@ -2,18 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_StoragePrincipalHelper_h
 #define mozilla_StoragePrincipalHelper_h
 
-#include "nsError.h"
-
 /**
  * StoragePrincipal
  * ~~~~~~~~~~~~~~~~
  *
  * StoragePrincipal is the nsIPrincipal to be used to open the cookie jar of a
  * resource's origin. Normally, the StoragePrincipal corresponds to the
  * resource's origin, but, in some scenarios, it can be different: it can have
  * some extra origin attributes.
deleted file mode 100644
--- a/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TemporaryAccessGrantObserver.h"
-
-#include "nsIObserverService.h"
-#include "nsPermissionManager.h"
-#include "nsTHashtable.h"
-#include "nsXULAppAPI.h"
-
-using namespace mozilla;
-
-UniquePtr<TemporaryAccessGrantObserver::ObserversTable>
-    TemporaryAccessGrantObserver::sObservers;
-
-TemporaryAccessGrantObserver::TemporaryAccessGrantObserver(
-    nsPermissionManager* aPM, nsIPrincipal* aPrincipal, const nsACString& aType)
-    : mPM(aPM), mPrincipal(aPrincipal), mType(aType) {
-  MOZ_ASSERT(XRE_IsParentProcess(),
-             "Enforcing temporary access grant lifetimes can only be done in "
-             "the parent process");
-}
-
-NS_IMPL_ISUPPORTS(TemporaryAccessGrantObserver, nsIObserver)
-
-// static
-void TemporaryAccessGrantObserver::Create(nsPermissionManager* aPM,
-                                          nsIPrincipal* aPrincipal,
-                                          const nsACString& aType) {
-  MOZ_ASSERT(XRE_IsParentProcess());
-
-  if (!sObservers) {
-    sObservers = MakeUnique<ObserversTable>();
-  }
-  Unused << sObservers
-                ->LookupForAdd(MakePair(nsCOMPtr<nsIPrincipal>(aPrincipal),
-                                        nsCString(aType)))
-                .OrInsert([&]() -> nsITimer* {
-                  // Only create a new observer if we don't have a matching
-                  // entry in our hashtable.
-                  nsCOMPtr<nsITimer> timer;
-                  RefPtr<TemporaryAccessGrantObserver> observer =
-                      new TemporaryAccessGrantObserver(aPM, aPrincipal, aType);
-                  nsresult rv =
-                      NS_NewTimerWithObserver(getter_AddRefs(timer), observer,
-                                              24 * 60 * 60 * 1000,  // 24 hours
-                                              nsITimer::TYPE_ONE_SHOT);
-
-                  if (NS_SUCCEEDED(rv)) {
-                    observer->SetTimer(timer);
-                    return timer;
-                  }
-                  timer->Cancel();
-                  return nullptr;
-                });
-}
-
-void TemporaryAccessGrantObserver::SetTimer(nsITimer* aTimer) {
-  mTimer = aTimer;
-  nsCOMPtr<nsIObserverService> observerService =
-      mozilla::services::GetObserverService();
-  if (observerService) {
-    observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
-  }
-}
-
-NS_IMETHODIMP
-TemporaryAccessGrantObserver::Observe(nsISupports* aSubject, const char* aTopic,
-                                      const char16_t* aData) {
-  if (strcmp(aTopic, NS_TIMER_CALLBACK_TOPIC) == 0) {
-    Unused << mPM->RemoveFromPrincipal(mPrincipal, mType);
-
-    MOZ_ASSERT(sObservers);
-    sObservers->Remove(MakePair(mPrincipal, mType));
-  } else if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
-    nsCOMPtr<nsIObserverService> observerService =
-        mozilla::services::GetObserverService();
-    if (observerService) {
-      observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
-    }
-    if (mTimer) {
-      mTimer->Cancel();
-      mTimer = nullptr;
-    }
-    sObservers.reset();
-  }
-
-  return NS_OK;
-}
deleted file mode 100644
--- a/toolkit/components/antitracking/TemporaryAccessGrantObserver.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_temporaryaccessgrantobserver_h
-#define mozilla_temporaryaccessgrantobserver_h
-
-#include "mozilla/BasePrincipal.h"
-#include "nsCOMPtr.h"
-#include "nsHashKeys.h"
-#include "nsIObserver.h"
-#include "nsString.h"
-#include "PLDHashTable.h"
-
-template <class, class>
-class nsDataHashtable;
-class nsITimer;
-class nsPermissionManager;
-class TemporaryAccessGrantCacheKey;
-
-namespace mozilla {
-
-class TemporaryAccessGrantCacheKey : public PLDHashEntryHdr {
- public:
-  typedef Pair<nsCOMPtr<nsIPrincipal>, nsCString> KeyType;
-  typedef const KeyType* KeyTypePointer;
-
-  explicit TemporaryAccessGrantCacheKey(KeyTypePointer aKey)
-      : mPrincipal(aKey->first()), mType(aKey->second()) {}
-  TemporaryAccessGrantCacheKey(TemporaryAccessGrantCacheKey&& aOther) = default;
-
-  ~TemporaryAccessGrantCacheKey() = default;
-
-  KeyType GetKey() const { return MakePair(mPrincipal, mType); }
-  bool KeyEquals(KeyTypePointer aKey) const {
-    return !!mPrincipal == !!aKey->first() && mType == aKey->second() &&
-           (mPrincipal ? (mPrincipal->Equals(aKey->first())) : true);
-  }
-
-  static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
-  static PLDHashNumber HashKey(KeyTypePointer aKey) {
-    if (!aKey) {
-      return 0;
-    }
-
-    BasePrincipal* bp = BasePrincipal::Cast(aKey->first());
-    return HashGeneric(bp->GetOriginNoSuffixHash(), bp->GetOriginSuffixHash(),
-                       HashString(aKey->second()));
-  }
-
-  enum { ALLOW_MEMMOVE = true };
-
- private:
-  nsCOMPtr<nsIPrincipal> mPrincipal;
-  nsCString mType;
-};
-
-class TemporaryAccessGrantObserver final : public nsIObserver {
- public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIOBSERVER
-
-  static void Create(nsPermissionManager* aPM, nsIPrincipal* aPrincipal,
-                     const nsACString& aType);
-
-  void SetTimer(nsITimer* aTimer);
-
- private:
-  TemporaryAccessGrantObserver(nsPermissionManager* aPM,
-                               nsIPrincipal* aPrincipal,
-                               const nsACString& aType);
-  ~TemporaryAccessGrantObserver() = default;
-
- private:
-  typedef nsDataHashtable<TemporaryAccessGrantCacheKey, nsCOMPtr<nsITimer>>
-      ObserversTable;
-  static UniquePtr<ObserversTable> sObservers;
-  nsCOMPtr<nsITimer> mTimer;
-  RefPtr<nsPermissionManager> mPM;
-  nsCOMPtr<nsIPrincipal> mPrincipal;
-  nsCString mType;
-};
-
-}  // namespace mozilla
-
-#endif  // mozilla_temporaryaccessgrantobserver_h
--- a/toolkit/components/antitracking/URLDecorationStripper.cpp
+++ b/toolkit/components/antitracking/URLDecorationStripper.cpp
@@ -5,17 +5,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "URLDecorationStripper.h"
 
 #include "mozilla/dom/URLSearchParams.h"
 #include "mozilla/Preferences.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsEffectiveTLDService.h"
-#include "nsIURI.h"
 #include "nsIURIMutator.h"
 
 namespace {
 static const char* kPrefName =
     "privacy.restrict3rdpartystorage.url_decorations";
 
 inline bool IgnoreWhitespace(char16_t c) { return false; }
 }  // namespace
--- a/toolkit/components/antitracking/moz.build
+++ b/toolkit/components/antitracking/moz.build
@@ -26,41 +26,30 @@ EXTRA_JS_MODULES += [
     'URLDecorationAnnotationsService.jsm',
 ]
 
 XPCOM_MANIFESTS += [
     'components.conf',
 ]
 
 EXPORTS.mozilla = [
+    'AntiTrackingCommon.h',
     'AntiTrackingIPCUtils.h',
-    'AntiTrackingRedirectHeuristic.h',
-    'AntiTrackingUtils.h',
-    'ContentBlocking.h',
     'ContentBlockingAllowList.h',
-    'ContentBlockingLog.h',
-    'ContentBlockingNotifier.h',
-    'ContentBlockingUserInteraction.h',
     'StorageAccess.h',
     'StoragePrincipalHelper.h',
     'URLDecorationStripper.h',
 ]
 
 UNIFIED_SOURCES += [
-    'AntiTrackingRedirectHeuristic.cpp',
-    'AntiTrackingUtils.cpp',
-    'ContentBlocking.cpp',
+    'AntiTrackingCommon.cpp',
     'ContentBlockingAllowList.cpp',
-    'ContentBlockingLog.cpp',
-    'ContentBlockingNotifier.cpp',
-    'ContentBlockingUserInteraction.cpp',
     'SettingsChangeObserver.cpp',
     'StorageAccess.cpp',
     'StoragePrincipalHelper.cpp',
-    'TemporaryAccessGrantObserver.cpp',
     'URLDecorationStripper.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/extensions/permissions',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
--- a/toolkit/components/telemetry/tests/gtest/TestOrigins.cpp
+++ b/toolkit/components/telemetry/tests/gtest/TestOrigins.cpp
@@ -1,17 +1,17 @@
 /* vim:set ts=2 sw=2 sts=2 et: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 #include "core/TelemetryOrigin.h"
 #include "gtest/gtest.h"
 #include "gmock/gmock.h"
-#include "mozilla/ContentBlockingLog.h"
+#include "mozilla/dom/ContentBlockingLog.h"
 #include "mozilla/Services.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Unused.h"
 #include "nsIObserverService.h"
 #include "TelemetryFixture.h"
 #include "TelemetryTestHelpers.h"
 
 using namespace mozilla;
@@ -43,34 +43,34 @@ NS_NAMED_LITERAL_CSTRING(
 // Test that we can properly record origin stuff using the C++ API.
 TEST_F(TelemetryTestFixture, RecordOrigin) {
   AutoJSContextWithGlobal cx(mCleanGlobal);
   JSContext* aCx = cx.GetJSContext();
 
   Unused << mTelemetry->ClearOrigins();
 
   Telemetry::RecordOrigin(OriginMetricID::TelemetryTest_Test1,
-                          mozilla::ContentBlockingLog::kDummyOriginHash);
+                          mozilla::dom::ContentBlockingLog::kDummyOriginHash);
 
   JS::RootedValue originSnapshot(aCx);
   GetOriginSnapshot(aCx, &originSnapshot);
 
   ASSERT_FALSE(originSnapshot.isNullOrUndefined())
   << "Origin snapshot must not be null/undefined.";
 
   JS::RootedValue origins(aCx);
   JS::RootedObject snapshotObj(aCx, &originSnapshot.toObject());
   ASSERT_TRUE(
       JS_GetProperty(aCx, snapshotObj, kTelemetryTest1Metric.get(), &origins))
   << "telemetry.test_test1 must be in the snapshot.";
 
   JS::RootedObject originsObj(aCx, &origins.toObject());
   JS::RootedValue count(aCx);
   ASSERT_TRUE(JS_GetProperty(
-      aCx, originsObj, mozilla::ContentBlockingLog::kDummyOriginHash.get(),
+      aCx, originsObj, mozilla::dom::ContentBlockingLog::kDummyOriginHash.get(),
       &count));
   ASSERT_TRUE(count.isInt32() && count.toInt32() == 1)
   << "Must have recorded the origin exactly once.";
 
   // Now test that the snapshot didn't clear things out.
   GetOriginSnapshot(aCx, &originSnapshot);
   ASSERT_FALSE(originSnapshot.isNullOrUndefined());
   JS::RootedObject unemptySnapshotObj(aCx, &originSnapshot.toObject());