diff --git a/build/win32/orderfile.txt b/build/win32/orderfile.txt index e9ffd0477db3..9c5973c368cc 100644 --- a/build/win32/orderfile.txt +++ b/build/win32/orderfile.txt @@ -19404,7 +19404,6 @@ Gecko_BeginWritingCString ?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 @@ -19532,7 +19531,6 @@ XPCOMService_GetThirdPartyUtil ?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 @@ -19548,12 +19546,10 @@ XPCOMService_GetThirdPartyUtil ?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 @@ -26368,7 +26364,6 @@ Gecko_AppendPropertyValuePair ?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 diff --git a/build/win64/orderfile.txt b/build/win64/orderfile.txt index 4d8b55209951..1df3ef30f4d1 100644 --- a/build/win64/orderfile.txt +++ b/build/win64/orderfile.txt @@ -19322,7 +19322,6 @@ Gecko_BeginWritingCString ?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 @@ -19443,7 +19442,6 @@ XPCOMService_GetThirdPartyUtil ?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 @@ -19464,12 +19462,10 @@ XPCOMService_GetThirdPartyUtil ?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 @@ -26335,7 +26331,6 @@ UnregisterWeakMemoryReporter ?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 @@ -26670,7 +26665,6 @@ Gecko_AppendPropertyValuePair ?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 diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 24d4affb78cb..9d2c87365049 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -11,11 +11,11 @@ #include "AudioChannelService.h" #include "mozilla/dom/Document.h" #include "DocumentInlines.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/AntiTrackingUtils.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" @@ -15066,7 +15066,7 @@ void Document::MaybeAllowStorageForOpenerAfterUserInteraction() { } // We don't care when the asynchronous work finishes here. - Unused << AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor( + Unused << ContentBlocking::AllowAccessFor( NodePrincipal(), openerInner, ContentBlockingNotifier::eOpenerAfterUserInteraction); } @@ -15639,10 +15639,11 @@ already_AddRefed Document::RequestStorageAccess( RefPtr self(this); - auto performFinalChecks = [inner, self]() - -> RefPtr { - RefPtr p = - new AntiTrackingCommon::StorageAccessFinalCheckPromise::Private( + auto performFinalChecks = + [inner, + self]() -> RefPtr { + RefPtr p = + new ContentBlocking::StorageAccessFinalCheckPromise::Private( __func__); RefPtr sapr = StorageAccessPermissionRequest::Create( @@ -15651,7 +15652,7 @@ already_AddRefed Document::RequestStorageAccess( [p] { Telemetry::AccumulateCategorical( Telemetry::LABELS_STORAGE_ACCESS_API_UI::Allow); - p->Resolve(AntiTrackingCommon::eAllow, __func__); + p->Resolve(ContentBlocking::eAllow, __func__); }, // Block [p] { @@ -15696,10 +15697,10 @@ already_AddRefed Document::RequestStorageAccess( MOZ_ASSERT_IF(pr2 != PromptResult::Granted, pr2 == PromptResult::Denied); if (pr2 == PromptResult::Granted) { - AntiTrackingCommon::StorageAccessPromptChoices choice = - AntiTrackingCommon::eAllow; + ContentBlocking::StorageAccessPromptChoices choice = + ContentBlocking::eAllow; if (autoGrant) { - choice = AntiTrackingCommon::eAllowAutoGrant; + choice = ContentBlocking::eAllowAutoGrant; } if (!autoGrant) { p->Resolve(choice, __func__); @@ -15722,7 +15723,7 @@ already_AddRefed Document::RequestStorageAccess( return std::move(p); }; - AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor( + ContentBlocking::AllowAccessFor( NodePrincipal(), inner, ContentBlockingNotifier::eStorageAccessAPI, performFinalChecks) ->Then( @@ -16046,11 +16047,11 @@ nsIPrincipal* Document::EffectiveStoragePrincipal() const { return mActiveStoragePrincipal; } - // We use the lower-level AntiTrackingCommon API here to ensure this + // We use the lower-level ContentBlocking API here to ensure this // check doesn't send notifications. uint32_t rejectedReason = 0; - if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - inner, GetDocumentURI(), &rejectedReason)) { + if (ContentBlocking::ShouldAllowAccessFor(inner, GetDocumentURI(), + &rejectedReason)) { return mActiveStoragePrincipal = NodePrincipal(); } diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 63f0b3233595..89e044f8c8a6 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -11,7 +11,7 @@ #include "nsIXULAppInfo.h" #include "nsPluginArray.h" #include "nsMimeTypeArray.h" -#include "mozilla/AntiTrackingCommon.h" +#include "mozilla/ContentBlocking.h" #include "mozilla/ContentBlockingNotifier.h" #include "mozilla/MemoryReporting.h" #include "mozilla/dom/BodyExtractor.h" @@ -528,8 +528,8 @@ bool Navigator::CookieEnabled() { } uint32_t rejectedReason = 0; - bool granted = AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - mWindow, contentURI, &rejectedReason); + bool granted = ContentBlocking::ShouldAllowAccessFor(mWindow, contentURI, + &rejectedReason); ContentBlockingNotifier::OnDecision( mWindow, diff --git a/dom/base/ThirdPartyUtil.cpp b/dom/base/ThirdPartyUtil.cpp index 7fc065fafb63..be469cc959be 100644 --- a/dom/base/ThirdPartyUtil.cpp +++ b/dom/base/ThirdPartyUtil.cpp @@ -19,6 +19,7 @@ #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" @@ -493,8 +494,8 @@ ThirdPartyUtil::AnalyzeChannel(nsIChannel* aChannel, bool aNotify, nsIURI* aURI, aRequireThirdPartyCheck ? result.contains(ThirdPartyAnalysis::IsForeign) : true; if (performStorageChecks && - AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - aChannel, aURI ? aURI : uri.get(), aRejectedReason)) { + ContentBlocking::ShouldAllowAccessFor(aChannel, aURI ? aURI : uri.get(), + aRejectedReason)) { result += ThirdPartyAnalysis::IsFirstPartyStorageAccessGranted; } diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index e445de694e5b..4e50f62515e2 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -33,7 +33,6 @@ #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" diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index d6934fde0e8a..7e3b8eb706f7 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -4400,8 +4400,8 @@ Storage* nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError) { // it may be okay to provide SessionStorage even when we receive a value of // eDeny. // - // AntiTrackingCommon::IsFirstPartyStorageAccessGranted will return false - // for 3 main reasons. + // ContentBlocking::ShouldAllowAccessFor 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 diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 6bbb90dc9ef5..602096089508 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -21,8 +21,8 @@ #include "nsIPermissionManager.h" #include "nsISecureBrowserUI.h" #include "nsIWebProgressListener.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/AntiTrackingUtils.h" +#include "mozilla/ContentBlocking.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/BrowserChild.h" #include "mozilla/dom/BrowsingContextBinding.h" @@ -2482,8 +2482,8 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument, // permission has been granted already. // Don't notify in this case, since we would be notifying the user // needlessly. - mHasStorageAccess = AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - newInnerWindow, uri, nullptr); + mHasStorageAccess = + ContentBlocking::ShouldAllowAccessFor(newInnerWindow, uri, nullptr); } return NS_OK; @@ -7184,8 +7184,8 @@ void nsGlobalWindowOuter::MaybeAllowStorageForOpenedWindow(nsIURI* aURI) { aURI, doc->NodePrincipal()->OriginAttributesRef()); // We don't care when the asynchronous work finishes here. - Unused << AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor( - principal, inner, ContentBlockingNotifier::eOpener); + Unused << ContentBlocking::AllowAccessFor(principal, inner, + ContentBlockingNotifier::eOpener); } //***************************************************************************** diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index a0fba102ccf5..87afe21f1e81 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -13,7 +13,6 @@ #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" diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index cbb6e9d67617..15ff982fc366 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -40,7 +40,7 @@ #include "URIUtils.h" #include "gfxPlatform.h" #include "gfxPlatformFontList.h" -#include "mozilla/AntiTrackingCommon.h" +#include "mozilla/ContentBlocking.h" #include "mozilla/BasePrincipal.h" #include "mozilla/BenchmarkStorageParent.h" #include "mozilla/ContentBlockingUserInteraction.h" @@ -5822,17 +5822,17 @@ ContentParent::RecvFirstPartyStorageAccessGrantedForOrigin( const Principal& aParentPrincipal, const Principal& aTrackingPrincipal, const nsCString& aTrackingOrigin, const int& aAllowMode, FirstPartyStorageAccessGrantedForOriginResolver&& aResolver) { - 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); - }); + 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); + }); return IPC_OK(); } diff --git a/dom/security/ReferrerInfo.cpp b/dom/security/ReferrerInfo.cpp index 36fc546c3f07..4e7ea0c39be2 100644 --- a/dom/security/ReferrerInfo.cpp +++ b/dom/security/ReferrerInfo.cpp @@ -18,8 +18,8 @@ #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" @@ -205,8 +205,7 @@ ReferrerPolicy ReferrerInfo::GetDefaultReferrerPolicy(nsIHttpChannel* aChannel, if (aChannel && aURI && cjs->GetRejectThirdPartyTrackers()) { uint32_t rejectedReason = 0; thirdPartyTrackerIsolated = - !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - aChannel, aURI, &rejectedReason); + !ContentBlocking::ShouldAllowAccessFor(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.) diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index b20abd71cbb8..2bfe4f9bc105 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -25,7 +25,6 @@ #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" diff --git a/image/ImageCacheKey.cpp b/image/ImageCacheKey.cpp index d5c69e3de67f..fc6c3e19e23d 100644 --- a/image/ImageCacheKey.cpp +++ b/image/ImageCacheKey.cpp @@ -7,7 +7,7 @@ #include -#include "mozilla/AntiTrackingCommon.h" +#include "mozilla/ContentBlocking.h" #include "mozilla/HashFunctions.h" #include "mozilla/StorageAccess.h" #include "mozilla/Unused.h" @@ -185,7 +185,7 @@ nsCString ImageCacheKey::GetTopLevelBaseDomain(Document* aDocument, // 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 (!AntiTrackingCommon::MaybeIsFirstPartyStorageAccessGrantedFor( + if (!ContentBlocking::ApproximateAllowAccessForWithoutChannel( aDocument->GetInnerWindow(), aURI)) { nsPIDOMWindowOuter* top = aDocument->GetInnerWindow()->GetInProcessScriptableTop(); diff --git a/media/webrtc/signaling/src/peerconnection/RTCStatsReport.h b/media/webrtc/signaling/src/peerconnection/RTCStatsReport.h index 5f9eb49dfc23..c2be8cf95097 100644 --- a/media/webrtc/signaling/src/peerconnection/RTCStatsReport.h +++ b/media/webrtc/signaling/src/peerconnection/RTCStatsReport.h @@ -18,6 +18,7 @@ #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 diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index 0d56efa586d2..8abd0dd9e4ea 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -9,7 +9,6 @@ #include "nsNetUtil.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/Atomics.h" #include "mozilla/Encoding.h" #include "mozilla/LoadContext.h" diff --git a/netwerk/cookie/CookieServiceChild.cpp b/netwerk/cookie/CookieServiceChild.cpp index 453e156a66c9..229a726fb19b 100644 --- a/netwerk/cookie/CookieServiceChild.cpp +++ b/netwerk/cookie/CookieServiceChild.cpp @@ -5,7 +5,6 @@ #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" diff --git a/netwerk/protocol/http/ClassifierDummyChannel.cpp b/netwerk/protocol/http/ClassifierDummyChannel.cpp index 34e58110bf5e..174af843ce8a 100644 --- a/netwerk/protocol/http/ClassifierDummyChannel.cpp +++ b/netwerk/protocol/http/ClassifierDummyChannel.cpp @@ -7,7 +7,7 @@ #include "ClassifierDummyChannel.h" -#include "mozilla/AntiTrackingCommon.h" +#include "mozilla/ContentBlocking.h" #include "mozilla/net/ClassifierDummyChannelChild.h" #include "mozilla/net/UrlClassifierCommon.h" #include "mozilla/dom/ContentChild.h" @@ -60,8 +60,7 @@ ClassifierDummyChannel::StorageAllowed( return eAsyncNeeded; } - if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(httpChannel, uri, - nullptr)) { + if (ContentBlocking::ShouldAllowAccessFor(httpChannel, uri, nullptr)) { return eStorageGranted; } diff --git a/netwerk/protocol/http/ClassifierDummyChannelChild.cpp b/netwerk/protocol/http/ClassifierDummyChannelChild.cpp index 29780377fab3..34fde15a4522 100644 --- a/netwerk/protocol/http/ClassifierDummyChannelChild.cpp +++ b/netwerk/protocol/http/ClassifierDummyChannelChild.cpp @@ -5,6 +5,7 @@ * 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" @@ -85,8 +86,8 @@ mozilla::ipc::IPCResult ClassifierDummyChannelChild::Recv__delete__( RefPtr httpChannel = do_QueryObject(channel); httpChannel->AddClassificationFlags(aClassificationFlags, mIsThirdParty); - bool storageGranted = AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - httpChannel, mURI, nullptr); + bool storageGranted = + ContentBlocking::ShouldAllowAccessFor(httpChannel, mURI, nullptr); mCallback(storageGranted); return IPC_OK(); } diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index d44884306cee..0851de69b573 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -10,7 +10,6 @@ #include "nsHttp.h" #include "nsICacheEntry.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/BasePrincipal.h" #include "mozilla/Unused.h" #include "mozilla/dom/ContentChild.h" diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 367f5c464536..ab1a3a90793e 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -55,9 +55,9 @@ #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" @@ -4025,8 +4025,7 @@ bool nsHttpChannel::IsIsolated() { } mIsIsolated = StaticPrefs::browser_cache_cache_isolation() || (IsThirdPartyTrackingResource() && - !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - this, mURI, nullptr)); + !ContentBlocking::ShouldAllowAccessFor(this, mURI, nullptr)); mHasBeenIsolatedChecked = true; return mIsIsolated; } diff --git a/netwerk/url-classifier/UrlClassifierCommon.h b/netwerk/url-classifier/UrlClassifierCommon.h index 2018b2331ba8..59e7bdfcf7fb 100644 --- a/netwerk/url-classifier/UrlClassifierCommon.h +++ b/netwerk/url-classifier/UrlClassifierCommon.h @@ -7,8 +7,8 @@ #ifndef mozilla_net_UrlClassifierCommon_h #define mozilla_net_UrlClassifierCommon_h +#include "mozilla/Logging.h" #include "nsString.h" -#include "mozilla/AntiTrackingCommon.h" #include diff --git a/netwerk/url-classifier/UrlClassifierFeatureBase.h b/netwerk/url-classifier/UrlClassifierFeatureBase.h index 6262904d58a0..eee1837ca782 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureBase.h +++ b/netwerk/url-classifier/UrlClassifierFeatureBase.h @@ -11,7 +11,6 @@ #include "nsIUrlClassifierSkipListService.h" #include "nsTArray.h" #include "nsString.h" -#include "mozilla/AntiTrackingCommon.h" namespace mozilla { namespace net { diff --git a/netwerk/url-classifier/UrlClassifierFeatureCryptominingAnnotation.cpp b/netwerk/url-classifier/UrlClassifierFeatureCryptominingAnnotation.cpp index 3d086c96898a..21d2e8e76824 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureCryptominingAnnotation.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureCryptominingAnnotation.cpp @@ -6,7 +6,6 @@ #include "UrlClassifierFeatureCryptominingAnnotation.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/net/UrlClassifierCommon.h" #include "nsIClassifiedChannel.h" #include "nsContentUtils.h" diff --git a/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp b/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp index 1250e7f85adf..cfd06c61a574 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureCryptominingProtection.cpp @@ -6,7 +6,6 @@ #include "UrlClassifierFeatureCryptominingProtection.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/net/UrlClassifierCommon.h" #include "mozilla/StaticPrefs_privacy.h" #include "nsContentUtils.h" diff --git a/netwerk/url-classifier/UrlClassifierFeatureFingerprintingAnnotation.cpp b/netwerk/url-classifier/UrlClassifierFeatureFingerprintingAnnotation.cpp index 9cc870a32d0e..c532f21fd682 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureFingerprintingAnnotation.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureFingerprintingAnnotation.cpp @@ -6,7 +6,6 @@ #include "UrlClassifierFeatureFingerprintingAnnotation.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/net/UrlClassifierCommon.h" #include "nsIClassifiedChannel.h" #include "nsContentUtils.h" diff --git a/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp b/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp index 6e6b83e505d9..e150567f5579 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureFingerprintingProtection.cpp @@ -6,7 +6,6 @@ #include "UrlClassifierFeatureFingerprintingProtection.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/net/UrlClassifierCommon.h" #include "mozilla/StaticPrefs_privacy.h" #include "nsContentUtils.h" diff --git a/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingAnnotation.cpp b/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingAnnotation.cpp index 1a2a3bce5346..791876d1badc 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingAnnotation.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingAnnotation.cpp @@ -6,7 +6,6 @@ #include "UrlClassifierFeatureSocialTrackingAnnotation.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/net/UrlClassifierCommon.h" #include "nsIClassifiedChannel.h" #include "nsContentUtils.h" diff --git a/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp b/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp index f85fe5458c1c..a7552cbb56e0 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureSocialTrackingProtection.cpp @@ -6,7 +6,6 @@ #include "UrlClassifierFeatureSocialTrackingProtection.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/net/UrlClassifierCommon.h" #include "mozilla/StaticPrefs_privacy.h" #include "nsContentUtils.h" diff --git a/netwerk/url-classifier/UrlClassifierFeatureTrackingAnnotation.cpp b/netwerk/url-classifier/UrlClassifierFeatureTrackingAnnotation.cpp index e6e564b42e19..bae124a67e1d 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureTrackingAnnotation.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureTrackingAnnotation.cpp @@ -7,7 +7,6 @@ #include "UrlClassifierFeatureTrackingAnnotation.h" #include "Classifier.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/Logging.h" #include "mozilla/StaticPrefs_privacy.h" #include "mozilla/StaticPtr.h" diff --git a/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp b/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp index af9e1177957e..4e19b8ab9a42 100644 --- a/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp +++ b/netwerk/url-classifier/UrlClassifierFeatureTrackingProtection.cpp @@ -6,7 +6,6 @@ #include "UrlClassifierFeatureTrackingProtection.h" -#include "mozilla/AntiTrackingCommon.h" #include "mozilla/net/UrlClassifierCommon.h" #include "nsContentUtils.h" #include "nsIHttpChannelInternal.h" diff --git a/toolkit/components/antitracking/AntiTrackingRedirectHeuristic.cpp b/toolkit/components/antitracking/AntiTrackingRedirectHeuristic.cpp index 64b18bea372b..207362f1186e 100644 --- a/toolkit/components/antitracking/AntiTrackingRedirectHeuristic.cpp +++ b/toolkit/components/antitracking/AntiTrackingRedirectHeuristic.cpp @@ -6,7 +6,7 @@ #include "AntiTrackingLog.h" #include "AntiTrackingRedirectHeuristic.h" -#include "AntiTrackingCommon.h" +#include "ContentBlocking.h" #include "ContentBlockingAllowList.h" #include "ContentBlockingUserInteraction.h" @@ -16,6 +16,7 @@ #include "nsContentUtils.h" #include "nsIChannel.h" #include "nsIClassifiedChannel.h" +#include "nsICookieService.h" #include "nsIRedirectHistoryEntry.h" #include "nsIScriptError.h" #include "nsIURI.h" @@ -210,13 +211,11 @@ void AntiTrackingRedirectHeuristic(nsIChannel* aOldChannel, nsIURI* aOldURI, } // We don't care about this promise because the operation is actually sync. - RefPtr promise = - AntiTrackingCommon:: - SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess( - redirectedPrincipal, trackingPrincipal, trackingOrigin, - AntiTrackingCommon::StorageAccessPromptChoices::eAllow, - StaticPrefs:: - privacy_restrict3rdpartystorage_expiration_redirect()); + RefPtr promise = + ContentBlocking::SaveAccessForOriginOnParentProcess( + redirectedPrincipal, trackingPrincipal, trackingOrigin, + ContentBlocking::StorageAccessPromptChoices::eAllow, + StaticPrefs::privacy_restrict3rdpartystorage_expiration_redirect()); Unused << promise; } diff --git a/toolkit/components/antitracking/AntiTrackingCommon.cpp b/toolkit/components/antitracking/ContentBlocking.cpp similarity index 94% rename from toolkit/components/antitracking/AntiTrackingCommon.cpp rename to toolkit/components/antitracking/ContentBlocking.cpp index b4e280e55aed..86ec9682d62a 100644 --- a/toolkit/components/antitracking/AntiTrackingCommon.cpp +++ b/toolkit/components/antitracking/ContentBlocking.cpp @@ -5,26 +5,14 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "AntiTrackingLog.h" -#include "AntiTrackingCommon.h" +#include "ContentBlocking.h" #include "AntiTrackingUtils.h" #include "TemporaryAccessGrantObserver.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" @@ -32,20 +20,11 @@ #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 "nsNetUtil.h" -#include "nsPIDOMWindow.h" -#include "nsPrintfCString.h" +#include "nsPermissionManager.h" #include "nsScriptSecurityManager.h" namespace mozilla { @@ -268,11 +247,11 @@ bool CheckAntiTrackingPermission(nsIPrincipal* aPrincipal, } // namespace -/* static */ RefPtr -AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor( +/* static */ RefPtr +ContentBlocking::AllowAccessFor( nsIPrincipal* aPrincipal, nsPIDOMWindowInner* aParentWindow, ContentBlockingNotifier::StorageAccessGrantedReason aReason, - const AntiTrackingCommon::PerformFinalChecks& aPerformFinalChecks) { + const ContentBlocking::PerformFinalChecks& aPerformFinalChecks) { MOZ_ASSERT(aParentWindow); switch (aReason) { @@ -488,12 +467,11 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor( if (XRE_IsParentProcess()) { LOG(("Saving the permission: trackingOrigin=%s", trackingOrigin.get())); - return SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess( - topLevelStoragePrincipal, trackingPrincipal, trackingOrigin, - aAllowMode) + return SaveAccessForOriginOnParentProcess(topLevelStoragePrincipal, + trackingPrincipal, + trackingOrigin, aAllowMode) ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [](FirstPartyStorageAccessGrantPromise::ResolveOrRejectValue&& - aValue) { + [](ParentAccessGrantPromise::ResolveOrRejectValue&& aValue) { if (aValue.IsResolve()) { return StorageAccessGrantPromise::CreateAndResolve( eAllow, __func__); @@ -545,8 +523,8 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor( } /* static */ -RefPtr -AntiTrackingCommon::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess( +RefPtr +ContentBlocking::SaveAccessForOriginOnParentProcess( nsIPrincipal* aParentPrincipal, nsIPrincipal* aTrackingPrincipal, const nsCString& aTrackingOrigin, int aAllowMode, uint64_t aExpirationTime) { @@ -555,8 +533,7 @@ AntiTrackingCommon::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess( if (!aParentPrincipal || !aTrackingPrincipal) { LOG(("Invalid input arguments passed")); - return FirstPartyStorageAccessGrantPromise::CreateAndReject(false, - __func__); + return ParentAccessGrantPromise::CreateAndReject(false, __func__); }; LOG_PRIN(("Saving a first-party storage permission on %s for " @@ -567,15 +544,13 @@ AntiTrackingCommon::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess( if (NS_WARN_IF(!aParentPrincipal)) { // The child process is sending something wrong. Let's ignore it. LOG(("aParentPrincipal is null, bailing out early")); - return FirstPartyStorageAccessGrantPromise::CreateAndReject(false, - __func__); + return ParentAccessGrantPromise::CreateAndReject(false, __func__); } nsPermissionManager* permManager = nsPermissionManager::GetInstance(); if (NS_WARN_IF(!permManager)) { LOG(("Permission manager is null, bailing out early")); - return FirstPartyStorageAccessGrantPromise::CreateAndReject(false, - __func__); + return ParentAccessGrantPromise::CreateAndReject(false, __func__); } // Remember that this pref is stored in seconds! @@ -613,11 +588,12 @@ AntiTrackingCommon::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess( } LOG(("Result: %s", NS_SUCCEEDED(rv) ? "success" : "failure")); - return FirstPartyStorageAccessGrantPromise::CreateAndResolve(rv, __func__); + return ParentAccessGrantPromise::CreateAndResolve(rv, __func__); } -bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - nsPIDOMWindowInner* aWindow, nsIURI* aURI, uint32_t* aRejectedReason) { +bool ContentBlocking::ShouldAllowAccessFor(nsPIDOMWindowInner* aWindow, + nsIURI* aURI, + uint32_t* aRejectedReason) { MOZ_ASSERT(aWindow); MOZ_ASSERT(aURI); @@ -819,8 +795,8 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( aRejectedReason, blockedReason); } -bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - nsIChannel* aChannel, nsIURI* aURI, uint32_t* aRejectedReason) { +bool ContentBlocking::ShouldAllowAccessFor(nsIChannel* aChannel, nsIURI* aURI, + uint32_t* aRejectedReason) { MOZ_ASSERT(aURI); MOZ_ASSERT(aChannel); @@ -1083,7 +1059,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( aRejectedReason, blockedReason); } -bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( +bool ContentBlocking::ShouldAllowAccessFor( nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings) { MOZ_ASSERT(aPrincipal); MOZ_ASSERT(aCookieJarSettings); @@ -1106,7 +1082,7 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( } /* static */ -bool AntiTrackingCommon::MaybeIsFirstPartyStorageAccessGrantedFor( +bool ContentBlocking::ApproximateAllowAccessForWithoutChannel( nsPIDOMWindowInner* aFirstPartyWindow, nsIURI* aURI) { MOZ_ASSERT(aFirstPartyWindow); MOZ_ASSERT(aURI); diff --git a/toolkit/components/antitracking/AntiTrackingCommon.h b/toolkit/components/antitracking/ContentBlocking.h similarity index 66% rename from toolkit/components/antitracking/AntiTrackingCommon.h rename to toolkit/components/antitracking/ContentBlocking.h index ed0456f23083..a05812a87cff 100644 --- a/toolkit/components/antitracking/AntiTrackingCommon.h +++ b/toolkit/components/antitracking/ContentBlocking.h @@ -25,19 +25,12 @@ namespace mozilla { class OriginAttributes; -class AntiTrackingCommon final { +class ContentBlocking 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 - 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 - // MaybeIsFirstPartyStorageAccessGrantedFor(); + // ApproximateAllowAccessForWithoutChannel(); // // aRejectedReason could be set to one of these values if passed and if the // storage permission is not granted: @@ -46,31 +39,29 @@ class AntiTrackingCommon final { // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_SOCIALTRACKER // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL // * nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN - static bool IsFirstPartyStorageAccessGrantedFor( - nsPIDOMWindowInner* a3rdPartyTrackingWindow, nsIURI* aURI, - uint32_t* aRejectedReason); + static bool ShouldAllowAccessFor(nsPIDOMWindowInner* a3rdPartyTrackingWindow, + nsIURI* aURI, uint32_t* aRejectedReason); - // 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( + // 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( 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 IsFirstPartyStorageAccessGrantedFor(window) to see the possible values - // of aRejectedReason. - static bool IsFirstPartyStorageAccessGrantedFor(nsIChannel* aChannel, - nsIURI* aURI, - uint32_t* aRejectedReason); + // See ShouldAllowAccessFor(window) to see the possible values of + // aRejectedReason. + static bool ShouldAllowAccessFor(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 IsFirstPartyStorageAccessGrantedFor( - nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings); + static bool ShouldAllowAccessFor(nsIPrincipal* aPrincipal, + nsICookieJarSettings* aCookieJarSettings); enum StorageAccessPromptChoices { eAllow, eAllowAutoGrant }; @@ -93,16 +84,14 @@ class AntiTrackingCommon final { typedef std::function()> PerformFinalChecks; typedef MozPromise StorageAccessGrantPromise; - static MOZ_MUST_USE RefPtr - AddFirstPartyStorageAccessGrantedFor( + static MOZ_MUST_USE RefPtr AllowAccessFor( nsIPrincipal* aPrincipal, nsPIDOMWindowInner* aParentWindow, ContentBlockingNotifier::StorageAccessGrantedReason aReason, const PerformFinalChecks& aPerformFinalChecks = nullptr); // For IPC only. - typedef MozPromise FirstPartyStorageAccessGrantPromise; - static RefPtr - SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess( + typedef MozPromise ParentAccessGrantPromise; + static RefPtr SaveAccessForOriginOnParentProcess( nsIPrincipal* aPrincipal, nsIPrincipal* aTrackingPrinciapl, const nsCString& aTrackingOrigin, int aAllowMode, uint64_t aExpirationTime = diff --git a/toolkit/components/antitracking/ContentBlockingAllowList.h b/toolkit/components/antitracking/ContentBlockingAllowList.h index f3183c840865..241904ae5c91 100644 --- a/toolkit/components/antitracking/ContentBlockingAllowList.h +++ b/toolkit/components/antitracking/ContentBlockingAllowList.h @@ -43,11 +43,11 @@ class ContentBlockingAllowList final { // Check(). static ContentBlockingAllowListCache& Cache(); - // Utility APIs for AntiTrackingCommon. + // Utility APIs for ContentBlocking. static bool Check(nsIPrincipal* aTopWinPrincipal, bool aIsPrivateBrowsing); static bool Check(nsPIDOMWindowInner* aWindow); - friend class AntiTrackingCommon; + friend class ContentBlocking; }; } // namespace mozilla diff --git a/toolkit/components/antitracking/ContentBlockingNotifier.cpp b/toolkit/components/antitracking/ContentBlockingNotifier.cpp index 15bb5eb5cc9c..59f46780b4ae 100644 --- a/toolkit/components/antitracking/ContentBlockingNotifier.cpp +++ b/toolkit/components/antitracking/ContentBlockingNotifier.cpp @@ -6,7 +6,6 @@ #include "AntiTrackingLog.h" #include "ContentBlockingNotifier.h" -#include "AntiTrackingCommon.h" #include "AntiTrackingUtils.h" #include "mozilla/AbstractEventQueue.h" diff --git a/toolkit/components/antitracking/ContentBlockingUserInteraction.cpp b/toolkit/components/antitracking/ContentBlockingUserInteraction.cpp index c8b60e8b34c2..44f6d77c6318 100644 --- a/toolkit/components/antitracking/ContentBlockingUserInteraction.cpp +++ b/toolkit/components/antitracking/ContentBlockingUserInteraction.cpp @@ -6,7 +6,6 @@ #include "AntiTrackingLog.h" #include "ContentBlockingUserInteraction.h" -#include "AntiTrackingCommon.h" #include "AntiTrackingUtils.h" #include "mozilla/dom/ContentChild.h" diff --git a/toolkit/components/antitracking/StorageAccess.cpp b/toolkit/components/antitracking/StorageAccess.cpp index 8e125fdaadf9..0084ffef4e0a 100644 --- a/toolkit/components/antitracking/StorageAccess.cpp +++ b/toolkit/components/antitracking/StorageAccess.cpp @@ -6,7 +6,7 @@ #include "mozilla/dom/Document.h" #include "mozilla/net/CookieJarSettings.h" -#include "mozilla/AntiTrackingCommon.h" +#include "mozilla/ContentBlocking.h" #include "mozilla/StaticPrefs_browser.h" #include "mozilla/StaticPrefs_network.h" #include "mozilla/StaticPrefs_privacy.h" @@ -175,9 +175,8 @@ static bool StorageDisabledByAntiTrackingInternal( if (aWindow) { nsIURI* documentURI = aURI ? aURI : aWindow->GetDocumentURI(); - return !documentURI || - !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - aWindow, documentURI, &aRejectedReason); + return !documentURI || !ContentBlocking::ShouldAllowAccessFor( + aWindow, documentURI, &aRejectedReason); } if (aChannel) { @@ -187,13 +186,12 @@ static bool StorageDisabledByAntiTrackingInternal( return false; } - return !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - aChannel, uri, &aRejectedReason); + return !ContentBlocking::ShouldAllowAccessFor(aChannel, uri, + &aRejectedReason); } MOZ_ASSERT(aPrincipal); - return !AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - aPrincipal, aCookieJarSettings); + return !ContentBlocking::ShouldAllowAccessFor(aPrincipal, aCookieJarSettings); } namespace mozilla { diff --git a/toolkit/components/antitracking/StoragePrincipalHelper.cpp b/toolkit/components/antitracking/StoragePrincipalHelper.cpp index dde64eac5e02..12cd90ac4a25 100644 --- a/toolkit/components/antitracking/StoragePrincipalHelper.cpp +++ b/toolkit/components/antitracking/StoragePrincipalHelper.cpp @@ -7,7 +7,7 @@ #include "StoragePrincipalHelper.h" #include "mozilla/ipc/PBackgroundSharedTypes.h" -#include "mozilla/AntiTrackingCommon.h" +#include "mozilla/ContentBlocking.h" #include "mozilla/ScopeExit.h" #include "mozilla/StorageAccess.h" #include "nsContentUtils.h" @@ -32,13 +32,12 @@ bool ChooseOriginAttributes(nsIChannel* aChannel, OriginAttributes& aAttrs) { } uint32_t rejectedReason = 0; - if (AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor( - aChannel, uri, &rejectedReason)) { + if (ContentBlocking::ShouldAllowAccessFor(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 AntiTrackingCommon API here to ensure this + // jar. We use the lower-level ContentBlocking API here to ensure this // check doesn't send notifications. if (!ShouldPartitionStorage(rejectedReason) || !StoragePartitioningEnabled(rejectedReason, cjs)) { diff --git a/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp b/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp index 91a8545a1bd8..383b7bd4117c 100644 --- a/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp +++ b/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp @@ -5,11 +5,11 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "TemporaryAccessGrantObserver.h" -#include "AntiTrackingCommon.h" #include "nsIObserverService.h" #include "nsPermissionManager.h" #include "nsTHashtable.h" +#include "nsXULAppAPI.h" using namespace mozilla; diff --git a/toolkit/components/antitracking/moz.build b/toolkit/components/antitracking/moz.build index c0ab2f195cd7..58e9bbc3f3f0 100644 --- a/toolkit/components/antitracking/moz.build +++ b/toolkit/components/antitracking/moz.build @@ -31,10 +31,10 @@ XPCOM_MANIFESTS += [ ] EXPORTS.mozilla = [ - 'AntiTrackingCommon.h', 'AntiTrackingIPCUtils.h', 'AntiTrackingRedirectHeuristic.h', 'AntiTrackingUtils.h', + 'ContentBlocking.h', 'ContentBlockingAllowList.h', 'ContentBlockingNotifier.h', 'ContentBlockingUserInteraction.h', @@ -44,9 +44,9 @@ EXPORTS.mozilla = [ ] UNIFIED_SOURCES += [ - 'AntiTrackingCommon.cpp', 'AntiTrackingRedirectHeuristic.cpp', 'AntiTrackingUtils.cpp', + 'ContentBlocking.cpp', 'ContentBlockingAllowList.cpp', 'ContentBlockingNotifier.cpp', 'ContentBlockingUserInteraction.cpp',