Chromium Code Reviews| Index: content/browser/browser_plugin/browser_plugin_embedder_helper.cc |
| diff --git a/content/browser/browser_plugin/browser_plugin_embedder_helper.cc b/content/browser/browser_plugin/browser_plugin_embedder_helper.cc |
| index 6398917e318ae84c5dc0caf4a24cbbf9ed70ab5d..38b6b8137e6ff3bf99d7a638bbfe92ccc1e8fc9b 100644 |
| --- a/content/browser/browser_plugin/browser_plugin_embedder_helper.cc |
| +++ b/content/browser/browser_plugin/browser_plugin_embedder_helper.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/time.h" |
| #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
| +#include "content/browser/browser_plugin/browser_plugin_guest.h" |
| #include "content/browser/renderer_host/render_view_host_impl.h" |
| #include "content/browser/renderer_host/render_widget_host_impl.h" |
| #include "content/browser/web_contents/web_contents_impl.h" |
| @@ -34,6 +35,33 @@ bool BrowserPluginEmbedderHelper::Send(IPC::Message* message) { |
| bool BrowserPluginEmbedderHelper::OnMessageReceived( |
| const IPC::Message& message) { |
| + if (static_cast<content::RenderViewHostImpl*>(render_view_host())-> |
|
nasko
2012/09/19 21:19:59
Can't this whole block be done through another IPC
|
| + is_swapped_out()) { |
| + // If this is a swapped out RVH then it's possible that this is actually |
| + // a guest RVH living in the embedder process to facilitate postMessage. |
| + if (message.type() == ViewHostMsg_RouteMessageEvent::ID) { |
| + ViewMsg_PostMessage_Params route_message_params; |
| + PickleIterator iter(message); |
| + if (!IPC::ReadParam(&message, &iter, &route_message_params)) |
| + return false; |
| + // This RVH is swapped out in the embedder process. If its WebContents |
| + // has a BrowserPluginGuest then we know this is actually a RVH for the |
|
nasko
2012/09/19 21:19:59
nit: BrowserPluginGuest, then
Fady Samuel
2012/09/20 15:24:28
Done.
|
| + // guest in the embedder's render process for the purpose of catching |
| + // ViewHostMsg_RouteMessageEvent and routing it to the guest. |
| + // This code path is executed when the embedder tries to send a message |
| + // back through. |
|
nasko
2012/09/19 21:19:59
Is this the event.source.postMessage code path? Th
Fady Samuel
2012/09/20 15:24:28
Done.
|
| + WebContentsImpl* guest_web_contents = static_cast<WebContentsImpl*>( |
| + render_view_host()->GetDelegate()); |
| + if (guest_web_contents->GetBrowserPluginGuest()) { |
| + OnRouteMessageEvent( |
| + guest_web_contents->GetBrowserPluginGuest()->instance_id(), |
| + route_message_params.data, |
| + route_message_params.target_origin); |
| + return true; |
| + } |
| + } |
| + return false; |
| + } |
| bool handled = true; |
| IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedderHelper, message) |
| IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, |
| @@ -44,10 +72,13 @@ bool BrowserPluginEmbedderHelper::OnMessageReceived( |
| IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent, |
| OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message), |
| &handled)) |
| + IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_RouteMessageEvent, |
| + OnRouteMessageEvent) |
| IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, |
| OnPluginDestroyed); |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| + |
| return handled; |
| } |
| @@ -151,4 +182,11 @@ void BrowserPluginEmbedderHelper::OnPluginDestroyed(int instance_id) { |
| embedder_->PluginDestroyed(instance_id); |
| } |
| +void BrowserPluginEmbedderHelper::OnRouteMessageEvent( |
| + int instance_id, |
| + const string16& data, |
| + const string16& target_origin) { |
| + embedder_->RouteMessageEvent(instance_id, data, target_origin); |
| +} |
| + |
| } // namespace content |