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

Side by Side 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: Verified to work with nasko@'s disabled frame tree updates 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/browser_plugin/browser_plugin_embedder_helper.h" 5 #include "content/browser/browser_plugin/browser_plugin_embedder_helper.h"
6 6
7 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 7 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
8 #include "content/browser/browser_plugin/browser_plugin_guest.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h" 9 #include "content/browser/renderer_host/render_view_host_impl.h"
10 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/common/browser_plugin_messages.h" 11 #include "content/common/browser_plugin_messages.h"
10 #include "content/common/view_messages.h" 12 #include "content/common/view_messages.h"
11 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/render_widget_host_view.h" 15 #include "content/public/browser/render_widget_host_view.h"
14 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 BrowserPluginEmbedderHelper::BrowserPluginEmbedderHelper( 20 BrowserPluginEmbedderHelper::BrowserPluginEmbedderHelper(
19 BrowserPluginEmbedder* embedder, 21 BrowserPluginEmbedder* embedder,
20 RenderViewHost* render_view_host) 22 RenderViewHost* render_view_host)
21 : RenderViewHostObserver(render_view_host), 23 : RenderViewHostObserver(render_view_host),
22 embedder_(embedder) { 24 embedder_(embedder) {
23 } 25 }
24 26
25 BrowserPluginEmbedderHelper::~BrowserPluginEmbedderHelper() { 27 BrowserPluginEmbedderHelper::~BrowserPluginEmbedderHelper() {
26 } 28 }
27 29
28 bool BrowserPluginEmbedderHelper::Send(IPC::Message* message) { 30 bool BrowserPluginEmbedderHelper::Send(IPC::Message* message) {
29 return RenderViewHostObserver::Send(message); 31 return RenderViewHostObserver::Send(message);
30 } 32 }
31 33
32 bool BrowserPluginEmbedderHelper::OnMessageReceived( 34 bool BrowserPluginEmbedderHelper::OnMessageReceived(
33 const IPC::Message& message) { 35 const IPC::Message& message) {
34 bool handled = true; 36 bool handled = true;
37 if (static_cast<content::RenderViewHostImpl*>(render_view_host())->
38 is_swapped_out()) {
39 IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedderHelper, message)
40 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteMessageEvent,
41 OnRouteMessageEvent)
42 IPC_MESSAGE_UNHANDLED(handled = false)
43 IPC_END_MESSAGE_MAP()
44 return handled;
45 }
35 IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedderHelper, message) 46 IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedderHelper, message)
36 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, 47 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest,
37 OnCreateGuest); 48 OnCreateGuest);
38 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, 49 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest,
39 OnNavigateGuest); 50 OnNavigateGuest);
40 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) 51 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
41 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK); 52 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK);
42 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus); 53 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus);
43 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent, 54 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent,
44 OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message), 55 OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message),
45 &handled)) 56 &handled))
46 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, 57 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed,
47 OnPluginDestroyed); 58 OnPluginDestroyed);
48 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Go, OnGo) 59 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Go, OnGo)
49 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Stop, OnStop) 60 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Stop, OnStop)
50 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload) 61 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload)
51 IPC_MESSAGE_UNHANDLED(handled = false) 62 IPC_MESSAGE_UNHANDLED(handled = false)
52 IPC_END_MESSAGE_MAP() 63 IPC_END_MESSAGE_MAP()
64
53 return handled; 65 return handled;
54 } 66 }
55 67
56 void BrowserPluginEmbedderHelper::OnResizeGuest( 68 void BrowserPluginEmbedderHelper::OnResizeGuest(
57 int instance_id, 69 int instance_id,
58 const BrowserPluginHostMsg_ResizeGuest_Params& params) { 70 const BrowserPluginHostMsg_ResizeGuest_Params& params) {
59 embedder_->ResizeGuest(render_view_host(), instance_id, params); 71 embedder_->ResizeGuest(render_view_host(), instance_id, params);
60 } 72 }
61 73
62 void BrowserPluginEmbedderHelper::OnHandleInputEvent( 74 void BrowserPluginEmbedderHelper::OnHandleInputEvent(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 141 }
130 142
131 void BrowserPluginEmbedderHelper::OnSetFocus(int instance_id, bool focused) { 143 void BrowserPluginEmbedderHelper::OnSetFocus(int instance_id, bool focused) {
132 embedder_->SetFocus(instance_id, focused); 144 embedder_->SetFocus(instance_id, focused);
133 } 145 }
134 146
135 void BrowserPluginEmbedderHelper::OnPluginDestroyed(int instance_id) { 147 void BrowserPluginEmbedderHelper::OnPluginDestroyed(int instance_id) {
136 embedder_->PluginDestroyed(instance_id); 148 embedder_->PluginDestroyed(instance_id);
137 } 149 }
138 150
151 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.
152 const ViewMsg_PostMessage_Params& params) {
153 // This helper's RVH corresponds to a swapped out RenderView living in
154 // the embedder's render process. If this RVH's WebContents has a
155 // BrowserPluginGuest, then we know this is actually a RVH for the
156 // guest for the purpose of catching ViewHostMsg_RouteMessageEvent and
157 // routing it to the guest WebContents.
158 // This code path is executed when the embedder tries to send a message
159 // back through event.source.postMessage within a 'message' event
160 // listener.
161 WebContentsImpl* guest_web_contents = static_cast<WebContentsImpl*>(
162 render_view_host()->GetDelegate());
163 if (!guest_web_contents->GetBrowserPluginGuest())
164 return;
165 embedder_->RouteMessageEvent(
166 guest_web_contents->GetBrowserPluginGuest()->instance_id(),
167 params.data,
168 params.source_frame_id,
169 params.target_origin,
170 params.target_frame_id);
171 }
172
139 void BrowserPluginEmbedderHelper::OnGo(int instance_id, int relative_index) { 173 void BrowserPluginEmbedderHelper::OnGo(int instance_id, int relative_index) {
140 embedder_->Go(instance_id, relative_index); 174 embedder_->Go(instance_id, relative_index);
141 } 175 }
142 176
143 void BrowserPluginEmbedderHelper::OnStop(int instance_id) { 177 void BrowserPluginEmbedderHelper::OnStop(int instance_id) {
144 embedder_->Stop(instance_id); 178 embedder_->Stop(instance_id);
145 } 179 }
146 180
147 void BrowserPluginEmbedderHelper::OnReload(int instance_id) { 181 void BrowserPluginEmbedderHelper::OnReload(int instance_id) {
148 embedder_->Reload(instance_id); 182 embedder_->Reload(instance_id);
149 } 183 }
150 184
151 } // namespace content 185 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698