Commit 3a266b76 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Introduce blink::mojom:::RemoteMainFrame interface

... and binding logic, pPreparation work for migrating
PageMsg_UpdateTextAutosizerPageInfoForRemoteMainFrames to Mojom.

This CL is a preparing CL that binds blink::RemoteFrame instances to
blink::mojom::RemoteFrameFrame interface, when it is appropriate.
It makes use of the existing WebViewImpl::DidAttachRemoteMainFrame() hook.

BUG=1102440
R=dtapuska@chromium.org

Change-Id: I792f26f38070dc9a168c0c76081941450243a5f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2307152Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Dominick Ng <dominickn@chromium.org>
Auto-Submit: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#790199}
parent c2f123c4
......@@ -885,6 +885,17 @@ interface LocalMainFrame {
pending_remote<network.mojom.CrossOriginOpenerPolicyReporter> reporter);
};
// Implemented in Blink, this interface defines remote main-frame-specific
// methods that will be invoked from the browser process (e.g.
// content::RenderFrameProxyHost).
//
// There is only ever one remote main frame for a given tab in all renderer
// processes.
//
// This interface will only be provided when the RemoteFrame is a main frame.
interface RemoteMainFrame {
};
// Implemented in Browser, this interface defines local-main-frame-specific
// methods that will be invoked from the renderer process (e.g. WebViewImpl).
interface LocalMainFrameHost {
......
......@@ -2010,7 +2010,7 @@ void WebViewImpl::DidAttachRemoteMainFrame() {
DCHECK(!MainFrameImpl());
RemoteFrame* remote_frame = DynamicTo<RemoteFrame>(GetPage()->MainFrame());
DCHECK(remote_frame);
remote_frame->WasAttachedAsRemoteMainFrame();
remote_frame->GetRemoteAssociatedInterfaces()->GetInterface(
remote_main_frame_host_remote_.BindNewEndpointAndPassReceiver());
......
......@@ -95,7 +95,10 @@ RemoteFrame::RemoteFrame(
owner,
frame_token,
MakeGarbageCollected<RemoteWindowProxyManager>(*this),
inheriting_agent_factory) {
inheriting_agent_factory),
interface_registry_(
interface_registry ? interface_registry
: InterfaceRegistry::GetEmptyInterfaceRegistry()) {
// TODO(crbug.com/1094850): Remove this check once the renderer is correctly
// handling errors during the creation of HTML portal elements, which would
// otherwise cause RemoteFrame() being created with empty frame tokens.
......@@ -225,6 +228,7 @@ void RemoteFrame::DetachImpl(FrameDetachType type) {
if (cc_layer_)
SetCcLayer(nullptr, false, false);
receiver_.reset();
main_frame_receiver_.reset();
}
bool RemoteFrame::DetachDocument() {
......@@ -723,6 +727,11 @@ void RemoteFrame::SetOpener(Frame* opener_frame) {
}
}
void RemoteFrame::WasAttachedAsRemoteMainFrame() {
interface_registry_->AddAssociatedInterface(WTF::BindRepeating(
&RemoteFrame::BindToMainFrameReceiver, WrapWeakPersistent(this)));
}
bool RemoteFrame::IsIgnoredForHitTest() const {
HTMLFrameOwnerElement* owner = DeprecatedLocalOwner();
if (!owner || !owner->GetLayoutObject())
......@@ -791,10 +800,17 @@ void RemoteFrame::ApplyReplicatedFeaturePolicyHeader() {
}
void RemoteFrame::BindToReceiver(
blink::RemoteFrame* frame,
RemoteFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::RemoteFrame> receiver) {
DCHECK(frame);
frame->receiver_.Bind(std::move(receiver));
}
void RemoteFrame::BindToMainFrameReceiver(
RemoteFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::RemoteMainFrame> receiver) {
DCHECK(frame);
frame->main_frame_receiver_.Bind(std::move(receiver));
}
} // namespace blink
......@@ -33,6 +33,7 @@ class RemoteFrameClient;
struct FrameLoadRequest;
class CORE_EXPORT RemoteFrame final : public Frame,
public mojom::blink::RemoteMainFrame,
public mojom::blink::RemoteFrame {
public:
// Returns the RemoteFrame for the given |frame_token|.
......@@ -169,6 +170,9 @@ class CORE_EXPORT RemoteFrame final : public Frame,
void SetOpener(Frame* opener) override;
// Indicate that this frame was attached as a MainFrame.
void WasAttachedAsRemoteMainFrame();
private:
// Frame protected overrides:
void DetachImpl(FrameDetachType) override;
......@@ -182,8 +186,11 @@ class CORE_EXPORT RemoteFrame final : public Frame,
void ApplyReplicatedFeaturePolicyHeader();
static void BindToReceiver(
blink::RemoteFrame* frame,
RemoteFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::RemoteFrame> receiver);
static void BindToMainFrameReceiver(
RemoteFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::RemoteMainFrame> receiver);
Member<RemoteFrameView> view_;
RemoteSecurityContext security_context_;
......@@ -193,9 +200,13 @@ class CORE_EXPORT RemoteFrame final : public Frame,
ParsedFeaturePolicy feature_policy_header_;
String unique_name_;
InterfaceRegistry* const interface_registry_;
mojo::AssociatedRemote<mojom::blink::RemoteFrameHost>
remote_frame_host_remote_;
mojo::AssociatedReceiver<mojom::blink::RemoteFrame> receiver_{this};
mojo::AssociatedReceiver<mojom::blink::RemoteMainFrame> main_frame_receiver_{
this};
};
inline RemoteFrameView* RemoteFrame::View() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment