зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616775 - P7. Add IPC for ContentBlockingNotifier::OnDecision r=timhuang,baku
Differential Revision: https://phabricator.services.mozilla.com/D71016
This commit is contained in:
Родитель
ae0eb1b968
Коммит
5ff0f8a47c
|
@ -3588,6 +3588,32 @@ mozilla::ipc::IPCResult ContentChild::RecvOnAllowAccessFor(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvOnContentBlockingDecision(
|
||||
const MaybeDiscarded<BrowsingContext>& aContext,
|
||||
const ContentBlockingNotifier::BlockingDecision& aDecision,
|
||||
uint32_t aRejectedReason) {
|
||||
MOZ_ASSERT(!aContext.IsNull(), "Browsing context cannot be null");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> outer = aContext.get()->GetDOMWindow();
|
||||
if (!outer) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ChildIPC: Trying to send a message to a context without a outer "
|
||||
"window"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> inner = outer->GetCurrentInnerWindow();
|
||||
if (!inner) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
|
||||
("ChildIPC: Trying to send a message to a context without a inner "
|
||||
"window"));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
ContentBlockingNotifier::OnDecision(inner, aDecision, aRejectedReason);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void ContentChild::OnChannelReceivedMessage(const Message& aMsg) {
|
||||
if (aMsg.is_sync() && !aMsg.is_reply()) {
|
||||
LSObject::OnSyncMessageReceived();
|
||||
|
|
|
@ -678,6 +678,11 @@ class ContentChild final
|
|||
const nsCString& aTrackingOrigin, uint32_t aCookieBehavior,
|
||||
const ContentBlockingNotifier::StorageAccessGrantedReason& aReason);
|
||||
|
||||
mozilla::ipc::IPCResult RecvOnContentBlockingDecision(
|
||||
const MaybeDiscarded<BrowsingContext>& aContext,
|
||||
const ContentBlockingNotifier::BlockingDecision& aDecision,
|
||||
uint32_t aRejectedReason);
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
// Fetch the current number of pending input events.
|
||||
//
|
||||
|
|
|
@ -124,6 +124,7 @@ 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::ContentBlockingNotifier::BlockingDecision from "mozilla/ContentBlockingNotifier.h";
|
||||
using mozilla::ContentBlocking::StorageAccessPromptChoices from "mozilla/ContentBlocking.h";
|
||||
|
||||
union ChromeRegistryItem
|
||||
|
@ -856,6 +857,10 @@ child:
|
|||
uint32_t aCookieBehavior,
|
||||
StorageAccessGrantedReason aReason);
|
||||
|
||||
async OnContentBlockingDecision(MaybeDiscardedBrowsingContext aContext,
|
||||
BlockingDecision aReason,
|
||||
uint32_t aRejectedReason);
|
||||
|
||||
parent:
|
||||
async InitBackground(Endpoint<PBackgroundParent> aEndpoint);
|
||||
|
||||
|
|
|
@ -25,6 +25,14 @@ struct ParamTraits<mozilla::ContentBlockingNotifier::StorageAccessGrantedReason>
|
|||
mozilla::ContentBlockingNotifier::StorageAccessGrantedReason::
|
||||
eOpener> {};
|
||||
|
||||
// ContentBlockingNotifier::BlockingDecision over IPC.
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ContentBlockingNotifier::BlockingDecision>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
mozilla::ContentBlockingNotifier::BlockingDecision,
|
||||
mozilla::ContentBlockingNotifier::BlockingDecision::eBlock,
|
||||
mozilla::ContentBlockingNotifier::BlockingDecision::eAllow> {};
|
||||
|
||||
// ContentBlocking::StorageAccessPromptChoices over IPC.
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ContentBlocking::StorageAccessPromptChoices>
|
||||
|
|
|
@ -402,23 +402,6 @@ ContentBlocking::CompleteAllowAccessFor(
|
|||
MOZ_ASSERT(aParentContext);
|
||||
MOZ_ASSERT_IF(XRE_IsContentProcess(), aParentContext->IsInProcess());
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> parentOuter = aParentContext->GetDOMWindow();
|
||||
if (!parentOuter) {
|
||||
LOG(
|
||||
("No outer window found for our parent window context, bailing out "
|
||||
"early"));
|
||||
return StorageAccessGrantPromise::CreateAndReject(false, __func__);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> parentInnerWindow =
|
||||
parentOuter->GetCurrentInnerWindow();
|
||||
if (!parentInnerWindow) {
|
||||
LOG(
|
||||
("No inner window found for our parent outer window, bailing out "
|
||||
"early"));
|
||||
return StorageAccessGrantPromise::CreateAndReject(false, __func__);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> trackingPrincipal;
|
||||
nsAutoCString trackingOrigin;
|
||||
if (!aTrackingPrincipal) {
|
||||
|
@ -460,13 +443,24 @@ ContentBlocking::CompleteAllowAccessFor(
|
|||
_spec),
|
||||
trackingPrincipal);
|
||||
ContentBlockingNotifier::OnDecision(
|
||||
parentInnerWindow, ContentBlockingNotifier::BlockingDecision::eBlock,
|
||||
aParentContext, ContentBlockingNotifier::BlockingDecision::eBlock,
|
||||
CookieJarSettings::IsRejectThirdPartyWithExceptions(aCookieBehavior)
|
||||
? nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
|
||||
: nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER);
|
||||
return StorageAccessGrantPromise::CreateAndReject(false, __func__);
|
||||
}
|
||||
|
||||
// Ensure we can find the window before continuing, so we can safely
|
||||
// execute storePermission.
|
||||
if (aParentContext->IsInProcess() &&
|
||||
(!aParentContext->GetDOMWindow() ||
|
||||
!aParentContext->GetDOMWindow()->GetCurrentInnerWindow())) {
|
||||
LOG(
|
||||
("No window found for our parent browsing context, bailing out "
|
||||
"early"));
|
||||
return StorageAccessGrantPromise::CreateAndReject(false, __func__);
|
||||
}
|
||||
|
||||
auto storePermission =
|
||||
[aParentContext, aTopLevelWindowId, trackingOrigin, trackingPrincipal,
|
||||
aCookieBehavior,
|
||||
|
|
|
@ -446,6 +446,39 @@ void ContentBlockingNotifier::OnDecision(nsPIDOMWindowInner* aWindow,
|
|||
NotifyBlockingDecision(channel, aDecision, aRejectedReason, uri);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void ContentBlockingNotifier::OnDecision(BrowsingContext* aBrowsingContext,
|
||||
BlockingDecision aDecision,
|
||||
uint32_t aRejectedReason) {
|
||||
MOZ_ASSERT(aBrowsingContext);
|
||||
MOZ_ASSERT_IF(XRE_IsContentProcess(), aBrowsingContext->IsInProcess());
|
||||
|
||||
if (aBrowsingContext->IsInProcess()) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> outer = aBrowsingContext->GetDOMWindow();
|
||||
if (NS_WARN_IF(!outer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> inner = outer->GetCurrentInnerWindow();
|
||||
if (NS_WARN_IF(!inner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ContentBlockingNotifier::OnDecision(inner, aDecision, aRejectedReason);
|
||||
} else {
|
||||
// we send an IPC to the content process when we don't have an in-process
|
||||
// browsing context. This is not smart because this should be able to be
|
||||
// done directly in the parent. The reason we are doing this is because we
|
||||
// need the channel, which is not accessible in the parent when you only
|
||||
// have a browsing context.
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
ContentParent* cp = aBrowsingContext->Canonical()->GetContentParent();
|
||||
Unused << cp->SendOnContentBlockingDecision(aBrowsingContext, aDecision,
|
||||
aRejectedReason);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void ContentBlockingNotifier::OnEvent(nsIChannel* aTrackingChannel,
|
||||
uint32_t aRejectedReason) {
|
||||
|
|
|
@ -17,6 +17,9 @@ class nsPIDOMWindowInner;
|
|||
class nsPIDOMWindowOuter;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class BrowsingContext;
|
||||
} // namespace dom
|
||||
|
||||
class ContentBlockingNotifier final {
|
||||
public:
|
||||
|
@ -49,6 +52,9 @@ class ContentBlockingNotifier final {
|
|||
static void OnDecision(nsPIDOMWindowInner* aWindow,
|
||||
BlockingDecision aDecision, uint32_t aRejectedReason);
|
||||
|
||||
static void OnDecision(dom::BrowsingContext* aBrowsingContext,
|
||||
BlockingDecision aDecision, uint32_t aRejectedReason);
|
||||
|
||||
static void OnEvent(nsIChannel* aChannel, uint32_t aRejectedReason);
|
||||
|
||||
static void OnEvent(
|
||||
|
|
Загрузка…
Ссылка в новой задаче