Index: components/guest_view/browser/guest_view_message_filter.cc |
diff --git a/components/guest_view/browser/guest_view_message_filter.cc b/components/guest_view/browser/guest_view_message_filter.cc |
index 13835a0ff6441793c8577fb31108bbede147ff38..d6a47b0d475b933705652e7ea313d303cd444774 100644 |
--- a/components/guest_view/browser/guest_view_message_filter.cc |
+++ b/components/guest_view/browser/guest_view_message_filter.cc |
@@ -74,6 +74,8 @@ bool GuestViewMessageFilter::OnMessageReceived(const IPC::Message& message) { |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(GuestViewMessageFilter, message) |
IPC_MESSAGE_HANDLER(GuestViewHostMsg_AttachGuest, OnAttachGuest) |
+ IPC_MESSAGE_HANDLER(GuestViewHostMsg_AttachToEmbedderFrame, |
+ OnAttachToEmbedderFrame) |
IPC_MESSAGE_HANDLER(GuestViewHostMsg_ViewCreated, OnViewCreated) |
IPC_MESSAGE_HANDLER(GuestViewHostMsg_ViewGarbageCollected, |
OnViewGarbageCollected) |
@@ -112,4 +114,39 @@ void GuestViewMessageFilter::OnAttachGuest( |
params); |
} |
+void GuestViewMessageFilter::OnAttachToEmbedderFrame( |
+ int embedder_local_render_frame_id, |
+ int element_instance_id, |
+ int guest_instance_id, |
+ const base::DictionaryValue& params) { |
+ auto* manager = GuestViewManager::FromBrowserContext(browser_context_); |
+ DCHECK(manager); |
+ content::WebContents* guest_web_contents = |
+ manager->GetGuestByInstanceIDSafely(guest_instance_id, |
+ render_process_id_); |
+ DCHECK(guest_web_contents); |
Fady Samuel
2015/06/24 22:01:10
I would consider CHECK'ing here. If the above fail
lazyboy
2015/06/24 23:01:50
I'm doing early exit.
Done.
|
+ auto* guest = GuestViewBase::FromWebContents(guest_web_contents); |
+ DCHECK(guest); |
+ content::WebContents* owner_web_contents = guest->owner_web_contents(); |
+ DCHECK(owner_web_contents); |
+ auto* embedder_frame = RenderFrameHost::FromID( |
+ render_process_id_, embedder_local_render_frame_id); |
+ guest_web_contents->AttachToOuterWebContentsFrame(owner_web_contents, |
Fady Samuel
2015/06/24 22:01:10
Comment above this explaining briefly what it does
lazyboy
2015/06/24 23:01:50
Done.
|
+ embedder_frame); |
+ |
+ manager->AttachGuest(render_process_id_, element_instance_id, |
Fady Samuel
2015/06/24 22:01:10
Comment above this explaining briefly what it does
lazyboy
2015/06/24 23:01:50
Done.
|
+ guest_instance_id, params); |
+ |
+ owner_web_contents->GetMainFrame()->Send( |
+ new GuestViewMsg_AttachToEmbedderFrame_ACK(element_instance_id)); |
+ |
+ guest->WillAttach( |
+ owner_web_contents, element_instance_id, false, |
+ base::Bind(&GuestViewMessageFilter::WillAttachCallback, this, guest)); |
Fady Samuel
2015/06/24 22:01:10
nit: Can you bind directly? base::Bind(&GuestView
lazyboy
2015/06/24 23:01:50
passing |guest| as |this| wouldn't work as |guest|
|
+} |
+ |
+void GuestViewMessageFilter::WillAttachCallback(GuestViewBase* guest) { |
+ guest->DidAttach(MSG_ROUTING_NONE); |
+} |
+ |
} // namespace guest_view |