Bug 1599043 - Part 5: Add an IPC message to allow content process to notify the OnContentBlockingEvent in the parent. r=dimi,Ehsan

This patch adds an IPC message which allows content process to notify
the OnContentBlockingEvent in the parent process. This is needed because
there are some situations that the content blocking happens in content
processes, so we need to tell the parent process to notify it. Such as,
AntiTrackingCommon::AntiTrackingCommon::AddFirstPartyStorageAccessGrantedFor().

Differential Revision: https://phabricator.services.mozilla.com/D55648

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tim Huang 2019-12-11 15:00:53 +00:00
Родитель 4d90cf0737
Коммит 40be750cfd
7 изменённых файлов: 96 добавлений и 0 удалений

Просмотреть файл

@ -4008,6 +4008,25 @@ BrowserChild::DoesWindowSupportProtectedMedia() {
}
#endif
void BrowserChild::NotifyContentBlockingEvent(
uint32_t aEvent, nsIChannel* aChannel, bool aBlocked, nsIURI* aHintURI,
const nsTArray<nsCString>& aTrackingFullHashes,
const Maybe<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>&
aReason) {
if (!IPCOpen()) {
return;
}
Maybe<WebProgressData> webProgressData;
RequestData requestData;
nsresult rv = PrepareProgressListenerData(nullptr, aChannel, webProgressData,
requestData);
NS_ENSURE_SUCCESS_VOID(rv);
Unused << SendNotifyContentBlockingEvent(
aEvent, requestData, aBlocked, aHintURI, aTrackingFullHashes, aReason);
}
BrowserChildMessageManager::BrowserChildMessageManager(
BrowserChild* aBrowserChild)
: ContentFrameMessageManager(new nsFrameMessageManager(aBrowserChild)),

Просмотреть файл

@ -685,6 +685,11 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
DoesWindowSupportProtectedMedia();
#endif
void NotifyContentBlockingEvent(
uint32_t aEvent, nsIChannel* aChannel, bool aBlocked, nsIURI* aHintURI,
const nsTArray<nsCString>& aTrackingFullHashes,
const Maybe<AntiTrackingCommon::StorageAccessGrantedReason>& aReason);
protected:
virtual ~BrowserChild();

Просмотреть файл

@ -2702,6 +2702,35 @@ mozilla::ipc::IPCResult BrowserParent::RecvNavigationFinished() {
return IPC_OK();
}
mozilla::ipc::IPCResult BrowserParent::RecvNotifyContentBlockingEvent(
const uint32_t& aEvent, const RequestData& aRequestData,
const bool aBlocked, nsIURI* aHintURI,
nsTArray<nsCString>&& aTrackingFullHashes,
const Maybe<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>&
aReason) {
MOZ_ASSERT(aRequestData.elapsedLoadTimeMS().isNothing());
RefPtr<BrowsingContext> bc = GetBrowsingContext();
if (!bc || bc->IsDiscarded()) {
return IPC_OK();
}
// Get the top-level browsing context.
bc = bc->Top();
RefPtr<dom::WindowGlobalParent> wgp =
bc->Canonical()->GetCurrentWindowGlobal();
nsCOMPtr<nsIRequest> request = MakeAndAddRef<RemoteWebProgressRequest>(
aRequestData.requestURI(), aRequestData.originalRequestURI(),
aRequestData.matchedList(), aRequestData.elapsedLoadTimeMS());
wgp->NotifyContentBlockingEvent(aEvent, request, aBlocked, aHintURI,
aTrackingFullHashes, aReason);
return IPC_OK();
}
bool BrowserParent::GetWebProgressListener(
nsIBrowser** aOutBrowser, nsIWebProgress** aOutManager,
nsIWebProgressListener** aOutListener) {

Просмотреть файл

@ -320,6 +320,13 @@ class BrowserParent final : public PBrowserParent,
const Maybe<WebProgressData>& aWebProgressData,
const RequestData& aRequestData, const uint32_t& aEvent);
mozilla::ipc::IPCResult RecvNotifyContentBlockingEvent(
const uint32_t& aEvent, const RequestData& aRequestData,
const bool aBlocked, nsIURI* aHintURI,
nsTArray<nsCString>&& aTrackingFullHashes,
const Maybe<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>&
aReason);
mozilla::ipc::IPCResult RecvNavigationFinished();
bool GetWebProgressListener(nsIBrowser** aOutBrowser,

Просмотреть файл

@ -30,6 +30,7 @@ include PPrintingTypes;
include PTabContext;
include PBackgroundSharedTypes;
include "mozilla/AntiTrackingIPCUtils.h";
include "mozilla/GfxMessageUtils.h";
include "mozilla/layers/LayersMessageUtils.h";
include "mozilla/ipc/TransportSecurityInfoUtils.h";
@ -97,6 +98,7 @@ using mozilla::ScrollFlags from "mozilla/PresShellForwards.h";
using struct InputFormData from "mozilla/dom/SessionStoreMessageUtils.h";
using struct CollectedInputDataValue from "mozilla/dom/SessionStoreMessageUtils.h";
using refcounted class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
using mozilla::AntiTrackingCommon::StorageAccessGrantedReason from "mozilla/AntiTrackingCommon.h";
namespace mozilla {
namespace dom {
@ -624,6 +626,11 @@ parent:
async OnContentBlockingEvent(WebProgressData? aWebProgressData,
RequestData aRequestData, uint32_t aEvent);
async NotifyContentBlockingEvent(uint32_t aEvent, RequestData aRequestData,
bool aBlocked, nsIURI aHintURI,
nsCString[] aTrackingFullHashes,
StorageAccessGrantedReason? aReason);
async NavigationFinished();
async SessionStoreUpdate(nsCString? aDocShellCaps, bool? aPrivatedMode,

Просмотреть файл

@ -0,0 +1,28 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_antitrackingipcutils_h
#define mozilla_antitrackingipcutils_h
#include "ipc/IPCMessageUtils.h"
#include "mozilla/AntiTrackingCommon.h"
namespace IPC {
// For allowing passing the enum AntiTrackingCommon::StorageAccessGrantedReason
// over IPC.
template <>
struct ParamTraits<mozilla::AntiTrackingCommon::StorageAccessGrantedReason>
: public ContiguousEnumSerializerInclusive<
mozilla::AntiTrackingCommon::StorageAccessGrantedReason,
mozilla::AntiTrackingCommon::StorageAccessGrantedReason::
eStorageAccessAPI,
mozilla::AntiTrackingCommon::StorageAccessGrantedReason::eOpener> {};
} // namespace IPC
#endif // mozilla_antitrackingipcutils_h

Просмотреть файл

@ -32,6 +32,7 @@ XPCOM_MANIFESTS += [
EXPORTS.mozilla = [
'AntiTrackingCommon.h',
'AntiTrackingIPCUtils.h',
'StorageAccess.h',
'StoragePrincipalHelper.h',
'URLDecorationStripper.h',