0

Make AppWindowContentsImpl MPArch-aware

Limit extensions::AppWindowContentsImpl DidFinishNavigation and
UpdateDraggableRegions to the primary main frame.

Bug: 1322068
Change-Id: I7d00136b6e00981d1f758aa0a7e9256878f1ce89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3623602
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1013682}
This commit is contained in:
Henrique Ferreiro
2022-06-13 22:25:45 +00:00
committed by Chromium LUCI CQ
parent a83dcbef0c
commit 8dbd453870
3 changed files with 16 additions and 2 deletions
extensions/browser
tools/metrics/histograms

@ -10,12 +10,14 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/browser/bad_message.h"
#include "extensions/browser/extension_web_contents_observer.h"
#include "extensions/common/extension_messages.h"
#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
@ -107,6 +109,9 @@ bool AppWindowContentsImpl::OnMessageReceived(
void AppWindowContentsImpl::DidFinishNavigation(
content::NavigationHandle* handle) {
if (!handle->IsInPrimaryMainFrame())
return;
// The callback inside app_window will be moved after the first call.
host_->OnDidFinishFirstNavigation();
}
@ -114,8 +119,15 @@ void AppWindowContentsImpl::DidFinishNavigation(
void AppWindowContentsImpl::UpdateDraggableRegions(
content::RenderFrameHost* sender,
const std::vector<DraggableRegion>& regions) {
if (!sender->GetParent()) // Only process events from the main frame.
host_->UpdateDraggableRegions(regions);
// This message should come from a primary main frame.
if (!sender->IsInPrimaryMainFrame()) {
bad_message::ReceivedBadMessage(
web_contents_->GetMainFrame()->GetProcess(),
bad_message::AWCI_INVALID_CALL_FROM_NOT_PRIMARY_MAIN_FRAME);
return;
}
host_->UpdateDraggableRegions(regions);
}
} // namespace extensions

@ -42,6 +42,7 @@ enum BadMessageReason {
EMF_INVALID_EXTENSION_ID_FOR_CONTENT_SCRIPT = 16,
EMF_INVALID_EXTENSION_ID_FOR_WORKER_CONTEXT = 17,
EMF_INVALID_PORT_CONTEXT = 18,
AWCI_INVALID_CALL_FROM_NOT_PRIMARY_MAIN_FRAME = 19,
// Please add new elements here. The naming convention is abbreviated class
// name (e.g. ExtensionHost becomes EH) plus a unique description of the
// reason. After making changes, you MUST update histograms.xml by running:

@ -10564,6 +10564,7 @@ Called by update_bad_message_reasons.py.-->
<int value="16" label="EMF_INVALID_EXTENSION_ID_FOR_CONTENT_SCRIPT"/>
<int value="17" label="EMF_INVALID_EXTENSION_ID_FOR_WORKER_CONTEXT"/>
<int value="18" label="EMF_INVALID_PORT_CONTEXT"/>
<int value="19" label="AWCI_INVALID_CALL_FROM_NOT_PRIMARY_MAIN_FRAME"/>
</enum>
<enum name="BadMessageReasonGuestView">