diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 17521f27a44b..1b3f2514feb5 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -18,7 +18,6 @@ #include "nsDOMNavigationTiming.h" #include "nsIDOMStorageManager.h" #include "mozilla/dom/AutoplayRequest.h" -#include "mozilla/dom/ContentChild.h" #include "mozilla/dom/DOMJSProxyHandler.h" #include "mozilla/dom/DOMPrefs.h" #include "mozilla/dom/EventTarget.h" @@ -8157,6 +8156,17 @@ nsGlobalWindowInner::ReleaseFirstPartyStorageAccessGrantedOrigins() } +namespace mozilla { +namespace dom { + +extern void +SendFirstPartyStorageAccessGrantedForOriginToParentProcess(nsIPrincipal* aPrincipal, + const nsACString& aParentOrigin, + const nsACString& aGrantedOrigin); + +} // namespace dom +} // namespace mozilla + void nsGlobalWindowInner::SaveFirstPartyStorageAccessGrantedFor(const nsAString& aOrigin) { @@ -8189,14 +8199,11 @@ nsGlobalWindowInner::SaveFirstPartyStorageAccessGrantedFor(const nsAString& aOri return; } - ContentChild* cc = ContentChild::GetSingleton(); - MOZ_ASSERT(cc); - - // This is not really secure, because here we have the content process sending - // the request of storing a permission. - Unused << cc->SendFirstPartyStorageAccessGrantedForOrigin(IPC::Principal(principal), - parentOrigin, - grantedOrigin); + // We have this external function because ContentChild includes windows.h and + // for this reason it cannot be included here. + SendFirstPartyStorageAccessGrantedForOriginToParentProcess(principal, + parentOrigin, + grantedOrigin); } /* static */ void diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 75ab2048eeaa..993e9cbb0b14 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -3279,6 +3279,25 @@ NextWindowID() return (processBits << kWindowIDWindowBits) | windowBits; } +// This code goes here rather than nsGlobalWindow.cpp because nsGlobalWindow.cpp +// can't include ContentChild.h since it includes windows.h. +void +SendFirstPartyStorageAccessGrantedForOriginToParentProcess(nsIPrincipal* aPrincipal, + const nsACString& aParentOrigin, + const nsACString& aGrantedOrigin) +{ + MOZ_ASSERT(!XRE_IsParentProcess()); + + ContentChild* cc = ContentChild::GetSingleton(); + MOZ_ASSERT(cc); + + // This is not really secure, because here we have the content process sending + // the request of storing a permission. + Unused << cc->SendFirstPartyStorageAccessGrantedForOrigin(IPC::Principal(aPrincipal), + nsCString(aParentOrigin), + nsCString(aGrantedOrigin)); +} + mozilla::ipc::IPCResult ContentChild::RecvInvokeDragSession(nsTArray&& aTransfers, const uint32_t& aAction) diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 0d65219d0558..d21cbe1b4352 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -848,6 +848,11 @@ private: uint64_t NextWindowID(); +void +SendFirstPartyStorageAccessGrantedForOriginToParentProcess(nsIPrincipal* aPrincipal, + const nsACString& aParentOrigin, + const nsACString& aGrantedOrigin); + } // namespace dom } // namespace mozilla