Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(984)

Unified Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 2417693002: Allow MimeHandlerViewGuest be embedded inside OOPIFs (Closed)
Patch Set: Addressing lfg@ and nasko@ comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_plugin/browser_plugin_guest.cc
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 461081dc723d4c338a3248725dc4a7e8e8bcdde1..631fe552a9ff05e1458c602fe8e32e265e235170 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -136,10 +136,19 @@ int BrowserPluginGuest::GetGuestProxyRoutingID() {
// owners in different processes. We probably need to clear the
// |guest_proxy_routing_id_| and perform any necessary cleanup on Detach
// to enable this.
- SiteInstance* owner_site_instance = owner_web_contents_->GetSiteInstance();
- int proxy_routing_id =
- GetWebContents()->GetFrameTree()->root()->render_manager()->
- CreateRenderFrameProxy(owner_site_instance);
+ //
+ // TODO(ekaramad): We create the proxy for post messaging to the guest. The
Charlie Reis 2016/11/02 20:47:06 nit: Say "to the guest below." (I was having a ha
EhsanK 2016/11/08 23:10:16 Sorry but I am a bit confused with the term "to th
+ // reverse route proxies are created when we first post message. However, if
+ // the guest is inisde an <iframe> (e.g., <embed>-ed PDF) then the reverse
Charlie Reis 2016/11/02 20:47:06 nit: inside
EhsanK 2016/11/08 23:10:16 Done.
+ // proxy is not created and the posted messages's source attribute is null.
+ // We should either create a RenderFrameProxyHost for the reverse path or
+ // implement MimeHandlerViewGuest's using OOPIF (https://crbug.com/659750).
+ SiteInstance* owner_site_instance = GetEmbedderFrame()->GetSiteInstance();
+ int proxy_routing_id = GetWebContents()
+ ->GetFrameTree()
+ ->root()
+ ->render_manager()
+ ->CreateRenderFrameProxy(owner_site_instance);
guest_proxy_routing_id_ = RenderFrameProxyHost::FromID(
owner_site_instance->GetProcess()->GetID(), proxy_routing_id)
->GetRenderViewHost()->GetRoutingID();
@@ -170,6 +179,10 @@ void BrowserPluginGuest::WillDestroy() {
attached_ = false;
}
+RenderFrameHostImpl* BrowserPluginGuest::GetEmbedderFrame() const {
+ return static_cast<RenderFrameHostImpl*>(delegate_->GetEmbedderFrame());
+}
+
void BrowserPluginGuest::Init() {
if (initialized_)
return;
@@ -242,11 +255,10 @@ bool BrowserPluginGuest::OnMessageReceivedFromEmbedder(
RenderWidgetHostViewGuest* rwhv = static_cast<RenderWidgetHostViewGuest*>(
web_contents()->GetRenderWidgetHostView());
// Until the guest is attached, it should not be handling input events.
- if (attached() && rwhv &&
- rwhv->OnMessageReceivedFromEmbedder(
- message,
- RenderWidgetHostImpl::From(
- embedder_web_contents()->GetRenderViewHost()->GetWidget()))) {
+ RenderFrameHostImpl* rfhi = GetEmbedderFrame();
+ RenderWidgetHostImpl* rwhi = rfhi ? rfhi->GetRenderWidgetHost() : nullptr;
Charlie Reis 2016/11/02 20:47:06 nit: Move these two lines above the "// Until" com
EhsanK 2016/11/08 23:10:16 Done.
+ if (attached() && rwhv && rwhi &&
+ rwhv->OnMessageReceivedFromEmbedder(message, rwhi)) {
return true;
}
@@ -374,9 +386,10 @@ bool BrowserPluginGuest::IsGuest(RenderViewHostImpl* render_view_host) {
}
RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() {
- if (!owner_web_contents_)
- return nullptr;
- return owner_web_contents_->GetRenderWidgetHostView();
+ if (GetEmbedderFrame())
+ return GetEmbedderFrame()->GetView();
+
+ return nullptr;
}
void BrowserPluginGuest::UpdateVisibility() {
@@ -448,8 +461,8 @@ void BrowserPluginGuest::ResendEventToEmbedder(
return;
DCHECK(browser_plugin_instance_id_);
- RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
- embedder_web_contents()->GetMainFrame()->GetView());
+ RenderWidgetHostViewBase* view =
+ static_cast<RenderWidgetHostViewBase*>(GetOwnerRenderWidgetHostView());
gfx::Vector2d offset_from_embedder = guest_window_rect_.OffsetFromOrigin();
if (event.type == blink::WebInputEvent::GestureScrollUpdate) {
@@ -506,7 +519,8 @@ void BrowserPluginGuest::SendMessageToEmbedder(
pending_messages_.push_back(std::move(msg));
return;
}
- owner_web_contents_->Send(msg.release());
+
+ GetEmbedderFrame()->GetRenderWidgetHost()->Send(msg.release());
Charlie Reis 2016/11/02 20:47:06 This change looks a little odd to me (sending via
EhsanK 2016/11/08 23:10:16 To respect the exact implementation, we should sen
}
void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y,

Powered by Google App Engine
This is Rietveld 408576698