OLD | NEW |
---|---|
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.h" | 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 8 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
9 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 9 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 | 24 |
25 // static | 25 // static |
26 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; | 26 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; |
27 | 27 |
28 BrowserPluginEmbedder::BrowserPluginEmbedder( | 28 BrowserPluginEmbedder::BrowserPluginEmbedder( |
29 WebContentsImpl* web_contents, | 29 WebContentsImpl* web_contents, |
30 RenderViewHost* render_view_host) | 30 RenderViewHost* render_view_host) |
31 : WebContentsObserver(web_contents), | 31 : WebContentsObserver(web_contents), |
32 render_view_host_(render_view_host), | 32 render_view_host_(render_view_host), |
33 visible_(true), | 33 visible_(true), |
34 next_get_render_view_request_id_(0) { | 34 next_get_render_view_request_id_(0), |
35 instance_id_counter_(0) { | |
35 // Listen to visibility changes so that an embedder hides its guests | 36 // Listen to visibility changes so that an embedder hides its guests |
36 // as well. | 37 // as well. |
37 registrar_.Add(this, | 38 registrar_.Add(this, |
38 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 39 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
39 Source<WebContents>(web_contents)); | 40 Source<WebContents>(web_contents)); |
40 } | 41 } |
41 | 42 |
42 BrowserPluginEmbedder::~BrowserPluginEmbedder() { | 43 BrowserPluginEmbedder::~BrowserPluginEmbedder() { |
43 CleanUp(); | 44 CleanUp(); |
44 } | 45 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 // All allowed messages must have instance_id as their first parameter. | 205 // All allowed messages must have instance_id as their first parameter. |
205 PickleIterator iter(message); | 206 PickleIterator iter(message); |
206 bool success = iter.ReadInt(&instance_id); | 207 bool success = iter.ReadInt(&instance_id); |
207 DCHECK(success); | 208 DCHECK(success); |
208 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); | 209 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
209 if (guest && guest->OnMessageReceivedFromEmbedder(message)) | 210 if (guest && guest->OnMessageReceivedFromEmbedder(message)) |
210 return true; | 211 return true; |
211 } | 212 } |
212 bool handled = true; | 213 bool handled = true; |
213 IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedder, message) | 214 IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedder, message) |
215 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_AllocateInstanceIDRequest, | |
216 OnAllocateInstanceID) | |
214 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, | 217 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, |
215 OnCreateGuest) | 218 OnCreateGuest) |
216 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginAtPositionResponse, | 219 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginAtPositionResponse, |
217 OnPluginAtPositionResponse) | 220 OnPluginAtPositionResponse) |
218 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, | 221 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, |
219 OnPluginDestroyed) | 222 OnPluginDestroyed) |
220 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, | 223 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, |
221 OnSwapBuffersACK) | 224 OnSwapBuffersACK) |
222 IPC_MESSAGE_UNHANDLED(handled = false) | 225 IPC_MESSAGE_UNHANDLED(handled = false) |
223 IPC_END_MESSAGE_MAP() | 226 IPC_END_MESSAGE_MAP() |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 case BrowserPluginHostMsg_Stop::ID: | 290 case BrowserPluginHostMsg_Stop::ID: |
288 case BrowserPluginHostMsg_TerminateGuest::ID: | 291 case BrowserPluginHostMsg_TerminateGuest::ID: |
289 case BrowserPluginHostMsg_UpdateRect_ACK::ID: | 292 case BrowserPluginHostMsg_UpdateRect_ACK::ID: |
290 return true; | 293 return true; |
291 default: | 294 default: |
292 break; | 295 break; |
293 } | 296 } |
294 return false; | 297 return false; |
295 } | 298 } |
296 | 299 |
300 void BrowserPluginEmbedder::OnAllocateInstanceID(int request_id) { | |
301 int instance_id = ++instance_id_counter_; | |
302 render_view_host_->Send(new BrowserPluginMsg_AllocateInstanceIDResponse( | |
303 render_view_host_->GetRoutingID(), request_id, instance_id)); | |
304 } | |
305 | |
297 void BrowserPluginEmbedder::OnCreateGuest( | 306 void BrowserPluginEmbedder::OnCreateGuest( |
298 int instance_id, | 307 int instance_id, |
299 const BrowserPluginHostMsg_CreateGuest_Params& params) { | 308 const BrowserPluginHostMsg_CreateGuest_Params& params) { |
300 CreateGuest(instance_id, MSG_ROUTING_NONE, NULL, params); | 309 CreateGuest(instance_id, MSG_ROUTING_NONE, NULL, params); |
310 if (params.src.empty()) | |
Charlie Reis
2013/01/18 01:54:31
Nice. Can you update the comment in the .h file t
Fady Samuel
2013/01/18 02:23:10
Not really, I guess. window.open uses CreateGuest
| |
311 return; | |
312 BrowserPluginHostMsg_NavigateGuest navigate_msg( | |
313 render_view_host_->GetRoutingID(), instance_id, params.src); | |
314 GetGuestByInstanceID(instance_id)-> | |
315 OnMessageReceivedFromEmbedder(navigate_msg); | |
301 } | 316 } |
302 | 317 |
303 void BrowserPluginEmbedder::OnPluginAtPositionResponse( | 318 void BrowserPluginEmbedder::OnPluginAtPositionResponse( |
304 int instance_id, int request_id, const gfx::Point& position) { | 319 int instance_id, int request_id, const gfx::Point& position) { |
305 const std::map<int, WebContents::GetRenderViewHostCallback>::iterator | 320 const std::map<int, WebContents::GetRenderViewHostCallback>::iterator |
306 callback_iter = pending_get_render_view_callbacks_.find(request_id); | 321 callback_iter = pending_get_render_view_callbacks_.find(request_id); |
307 if (callback_iter == pending_get_render_view_callbacks_.end()) | 322 if (callback_iter == pending_get_render_view_callbacks_.end()) |
308 return; | 323 return; |
309 | 324 |
310 RenderViewHost* render_view_host; | 325 RenderViewHost* render_view_host; |
(...skipping 17 matching lines...) Expand all Loading... | |
328 uint32 sync_point) { | 343 uint32 sync_point) { |
329 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 344 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
330 ack_params.mailbox_name = mailbox_name; | 345 ack_params.mailbox_name = mailbox_name; |
331 ack_params.sync_point = sync_point; | 346 ack_params.sync_point = sync_point; |
332 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 347 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
333 gpu_host_id, | 348 gpu_host_id, |
334 ack_params); | 349 ack_params); |
335 } | 350 } |
336 | 351 |
337 } // namespace content | 352 } // namespace content |
OLD | NEW |