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

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

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT. Added subframe targeting + test. Created 8 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_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 7039b2bb06fa548466dab0491ea084c5bc8387f4..68331cea377f1f05ccdf165f23828c4b720e4eb6 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_NavigateGuest,
OnNavigateGuest);
@@ -48,6 +59,7 @@ bool BrowserPluginEmbedderHelper::OnMessageReceived(
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
+
return handled;
}
@@ -121,6 +133,28 @@ void BrowserPluginEmbedderHelper::OnPluginDestroyed(int instance_id) {
embedder_->PluginDestroyed(instance_id);
}
+void BrowserPluginEmbedderHelper::OnRouteMessageEvent(
+ 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);
}

Powered by Google App Engine
This is Rietveld 408576698