зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1626362 - Move url classifier notifications to parent process. r=nika,necko-reviewers,JuniorHsu
We shouldn't need to handle this with an early return in docshell, since the classifier failure codes won't display an error page anyway. Differential Revision: https://phabricator.services.mozilla.com/D80108
This commit is contained in:
Родитель
55f60f13b9
Коммит
87cdbac816
|
@ -6018,63 +6018,6 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
|
|||
// 5. Throw an error dialog box...
|
||||
//
|
||||
if (NS_FAILED(aStatus)) {
|
||||
// Handle iframe document not loading error because source was
|
||||
// a tracking URL. We make a note of this iframe node by including
|
||||
// it in a dedicated array of blocked tracking nodes under its parent
|
||||
// document. (document of parent window of blocked document)
|
||||
if (!isTopFrame &&
|
||||
UrlClassifierFeatureFactory::IsClassifierBlockingErrorCode(aStatus)) {
|
||||
UnblockEmbedderLoadEventForFailure();
|
||||
|
||||
// We don't really need to add the blocked node if we are not testing.
|
||||
// This could save a IPC here.
|
||||
if (!StaticPrefs::
|
||||
privacy_trackingprotection_testing_report_blocked_node()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<BrowsingContext> bc = GetBrowsingContext();
|
||||
RefPtr<BrowsingContext> parentBC = bc->GetParent();
|
||||
|
||||
if (!parentBC) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (parentBC->IsInProcess()) {
|
||||
// We can directly add the blocked node in the parent document if the
|
||||
// parent is in the same process.
|
||||
nsCOMPtr<nsPIDOMWindowOuter> parentOuter = parentBC->GetDOMWindow();
|
||||
|
||||
if (!parentOuter) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> parentInner =
|
||||
parentOuter->GetCurrentInnerWindow();
|
||||
|
||||
if (!parentInner) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<Document> parentDoc;
|
||||
parentDoc = parentInner->GetExtantDoc();
|
||||
if (!parentDoc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
parentDoc->AddBlockedNodeByClassifier(bc->GetEmbedderElement());
|
||||
} else {
|
||||
// If the parent is out-of-process, we send to the process of the
|
||||
// document which embeds the frame to add the blocked node there.
|
||||
RefPtr<BrowserChild> browserChild = BrowserChild::GetFrom(this);
|
||||
if (browserChild) {
|
||||
Unused << browserChild->SendReportBlockedEmbedderNodeByClassifier();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> newPostData;
|
||||
nsCOMPtr<nsIURI> newURI =
|
||||
AttemptURIFixup(aChannel, aStatus, Some(mOriginalUriString), mLoadType,
|
||||
|
|
|
@ -221,21 +221,6 @@ mozilla::ipc::IPCResult BrowserBridgeChild::RecvSubFrameCrashed() {
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult BrowserBridgeChild::RecvAddBlockedNodeByClassifier() {
|
||||
RefPtr<Element> owner = mFrameLoader->GetOwnerContent();
|
||||
if (!owner) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
RefPtr<Document> doc = mFrameLoader->GetOwnerDoc();
|
||||
if (!doc) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
doc->AddBlockedNodeByClassifier(owner);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void BrowserBridgeChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
if (!mBrowsingContext) {
|
||||
// This BBC was never valid, skip teardown.
|
||||
|
|
|
@ -94,8 +94,6 @@ class BrowserBridgeChild : public PBrowserBridgeChild {
|
|||
|
||||
mozilla::ipc::IPCResult RecvSubFrameCrashed();
|
||||
|
||||
mozilla::ipc::IPCResult RecvAddBlockedNodeByClassifier();
|
||||
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -2763,18 +2763,6 @@ mozilla::ipc::IPCResult BrowserParent::RecvNotifyContentBlockingEvent(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
BrowserParent::RecvReportBlockedEmbedderNodeByClassifier() {
|
||||
BrowserBridgeParent* bridge = GetBrowserBridgeParent();
|
||||
|
||||
if (!bridge) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
Unused << bridge->SendAddBlockedNodeByClassifier();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIBrowser> BrowserParent::GetBrowser() {
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
RefPtr<Element> currentElement = mFrameElement;
|
||||
|
|
|
@ -314,8 +314,6 @@ class BrowserParent final : public PBrowserParent,
|
|||
const Maybe<mozilla::ContentBlockingNotifier::
|
||||
StorageAccessPermissionGrantedReason>& aReason);
|
||||
|
||||
mozilla::ipc::IPCResult RecvReportBlockedEmbedderNodeByClassifier();
|
||||
|
||||
mozilla::ipc::IPCResult RecvNavigationFinished();
|
||||
|
||||
already_AddRefed<nsIBrowser> GetBrowser();
|
||||
|
|
|
@ -672,8 +672,6 @@ parent:
|
|||
ScrollAxis aHorizontal, ScrollFlags aScrollFlags,
|
||||
int32_t aAppUnitsPerDevPixel);
|
||||
|
||||
async ReportBlockedEmbedderNodeByClassifier();
|
||||
|
||||
child:
|
||||
/**
|
||||
* Notify the remote browser that it has been Show()n on this side. This
|
||||
|
|
|
@ -66,8 +66,6 @@ child:
|
|||
|
||||
async SubFrameCrashed();
|
||||
|
||||
async AddBlockedNodeByClassifier();
|
||||
|
||||
parent:
|
||||
// Destroy the remote web browser due to the nsFrameLoader going away.
|
||||
async __delete__();
|
||||
|
|
|
@ -72,6 +72,8 @@ child:
|
|||
|
||||
async SaveStorageAccessPermissionGranted();
|
||||
|
||||
async AddBlockedFrameNodeByClassifier(MaybeDiscardedBrowsingContext aNode);
|
||||
|
||||
both:
|
||||
async RawMessage(JSActorMessageMeta aMetadata, ClonedMessageData aData,
|
||||
ClonedMessageData aStack);
|
||||
|
|
|
@ -525,6 +525,27 @@ mozilla::ipc::IPCResult WindowGlobalChild::RecvDispatchSecurityPolicyViolation(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult WindowGlobalChild::RecvAddBlockedFrameNodeByClassifier(
|
||||
const MaybeDiscardedBrowsingContext& aNode) {
|
||||
if (aNode.IsNullOrDiscarded()) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsGlobalWindowInner* window = GetWindowGlobal();
|
||||
if (!window) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
Document* doc = window->GetDocument();
|
||||
if (!doc) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aNode.get()->GetEmbedderElement()->OwnerDoc() == doc);
|
||||
doc->AddBlockedNodeByClassifier(aNode.get()->GetEmbedderElement());
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
IPCResult WindowGlobalChild::RecvRawMessage(const JSActorMessageMeta& aMeta,
|
||||
const ClonedMessageData& aData,
|
||||
const ClonedMessageData& aStack) {
|
||||
|
|
|
@ -146,6 +146,9 @@ class WindowGlobalChild final : public WindowGlobalActor,
|
|||
|
||||
mozilla::ipc::IPCResult RecvSaveStorageAccessPermissionGranted();
|
||||
|
||||
mozilla::ipc::IPCResult RecvAddBlockedFrameNodeByClassifier(
|
||||
const MaybeDiscardedBrowsingContext& aNode);
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/RemoteWebProgress.h"
|
||||
#include "mozilla/dom/RemoteWebProgressRequest.h"
|
||||
#include "mozilla/net/UrlClassifierFeatureFactory.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
# include "mozilla/widget/nsWindow.h"
|
||||
|
@ -1537,6 +1538,23 @@ void DocumentLoadListener::TriggerRedirectToRealChannel(
|
|||
});
|
||||
}
|
||||
|
||||
void DocumentLoadListener::MaybeReportBlockedByURLClassifier(nsresult aStatus) {
|
||||
if (!GetBrowsingContext() || GetBrowsingContext()->IsTop() ||
|
||||
!StaticPrefs::privacy_trackingprotection_testing_report_blocked_node()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UrlClassifierFeatureFactory::IsClassifierBlockingErrorCode(aStatus)) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<WindowGlobalParent> parent =
|
||||
GetBrowsingContext()->GetParentWindowContext();
|
||||
if (parent) {
|
||||
Unused << parent->SendAddBlockedFrameNodeByClassifier(GetBrowsingContext());
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
|
||||
LOG(("DocumentLoadListener OnStartRequest [this=%p]", this));
|
||||
|
@ -1583,6 +1601,8 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
|
|||
|
||||
mInitiatedRedirectToRealChannel = true;
|
||||
|
||||
MaybeReportBlockedByURLClassifier(status);
|
||||
|
||||
// Determine if a new process needs to be spawned. If it does, this will
|
||||
// trigger a cross process switch, and we should hold off on redirecting to
|
||||
// the real channel.
|
||||
|
|
|
@ -284,6 +284,8 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
|
|||
|
||||
void Disconnect();
|
||||
|
||||
void MaybeReportBlockedByURLClassifier(nsresult aStatus);
|
||||
|
||||
// This defines a variant that describes all the attribute setters (and their
|
||||
// parameters) from nsIParentChannel
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче