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 6c15c98d11d411a8b82afec86345bd03478e8cfe..adf3608bf5e8af568f7f025e08bd943b9632ae40 100644 |
| --- a/content/browser/browser_plugin/browser_plugin_embedder_helper.cc |
| +++ b/content/browser/browser_plugin/browser_plugin_embedder_helper.cc |
| @@ -5,7 +5,9 @@ |
| #include "content/browser/browser_plugin/browser_plugin_embedder_helper.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/web_contents/web_contents_impl.h" |
| #include "content/common/browser_plugin_messages.h" |
| #include "content/common/view_messages.h" |
| #include "content/public/browser/render_process_host.h" |
| @@ -32,6 +34,15 @@ bool BrowserPluginEmbedderHelper::Send(IPC::Message* message) { |
| bool BrowserPluginEmbedderHelper::OnMessageReceived( |
| const IPC::Message& message) { |
| bool handled = true; |
| + if (static_cast<content::RenderViewHostImpl*>(render_view_host())-> |
| + is_swapped_out()) { |
| + IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedderHelper, message) |
| + IPC_MESSAGE_HANDLER(ViewHostMsg_RouteMessageEvent, |
| + OnRouteMessageEvent) |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP() |
| + return handled; |
| + } |
| IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedderHelper, message) |
| IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, |
| OnCreateGuest); |
| @@ -50,6 +61,7 @@ bool BrowserPluginEmbedderHelper::OnMessageReceived( |
| IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| + |
| return handled; |
| } |
| @@ -136,6 +148,28 @@ void BrowserPluginEmbedderHelper::OnPluginDestroyed(int instance_id) { |
| embedder_->PluginDestroyed(instance_id); |
| } |
| +void BrowserPluginEmbedderHelper::OnRouteMessageEvent( |
|
Charlie Reis
2012/10/04 21:58:25
Again, it seems like WebContentsImpl should alread
Fady Samuel
2012/10/10 21:36:07
Done.
|
| + const ViewMsg_PostMessage_Params& params) { |
| + // This helper's RVH corresponds to a swapped out RenderView living in |
| + // the embedder's render process. If this RVH's WebContents has a |
| + // BrowserPluginGuest, then we know this is actually a RVH for the |
| + // guest for the purpose of catching ViewHostMsg_RouteMessageEvent and |
| + // routing it to the guest WebContents. |
| + // This code path is executed when the embedder tries to send a message |
| + // back through event.source.postMessage within a 'message' event |
| + // listener. |
| + WebContentsImpl* guest_web_contents = static_cast<WebContentsImpl*>( |
| + render_view_host()->GetDelegate()); |
| + if (!guest_web_contents->GetBrowserPluginGuest()) |
| + return; |
| + embedder_->RouteMessageEvent( |
| + guest_web_contents->GetBrowserPluginGuest()->instance_id(), |
| + params.data, |
| + params.source_frame_id, |
| + params.target_origin, |
| + params.target_frame_id); |
| +} |
| + |
| void BrowserPluginEmbedderHelper::OnGo(int instance_id, int relative_index) { |
| embedder_->Go(instance_id, relative_index); |
| } |