зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616775 - P4. Add CompleteAllowAccessFor IPDL r=timhuang,baku
Differential Revision: https://phabricator.services.mozilla.com/D71013
This commit is contained in:
Родитель
16e2fc08d9
Коммит
00aeb88f21
|
@ -5759,6 +5759,34 @@ ContentParent::RecvFirstPartyStorageAccessGrantedForOrigin(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvCompleteAllowAccessFor(
|
||||
const MaybeDiscarded<BrowsingContext>& aParentContext,
|
||||
uint64_t aTopLevelWindowId, const Principal& aTrackingPrincipal,
|
||||
const nsCString& aTrackingOrigin, uint32_t aCookieBehavior,
|
||||
const ContentBlockingNotifier::StorageAccessGrantedReason& aReason,
|
||||
CompleteAllowAccessForResolver&& aResolver) {
|
||||
if (aParentContext.IsNullOrDiscarded()) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
ContentBlocking::CompleteAllowAccessFor(
|
||||
aParentContext.get_canonical(), aTopLevelWindowId, aTrackingPrincipal,
|
||||
aTrackingOrigin, aCookieBehavior, aReason, nullptr)
|
||||
->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[aResolver = std::move(aResolver)](
|
||||
ContentBlocking::StorageAccessGrantPromise::ResolveOrRejectValue&&
|
||||
aValue) {
|
||||
Maybe<StorageAccessPromptChoices> choice;
|
||||
if (aValue.IsResolve()) {
|
||||
choice.emplace(static_cast<StorageAccessPromptChoices>(
|
||||
aValue.ResolveValue()));
|
||||
}
|
||||
aResolver(choice);
|
||||
});
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvStoreUserInteractionAsPermission(
|
||||
const Principal& aPrincipal) {
|
||||
ContentBlockingUserInteraction::Observe(aPrincipal);
|
||||
|
|
|
@ -1239,6 +1239,13 @@ class ContentParent final
|
|||
const nsCString& aTrackingOrigin, const int& aAllowMode,
|
||||
FirstPartyStorageAccessGrantedForOriginResolver&& aResolver);
|
||||
|
||||
mozilla::ipc::IPCResult RecvCompleteAllowAccessFor(
|
||||
const MaybeDiscarded<BrowsingContext>& aParentContext,
|
||||
uint64_t aTopLevelWindowId, const Principal& aTrackingPrincipal,
|
||||
const nsCString& aTrackingOrigin, uint32_t aCookieBehavior,
|
||||
const ContentBlockingNotifier::StorageAccessGrantedReason& aReason,
|
||||
CompleteAllowAccessForResolver&& aResolver);
|
||||
|
||||
mozilla::ipc::IPCResult RecvStoreUserInteractionAsPermission(
|
||||
const Principal& aPrincipal);
|
||||
|
||||
|
|
|
@ -123,6 +123,8 @@ using mozilla::dom::MediaSessionPlaybackState from "mozilla/dom/MediaSessionBind
|
|||
using refcounted class nsDocShellLoadState from "nsDocShellLoadState.h";
|
||||
using mozilla::dom::ServiceWorkerShutdownState::Progress from "mozilla/dom/ServiceWorkerShutdownState.h";
|
||||
using refcounted class mozilla::dom::CrossProcessSHEntry from "mozilla/dom/MaybeNewPSHEntry.h";
|
||||
using mozilla::ContentBlockingNotifier::StorageAccessGrantedReason from "mozilla/ContentBlockingNotifier.h";
|
||||
using mozilla::ContentBlocking::StorageAccessPromptChoices from "mozilla/ContentBlocking.h";
|
||||
|
||||
union ChromeRegistryItem
|
||||
{
|
||||
|
@ -1466,6 +1468,14 @@ parent:
|
|||
int aAllowMode)
|
||||
returns (bool unused);
|
||||
|
||||
async CompleteAllowAccessFor(MaybeDiscardedBrowsingContext aParentContext,
|
||||
uint64_t aTopLevelWindowId,
|
||||
Principal aTrackingPrincipal,
|
||||
nsCString aTrackingOrigin,
|
||||
uint32_t aCookieBehavior,
|
||||
StorageAccessGrantedReason aReason)
|
||||
returns (StorageAccessPromptChoices? choice);
|
||||
|
||||
async StoreUserInteractionAsPermission(Principal aPrincipal);
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "ipc/IPCMessageUtils.h"
|
||||
|
||||
#include "mozilla/ContentBlockingNotifier.h"
|
||||
#include "mozilla/ContentBlocking.h"
|
||||
|
||||
namespace IPC {
|
||||
|
||||
|
@ -24,6 +25,14 @@ struct ParamTraits<mozilla::ContentBlockingNotifier::StorageAccessGrantedReason>
|
|||
mozilla::ContentBlockingNotifier::StorageAccessGrantedReason::
|
||||
eOpener> {};
|
||||
|
||||
// ContentBlocking::StorageAccessPromptChoices over IPC.
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ContentBlocking::StorageAccessPromptChoices>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
mozilla::ContentBlocking::StorageAccessPromptChoices,
|
||||
mozilla::ContentBlocking::StorageAccessPromptChoices::eAllow,
|
||||
mozilla::ContentBlocking::StorageAccessPromptChoices::
|
||||
eAllowAutoGrant> {};
|
||||
} // namespace IPC
|
||||
|
||||
#endif // mozilla_antitrackingipcutils_h
|
||||
|
|
|
@ -331,7 +331,29 @@ ContentBlocking::AllowAccessFor(
|
|||
behavior, aReason, aPerformFinalChecks);
|
||||
}
|
||||
|
||||
return StorageAccessGrantPromise::CreateAndReject(false, __func__);
|
||||
MOZ_ASSERT(XRE_IsContentProcess());
|
||||
// Only support PerformFinalChecks when we run ::CompleteAllowAccessFor in
|
||||
// the same process. This callback is only used by eStorageAccessAPI,
|
||||
// which is always runned in the same process.
|
||||
MOZ_ASSERT(!aPerformFinalChecks);
|
||||
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
MOZ_ASSERT(cc);
|
||||
|
||||
return cc
|
||||
->SendCompleteAllowAccessFor(aParentContext, topLevelWindowId,
|
||||
IPC::Principal(trackingPrincipal),
|
||||
trackingOrigin, behavior, aReason)
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[](const ContentChild::CompleteAllowAccessForPromise::
|
||||
ResolveOrRejectValue& aValue) {
|
||||
if (aValue.IsResolve() && aValue.ResolveValue().isSome()) {
|
||||
return StorageAccessGrantPromise::CreateAndResolve(
|
||||
aValue.ResolveValue().value(), __func__);
|
||||
}
|
||||
return StorageAccessGrantPromise::CreateAndReject(false,
|
||||
__func__);
|
||||
});
|
||||
}
|
||||
|
||||
// CompleteAllowAccessFor is used to process the remaining work in
|
||||
|
@ -462,7 +484,7 @@ ContentBlocking::CompleteAllowAccessFor(
|
|||
[](ParentAccessGrantPromise::ResolveOrRejectValue&& aValue) {
|
||||
if (aValue.IsResolve()) {
|
||||
return StorageAccessGrantPromise::CreateAndResolve(
|
||||
eAllow, __func__);
|
||||
ContentBlocking::eAllow, __func__);
|
||||
}
|
||||
return StorageAccessGrantPromise::CreateAndReject(false,
|
||||
__func__);
|
||||
|
|
|
@ -27,6 +27,7 @@ class OriginAttributes;
|
|||
|
||||
namespace dom {
|
||||
class BrowsingContext;
|
||||
class ContentParent;
|
||||
}
|
||||
|
||||
class ContentBlocking final {
|
||||
|
@ -109,6 +110,7 @@ class ContentBlocking final {
|
|||
StaticPrefs::privacy_restrict3rdpartystorage_expiration());
|
||||
|
||||
private:
|
||||
friend class dom::ContentParent;
|
||||
// This should be running either in the parent process or in the child
|
||||
// processes with an in-process browsing context.
|
||||
static MOZ_MUST_USE RefPtr<StorageAccessGrantPromise> CompleteAllowAccessFor(
|
||||
|
|
Загрузка…
Ссылка в новой задаче