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

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

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed crash + cleanup Created 8 years, 3 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.cc
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index 0a4cd01c9dc00288d2178c56d18796d4e6a843b4..091eb88c28e8500a033ae0fbbdf2426eef00f17c 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -268,6 +268,63 @@ void BrowserPluginEmbedder::PluginDestroyed(int instance_id) {
DestroyGuestByInstanceID(instance_id);
}
+void BrowserPluginEmbedder::RouteMessageEvent(
+ int instance_id,
+ const string16& data,
+ const string16& target_origin) {
+ BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
+ if (!guest)
+ return;
+
+ WebContentsImpl* guest_web_contents =
+ static_cast<WebContentsImpl*>(guest->web_contents());
+
+ ViewMsg_PostMessage_Params new_params;
+ new_params.data = data;
+ new_params.target_origin = target_origin;
+ new_params.target_frame_id = -1;
nasko 2012/09/19 21:19:59 nit: It will be useful if we have the real frame i
Fady Samuel 2012/09/20 15:24:28 Hmm, I'm not entirely sure what you want me to do
+ new_params.source_frame_id = -1;
+
+ SiteInstance* guest_site_instance = guest_web_contents->GetSiteInstance();
+ // Create a swapped out RenderView for the embedder in the guest render
+ // process if it does not already exist.
+ if (guest->swapped_out_guest_routing_id() == MSG_ROUTING_NONE) {
+ guest->set_swapped_out_guest_routing_id(
+ static_cast<WebContentsImpl*>(web_contents())->
+ CreateSwappedOutRenderViewForGuest(guest_site_instance));
+ // Attach a BrowserPluginGuestHelper to the swapped out guest RVH so that it
+ // can catch custom IDs.
+ RenderViewHostImpl* swapped_out_rvh = RenderViewHostImpl::FromID(
+ guest_site_instance->GetProcess()->GetID(),
+ guest->swapped_out_guest_routing_id());
+ DCHECK(swapped_out_rvh);
+ new BrowserPluginGuestHelper(guest, swapped_out_rvh);
nasko 2012/09/19 21:19:59 How is this helper object cleaned up?
Fady Samuel 2012/09/20 15:24:28 Done.
+ }
+
+ DCHECK(guest->swapped_out_guest_routing_id() != MSG_ROUTING_NONE);
+ new_params.source_routing_id = guest->swapped_out_guest_routing_id();
+
+ // Create a swapped out Render View for the guest in the embedder render
nasko 2012/09/19 21:19:59 nit: RenderView
Fady Samuel 2012/09/20 15:24:28 Done.
+ // process so that the embedder can reply to the guest from the source
nasko 2012/09/19 21:19:59 nit: process, so
Fady Samuel 2012/09/20 15:24:28 Done.
+ // field in the JS event object.
+ if (guest->swapped_out_embedder_routing_id() == MSG_ROUTING_NONE) {
+ guest->set_swapped_out_embedder_routing_id(
+ static_cast<WebContentsImpl*>(guest->web_contents())->
+ CreateSwappedOutRenderViewForGuest(
+ web_contents()->GetSiteInstance()));
+ // Attach a BrowserPluginEmbedderHelper to the swapped out embedder RVH
+ // so that it can catch custom IDs.
+ RenderViewHostImpl* swapped_out_rvh = RenderViewHostImpl::FromID(
+ web_contents()->GetRenderProcessHost()->GetID(),
+ guest->swapped_out_embedder_routing_id());
+ DCHECK(swapped_out_rvh);
+ new BrowserPluginEmbedderHelper(this, swapped_out_rvh);
nasko 2012/09/19 21:19:59 Same as above, how do we free those helpers?
Fady Samuel 2012/09/20 15:24:28 Done.
+ }
+
+ guest_web_contents->GetRenderViewHost()->Send(new ViewMsg_PostMessageEvent(
+ guest_web_contents->GetRenderViewHost()->GetRoutingID(), new_params));
+}
+
void BrowserPluginEmbedder::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {

Powered by Google App Engine
This is Rietveld 408576698