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/renderer/pepper/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 // Out of process: have the browser start the plugin process for us. | 376 // Out of process: have the browser start the plugin process for us. |
377 IPC::ChannelHandle channel_handle; | 377 IPC::ChannelHandle channel_handle; |
378 int plugin_child_id = 0; | 378 int plugin_child_id = 0; |
379 render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin( | 379 render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin( |
380 path, &channel_handle, &plugin_child_id)); | 380 path, &channel_handle, &plugin_child_id)); |
381 if (channel_handle.name.empty()) { | 381 if (channel_handle.name.empty()) { |
382 // Couldn't be initialized. | 382 // Couldn't be initialized. |
383 return scoped_refptr<webkit::ppapi::PluginModule>(); | 383 return scoped_refptr<webkit::ppapi::PluginModule>(); |
384 } | 384 } |
385 | 385 |
386 scoped_refptr<PepperHungPluginFilter> hung_filter( | 386 // AddLiveModule must be called before any early returns since the |
387 new PepperHungPluginFilter(path, render_view_->routing_id(), | 387 // module's destructor will remove itself. |
388 plugin_child_id)); | |
389 | |
390 // Create a new HostDispatcher for the proxying, and hook it to a new | |
391 // PluginModule. Note that AddLiveModule must be called before any early | |
392 // returns since the module's destructor will remove itself. | |
393 module = new webkit::ppapi::PluginModule( | 388 module = new webkit::ppapi::PluginModule( |
394 info->name, path, | 389 info->name, path, |
395 PepperPluginRegistry::GetInstance(), | 390 PepperPluginRegistry::GetInstance(), |
396 permissions); | 391 permissions); |
397 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); | 392 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); |
398 scoped_ptr<HostDispatcherWrapper> dispatcher( | 393 |
399 new HostDispatcherWrapper(module, plugin_child_id, permissions)); | 394 if (!CreateOutOfProcessModule( |
400 if (!dispatcher->Init( | 395 module, path, permissions, channel_handle, plugin_child_id)) { |
401 channel_handle, | |
402 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | |
403 GetPreferences(), | |
404 permissions, | |
405 hung_filter.get())) | |
406 return scoped_refptr<webkit::ppapi::PluginModule>(); | 396 return scoped_refptr<webkit::ppapi::PluginModule>(); |
| 397 } |
| 398 return module; |
| 399 } |
407 | 400 |
408 RendererPpapiHostImpl* host_impl = | 401 RendererPpapiHost* PepperPluginDelegateImpl::CreateExternalPluginModule( |
409 content::RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( | 402 scoped_refptr<webkit::ppapi::PluginModule> module, |
410 module, dispatcher->dispatcher(), permissions); | 403 const FilePath& path, |
411 render_view_->PpapiPluginCreated(host_impl); | 404 ppapi::PpapiPermissions permissions, |
412 | 405 const IPC::ChannelHandle& channel_handle, |
413 module->InitAsProxied(dispatcher.release()); | 406 int plugin_child_id) { |
414 return module; | 407 // We don't call PepperPluginRegistry::AddLiveModule, as this module is |
| 408 // managed externally. |
| 409 return CreateOutOfProcessModule( |
| 410 module, path, permissions, channel_handle, plugin_child_id); |
415 } | 411 } |
416 | 412 |
417 scoped_refptr<webkit::ppapi::PluginModule> | 413 scoped_refptr<webkit::ppapi::PluginModule> |
418 PepperPluginDelegateImpl::CreateBrowserPluginModule( | 414 PepperPluginDelegateImpl::CreateBrowserPluginModule( |
419 const IPC::ChannelHandle& channel_handle, | 415 const IPC::ChannelHandle& channel_handle, |
420 int guest_process_id) { | 416 int guest_process_id) { |
421 content::old::BrowserPluginRegistry* registry = | 417 content::old::BrowserPluginRegistry* registry = |
422 RenderThreadImpl::current()->browser_plugin_registry(); | 418 RenderThreadImpl::current()->browser_plugin_registry(); |
423 scoped_refptr<webkit::ppapi::PluginModule> module = | 419 scoped_refptr<webkit::ppapi::PluginModule> module = |
424 registry->GetModule(guest_process_id); | 420 registry->GetModule(guest_process_id); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 request_id, | 469 request_id, |
474 broker_path); | 470 broker_path); |
475 if (!render_view_->Send(msg)) { | 471 if (!render_view_->Send(msg)) { |
476 pending_connect_broker_.Remove(request_id); | 472 pending_connect_broker_.Remove(request_id); |
477 return scoped_refptr<PepperBrokerImpl>(); | 473 return scoped_refptr<PepperBrokerImpl>(); |
478 } | 474 } |
479 | 475 |
480 return broker; | 476 return broker; |
481 } | 477 } |
482 | 478 |
| 479 RendererPpapiHost* PepperPluginDelegateImpl::CreateOutOfProcessModule( |
| 480 webkit::ppapi::PluginModule* module, |
| 481 const FilePath& path, |
| 482 ppapi::PpapiPermissions permissions, |
| 483 const IPC::ChannelHandle& channel_handle, |
| 484 int plugin_child_id) { |
| 485 scoped_refptr<PepperHungPluginFilter> hung_filter( |
| 486 new PepperHungPluginFilter(path, |
| 487 render_view_->routing_id(), |
| 488 plugin_child_id)); |
| 489 scoped_ptr<HostDispatcherWrapper> dispatcher( |
| 490 new HostDispatcherWrapper(module, plugin_child_id, permissions)); |
| 491 if (!dispatcher->Init( |
| 492 channel_handle, |
| 493 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), |
| 494 GetPreferences(), |
| 495 permissions, |
| 496 hung_filter.get())) |
| 497 return NULL; |
| 498 |
| 499 RendererPpapiHostImpl* host_impl = |
| 500 content::RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( |
| 501 module, dispatcher->dispatcher(), permissions); |
| 502 render_view_->PpapiPluginCreated(host_impl); |
| 503 |
| 504 module->InitAsProxied(dispatcher.release()); |
| 505 return host_impl; |
| 506 } |
| 507 |
483 void PepperPluginDelegateImpl::OnMenuAction(int request_id, unsigned action) { | 508 void PepperPluginDelegateImpl::OnMenuAction(int request_id, unsigned action) { |
484 // Just save the action. | 509 // Just save the action. |
485 DCHECK(!has_saved_context_menu_action_); | 510 DCHECK(!has_saved_context_menu_action_); |
486 has_saved_context_menu_action_ = true; | 511 has_saved_context_menu_action_ = true; |
487 saved_context_menu_action_ = action; | 512 saved_context_menu_action_ = action; |
488 } | 513 } |
489 | 514 |
490 void PepperPluginDelegateImpl::OnMenuClosed(int request_id) { | 515 void PepperPluginDelegateImpl::OnMenuClosed(int request_id) { |
491 PendingContextMenuMap::iterator found = | 516 PendingContextMenuMap::iterator found = |
492 pending_context_menus_.find(request_id); | 517 pending_context_menus_.find(request_id); |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 else | 1885 else |
1861 return render_view_->mouse_lock_dispatcher(); | 1886 return render_view_->mouse_lock_dispatcher(); |
1862 } | 1887 } |
1863 | 1888 |
1864 webkit_glue::ClipboardClient* | 1889 webkit_glue::ClipboardClient* |
1865 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1890 PepperPluginDelegateImpl::CreateClipboardClient() const { |
1866 return new RendererClipboardClient; | 1891 return new RendererClipboardClient; |
1867 } | 1892 } |
1868 | 1893 |
1869 } // namespace content | 1894 } // namespace content |
OLD | NEW |