diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 34b62f7d2069..525dbee9e65a 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -12517,9 +12517,8 @@ nsIDocument::MaybeAllowStorageForOpener() return; } - // We don't care when the asynchronous work finishes here. - Unused << AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(origin, - openerInner); + AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(origin, + openerInner); } bool diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index f1673146d91b..f1c4e18af2b4 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -7148,9 +7148,7 @@ nsGlobalWindowOuter::MaybeAllowStorageForOpenedWindow(nsIURI* aURI) return; } - // We don't care when the asynchronous work finishes here. - Unused << AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(origin, - inner); + AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(origin, inner); } //***************************************************************************** diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index ba7287412f00..0ddc2fffe673 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -5780,12 +5780,10 @@ ContentParent::RecvBHRThreadHang(const HangDetails& aDetails) mozilla::ipc::IPCResult ContentParent::RecvFirstPartyStorageAccessGrantedForOrigin(const Principal& aParentPrincipal, const nsCString& aTrackingOrigin, - const nsCString& aGrantedOrigin, - FirstPartyStorageAccessGrantedForOriginResolver&& aResolver) + const nsCString& aGrantedOrigin) { AntiTrackingCommon::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(aParentPrincipal, aTrackingOrigin, - aGrantedOrigin, - std::move(aResolver)); + aGrantedOrigin); return IPC_OK(); } diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 5c8a1141fd71..28e833ce2618 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -1227,8 +1227,7 @@ public: virtual mozilla::ipc::IPCResult RecvFirstPartyStorageAccessGrantedForOrigin(const Principal& aParentPrincipal, const nsCString& aTrackingOrigin, - const nsCString& aGrantedOrigin, - FirstPartyStorageAccessGrantedForOriginResolver&& aResolver) override; + const nsCString& aGrantedOrigin) override; // Notify the ContentChild to enable the input event prioritization when // initializing. diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 9e61cadbdb15..8a1b11541f8a 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -1165,8 +1165,7 @@ parent: */ async FirstPartyStorageAccessGrantedForOrigin(Principal aParentPrincipal, nsCString aTrackingOrigin, - nsCString aGrantedOrigin) - returns (bool unused); + nsCString aGrantedOrigin); both: async AsyncMessage(nsString aMessage, CpowEntry[] aCpows, diff --git a/toolkit/components/antitracking/AntiTrackingCommon.cpp b/toolkit/components/antitracking/AntiTrackingCommon.cpp index 8784b831217b..b48c468eb978 100644 --- a/toolkit/components/antitracking/AntiTrackingCommon.cpp +++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp @@ -7,8 +7,6 @@ #include "AntiTrackingCommon.h" #include "mozilla/dom/ContentChild.h" -#include "mozilla/ipc/MessageChannel.h" -#include "mozilla/AbstractThread.h" #include "mozilla/StaticPrefs.h" #include "mozIThirdPartyUtil.h" #include "nsContentUtils.h" @@ -73,14 +71,14 @@ CreatePermissionKey(const nsCString& aTrackingOrigin, } // anonymous -/* static */ RefPtr +/* static */ void AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigin, nsPIDOMWindowInner* aParentWindow) { MOZ_ASSERT(aParentWindow); if (!StaticPrefs::privacy_restrict3rdpartystorage_enabled()) { - return StorageAccessGrantPromise::CreateAndResolve(true, __func__); + return; } nsCOMPtr topLevelStoragePrincipal; @@ -90,7 +88,7 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigi nsGlobalWindowOuter* outerParentWindow = nsGlobalWindowOuter::Cast(parentWindow->GetOuterWindow()); if (NS_WARN_IF(!outerParentWindow)) { - return StorageAccessGrantPromise::CreateAndReject(false, __func__); + return; } // We are a first party resource. @@ -98,27 +96,23 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigi CopyUTF16toUTF8(aOrigin, trackingOrigin); topLevelStoragePrincipal = parentWindow->GetPrincipal(); if (NS_WARN_IF(!topLevelStoragePrincipal)) { - return StorageAccessGrantPromise::CreateAndReject(false, __func__); + return; } // We are a 3rd party source. } else if (!GetParentPrincipalAndTrackingOrigin(parentWindow, getter_AddRefs(topLevelStoragePrincipal), trackingOrigin)) { - return StorageAccessGrantPromise::CreateAndReject(false, __func__); + return; } NS_ConvertUTF16toUTF8 grantedOrigin(aOrigin); if (XRE_IsParentProcess()) { - RefPtr p = new StorageAccessGrantPromise::Private(__func__); SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(topLevelStoragePrincipal, trackingOrigin, - grantedOrigin, - [p] (bool success) { - p->Resolve(success, __func__); - }); - return p; + grantedOrigin); + return; } ContentChild* cc = ContentChild::GetSingleton(); @@ -126,36 +120,25 @@ AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigi // This is not really secure, because here we have the content process sending // the request of storing a permission. - RefPtr p = new StorageAccessGrantPromise::Private(__func__); - cc->SendFirstPartyStorageAccessGrantedForOrigin(IPC::Principal(topLevelStoragePrincipal), - trackingOrigin, - grantedOrigin) - ->Then(GetCurrentThreadSerialEventTarget(), __func__, - [p] (bool success) { - p->Resolve(success, __func__); - }, [p] (ipc::ResponseRejectReason aReason) { - p->Reject(false, __func__); - }); - return p; + Unused << cc->SendFirstPartyStorageAccessGrantedForOrigin(IPC::Principal(topLevelStoragePrincipal), + trackingOrigin, + grantedOrigin); } /* static */ void AntiTrackingCommon::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(nsIPrincipal* aParentPrincipal, const nsCString& aTrackingOrigin, - const nsCString& aGrantedOrigin, - FirstPartyStorageAccessGrantedForOriginResolver&& aResolver) + const nsCString& aGrantedOrigin) { MOZ_ASSERT(XRE_IsParentProcess()); if (NS_WARN_IF(!aParentPrincipal)) { // The child process is sending something wrong. Let's ignore it. - aResolver(false); return; } nsCOMPtr pm = services::GetPermissionManager(); if (NS_WARN_IF(!pm)) { - aResolver(false); return; } @@ -171,7 +154,6 @@ AntiTrackingCommon::SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(n nsIPermissionManager::ALLOW_ACTION, nsIPermissionManager::EXPIRE_TIME, when); Unused << NS_WARN_IF(NS_FAILED(rv)); - aResolver(NS_SUCCEEDED(rv)); } bool diff --git a/toolkit/components/antitracking/AntiTrackingCommon.h b/toolkit/components/antitracking/AntiTrackingCommon.h index 0cca926146f3..21742995462c 100644 --- a/toolkit/components/antitracking/AntiTrackingCommon.h +++ b/toolkit/components/antitracking/AntiTrackingCommon.h @@ -8,9 +8,6 @@ #define mozilla_antitrackingservice_h #include "nsString.h" -#include "mozilla/dom/PContentParent.h" -#include "mozilla/MozPromise.h" -#include "mozilla/RefPtr.h" class nsIHttpChannel; class nsIPrincipal; @@ -22,9 +19,6 @@ namespace mozilla { class AntiTrackingCommon final { public: - typedef dom::PContentParent::FirstPartyStorageAccessGrantedForOriginResolver - 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 @@ -65,8 +59,7 @@ public: // 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 StorageAccessGrantPromise; - static MOZ_MUST_USE RefPtr + static void AddFirstPartyStorageAccessGrantedFor(const nsAString& aOrigin, nsPIDOMWindowInner* aParentWindow); @@ -74,8 +67,7 @@ public: static void SaveFirstPartyStorageAccessGrantedForOriginOnParentProcess(nsIPrincipal* aPrincipal, const nsCString& aParentOrigin, - const nsCString& aGrantedOrigin, - FirstPartyStorageAccessGrantedForOriginResolver&& aResolver); + const nsCString& aGrantedOrigin); };