Chromium Code Reviews| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 namespace { | 101 namespace { |
| 102 | 102 |
| 103 // This class wraps a dispatcher and has the same lifetime. A dispatcher has | 103 // This class wraps a dispatcher and has the same lifetime. A dispatcher has |
| 104 // the same lifetime as a plugin module, which is longer than any particular | 104 // the same lifetime as a plugin module, which is longer than any particular |
| 105 // RenderView or plugin instance. | 105 // RenderView or plugin instance. |
| 106 class HostDispatcherWrapper | 106 class HostDispatcherWrapper |
| 107 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { | 107 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { |
| 108 public: | 108 public: |
| 109 HostDispatcherWrapper(webkit::ppapi::PluginModule* module, | 109 HostDispatcherWrapper(webkit::ppapi::PluginModule* module, |
| 110 int plugin_child_id, | 110 int plugin_child_id, |
| 111 const ppapi::PpapiPermissions& perms) | 111 const ppapi::PpapiPermissions& perms, |
| 112 bool is_external) | |
| 112 : module_(module), | 113 : module_(module), |
| 113 plugin_child_id_(plugin_child_id), | 114 plugin_child_id_(plugin_child_id), |
| 114 permissions_(perms) { | 115 permissions_(perms), |
| 116 is_external_(is_external) { | |
| 115 } | 117 } |
| 116 virtual ~HostDispatcherWrapper() {} | 118 virtual ~HostDispatcherWrapper() {} |
| 117 | 119 |
| 118 bool Init(const IPC::ChannelHandle& channel_handle, | 120 bool Init(const IPC::ChannelHandle& channel_handle, |
| 119 PP_GetInterface_Func local_get_interface, | 121 PP_GetInterface_Func local_get_interface, |
| 120 const ppapi::Preferences& preferences, | 122 const ppapi::Preferences& preferences, |
| 121 const ppapi::PpapiPermissions& permissions, | |
| 122 PepperHungPluginFilter* filter) { | 123 PepperHungPluginFilter* filter) { |
| 123 if (channel_handle.name.empty()) | 124 if (channel_handle.name.empty()) |
| 124 return false; | 125 return false; |
| 125 | 126 |
| 126 #if defined(OS_POSIX) | 127 #if defined(OS_POSIX) |
| 127 DCHECK_NE(-1, channel_handle.socket.fd); | 128 DCHECK_NE(-1, channel_handle.socket.fd); |
| 128 if (channel_handle.socket.fd == -1) | 129 if (channel_handle.socket.fd == -1) |
| 129 return false; | 130 return false; |
| 130 #endif | 131 #endif |
| 131 | 132 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 157 RendererPpapiHostImpl::GetForPPInstance(instance); | 158 RendererPpapiHostImpl::GetForPPInstance(instance); |
| 158 // TODO(brettw) remove this null check when the old-style pepper-based | 159 // TODO(brettw) remove this null check when the old-style pepper-based |
| 159 // browser tag is removed from this file. Getting this notification should | 160 // browser tag is removed from this file. Getting this notification should |
| 160 // always give us an instance we can find in the map otherwise, but that | 161 // always give us an instance we can find in the map otherwise, but that |
| 161 // isn't true for browser tag support. | 162 // isn't true for browser tag support. |
| 162 if (host) { | 163 if (host) { |
| 163 RenderView* render_view = host->GetRenderViewForInstance(instance); | 164 RenderView* render_view = host->GetRenderViewForInstance(instance); |
| 164 render_view->Send(new ViewHostMsg_DidCreateOutOfProcessPepperInstance( | 165 render_view->Send(new ViewHostMsg_DidCreateOutOfProcessPepperInstance( |
| 165 plugin_child_id_, | 166 plugin_child_id_, |
| 166 instance, | 167 instance, |
| 167 render_view->GetRoutingID())); | 168 render_view->GetRoutingID(), |
| 169 is_external_)); | |
| 168 } | 170 } |
| 169 } | 171 } |
| 170 virtual void RemoveInstance(PP_Instance instance) { | 172 virtual void RemoveInstance(PP_Instance instance) { |
| 171 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); | 173 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); |
| 172 | 174 |
| 173 RendererPpapiHostImpl* host = | 175 RendererPpapiHostImpl* host = |
| 174 RendererPpapiHostImpl::GetForPPInstance(instance); | 176 RendererPpapiHostImpl::GetForPPInstance(instance); |
| 175 // TODO(brettw) remove null check as described in AddInstance. | 177 // TODO(brettw) remove null check as described in AddInstance. |
| 176 if (host) { | 178 if (host) { |
| 177 RenderView* render_view = host->GetRenderViewForInstance(instance); | 179 RenderView* render_view = host->GetRenderViewForInstance(instance); |
| 178 render_view->Send(new ViewHostMsg_DidDeleteOutOfProcessPepperInstance( | 180 render_view->Send(new ViewHostMsg_DidDeleteOutOfProcessPepperInstance( |
| 179 plugin_child_id_, | 181 plugin_child_id_, |
| 180 instance)); | 182 instance, |
| 183 is_external_)); | |
| 181 } | 184 } |
| 182 } | 185 } |
| 183 | 186 |
| 184 ppapi::proxy::HostDispatcher* dispatcher() { return dispatcher_.get(); } | 187 ppapi::proxy::HostDispatcher* dispatcher() { return dispatcher_.get(); } |
| 185 | 188 |
| 186 private: | 189 private: |
| 187 webkit::ppapi::PluginModule* module_; | 190 webkit::ppapi::PluginModule* module_; |
| 188 | 191 |
| 189 // ID that the browser process uses to idetify the child process for the | 192 // ID that the browser process uses to idetify the child process for the |
| 190 // plugin. This isn't directly useful from our process (the renderer) except | 193 // plugin. This isn't directly useful from our process (the renderer) except |
| 191 // in messages to the browser to disambiguate plugins. | 194 // in messages to the browser to disambiguate plugins. |
| 192 int plugin_child_id_; | 195 int plugin_child_id_; |
| 193 | 196 |
| 194 ppapi::PpapiPermissions permissions_; | 197 ppapi::PpapiPermissions permissions_; |
| 198 bool is_external_; | |
| 195 | 199 |
| 196 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; | 200 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; |
| 197 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; | 201 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; |
| 198 }; | 202 }; |
| 199 | 203 |
| 200 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { | 204 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { |
| 201 public: | 205 public: |
| 202 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; | 206 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; |
| 203 explicit QuotaCallbackTranslator(const PluginCallback& cb) : callback_(cb) {} | 207 explicit QuotaCallbackTranslator(const PluginCallback& cb) : callback_(cb) {} |
| 204 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { | 208 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 } | 390 } |
| 387 | 391 |
| 388 // AddLiveModule must be called before any early returns since the | 392 // AddLiveModule must be called before any early returns since the |
| 389 // module's destructor will remove itself. | 393 // module's destructor will remove itself. |
| 390 module = new webkit::ppapi::PluginModule( | 394 module = new webkit::ppapi::PluginModule( |
| 391 info->name, path, | 395 info->name, path, |
| 392 PepperPluginRegistry::GetInstance(), | 396 PepperPluginRegistry::GetInstance(), |
| 393 permissions); | 397 permissions); |
| 394 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); | 398 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); |
| 395 | 399 |
| 396 if (!CreateOutOfProcessModule( | 400 if (!CreateOutOfProcessModule(module, |
| 397 module, path, permissions, channel_handle, plugin_child_id)) { | 401 path, |
| 402 permissions, | |
| 403 channel_handle, | |
| 404 plugin_child_id, | |
| 405 false)) // is_external = false | |
| 398 return scoped_refptr<webkit::ppapi::PluginModule>(); | 406 return scoped_refptr<webkit::ppapi::PluginModule>(); |
| 399 } | 407 |
| 400 return module; | 408 return module; |
| 401 } | 409 } |
| 402 | 410 |
| 403 RendererPpapiHost* PepperPluginDelegateImpl::CreateExternalPluginModule( | 411 RendererPpapiHost* PepperPluginDelegateImpl::CreateExternalPluginModule( |
| 404 scoped_refptr<webkit::ppapi::PluginModule> module, | 412 scoped_refptr<webkit::ppapi::PluginModule> module, |
| 405 const FilePath& path, | 413 const FilePath& path, |
| 406 ppapi::PpapiPermissions permissions, | 414 ppapi::PpapiPermissions permissions, |
| 407 const IPC::ChannelHandle& channel_handle, | 415 const IPC::ChannelHandle& channel_handle, |
| 408 int plugin_child_id) { | 416 int plugin_child_id) { |
| 409 // We don't call PepperPluginRegistry::AddLiveModule, as this module is | 417 // We don't call PepperPluginRegistry::AddLiveModule, as this module is |
| 410 // managed externally. | 418 // managed externally. |
| 411 // TODO(bbudge) pass plugin_child_id when PpapiPluginProcessHost receives | 419 return CreateOutOfProcessModule(module, |
| 412 // a message notifying it that the external plugin process has been created. | 420 path, |
| 413 return CreateOutOfProcessModule( | 421 permissions, |
| 414 module, path, permissions, channel_handle, 0); | 422 channel_handle, |
| 423 plugin_child_id, | |
| 424 true); // is_external = true | |
| 415 } | 425 } |
| 416 | 426 |
| 417 scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker( | 427 scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker( |
| 418 webkit::ppapi::PluginModule* plugin_module) { | 428 webkit::ppapi::PluginModule* plugin_module) { |
| 419 DCHECK(plugin_module); | 429 DCHECK(plugin_module); |
| 420 DCHECK(!plugin_module->GetBroker()); | 430 DCHECK(!plugin_module->GetBroker()); |
| 421 | 431 |
| 422 // The broker path is the same as the plugin. | 432 // The broker path is the same as the plugin. |
| 423 const FilePath& broker_path = plugin_module->path(); | 433 const FilePath& broker_path = plugin_module->path(); |
| 424 | 434 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 439 } | 449 } |
| 440 | 450 |
| 441 return broker; | 451 return broker; |
| 442 } | 452 } |
| 443 | 453 |
| 444 RendererPpapiHost* PepperPluginDelegateImpl::CreateOutOfProcessModule( | 454 RendererPpapiHost* PepperPluginDelegateImpl::CreateOutOfProcessModule( |
| 445 webkit::ppapi::PluginModule* module, | 455 webkit::ppapi::PluginModule* module, |
| 446 const FilePath& path, | 456 const FilePath& path, |
| 447 ppapi::PpapiPermissions permissions, | 457 ppapi::PpapiPermissions permissions, |
| 448 const IPC::ChannelHandle& channel_handle, | 458 const IPC::ChannelHandle& channel_handle, |
| 449 int plugin_child_id) { | 459 int plugin_child_id, |
| 460 bool is_external) { | |
| 450 scoped_refptr<PepperHungPluginFilter> hung_filter( | 461 scoped_refptr<PepperHungPluginFilter> hung_filter( |
| 451 new PepperHungPluginFilter(path, | 462 new PepperHungPluginFilter(path, |
| 452 render_view_->routing_id(), | 463 render_view_->routing_id(), |
| 453 plugin_child_id)); | 464 plugin_child_id)); |
| 454 scoped_ptr<HostDispatcherWrapper> dispatcher( | 465 scoped_ptr<HostDispatcherWrapper> dispatcher( |
| 455 new HostDispatcherWrapper(module, plugin_child_id, permissions)); | 466 new HostDispatcherWrapper(module, |
| 467 plugin_child_id, | |
| 468 permissions, | |
| 469 is_external)); | |
| 456 if (!dispatcher->Init( | 470 if (!dispatcher->Init( |
| 457 channel_handle, | 471 channel_handle, |
| 458 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | 472 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), |
| 459 GetPreferences(), | 473 GetPreferences(), |
| 460 permissions, | |
|
bbudge
2012/10/31 23:05:14
Removed unused parameter. It's passed in the ctor.
| |
| 461 hung_filter.get())) | 474 hung_filter.get())) |
| 462 return NULL; | 475 return NULL; |
| 463 | 476 |
| 464 RendererPpapiHostImpl* host_impl = | 477 RendererPpapiHostImpl* host_impl = |
| 465 RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( | 478 RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( |
| 466 module, dispatcher->dispatcher(), permissions); | 479 module, dispatcher->dispatcher(), permissions); |
| 467 render_view_->PpapiPluginCreated(host_impl); | 480 render_view_->PpapiPluginCreated(host_impl); |
| 468 | 481 |
| 469 module->InitAsProxied(dispatcher.release()); | 482 module->InitAsProxied(dispatcher.release()); |
| 470 return host_impl; | 483 return host_impl; |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1863 return render_view_->mouse_lock_dispatcher(); | 1876 return render_view_->mouse_lock_dispatcher(); |
| 1864 } | 1877 } |
| 1865 } | 1878 } |
| 1866 | 1879 |
| 1867 webkit_glue::ClipboardClient* | 1880 webkit_glue::ClipboardClient* |
| 1868 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1881 PepperPluginDelegateImpl::CreateClipboardClient() const { |
| 1869 return new RendererClipboardClient; | 1882 return new RendererClipboardClient; |
| 1870 } | 1883 } |
| 1871 | 1884 |
| 1872 } // namespace content | 1885 } // namespace content |
| OLD | NEW |