| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper_plugin_delegate_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "content/renderer/render_view.h" | 38 #include "content/renderer/render_view.h" |
| 39 #include "content/renderer/render_widget_fullscreen_pepper.h" | 39 #include "content/renderer/render_widget_fullscreen_pepper.h" |
| 40 #include "content/renderer/webplugin_delegate_proxy.h" | 40 #include "content/renderer/webplugin_delegate_proxy.h" |
| 41 #include "ipc/ipc_channel_handle.h" | 41 #include "ipc/ipc_channel_handle.h" |
| 42 #include "ppapi/c/dev/pp_video_dev.h" | 42 #include "ppapi/c/dev/pp_video_dev.h" |
| 43 #include "ppapi/c/pp_errors.h" | 43 #include "ppapi/c/pp_errors.h" |
| 44 #include "ppapi/c/private/ppb_flash.h" | 44 #include "ppapi/c/private/ppb_flash.h" |
| 45 #include "ppapi/c/private/ppb_flash_net_connector.h" | 45 #include "ppapi/c/private/ppb_flash_net_connector.h" |
| 46 #include "ppapi/proxy/host_dispatcher.h" | 46 #include "ppapi/proxy/host_dispatcher.h" |
| 47 #include "ppapi/proxy/ppapi_messages.h" | 47 #include "ppapi/proxy/ppapi_messages.h" |
| 48 #include "ppapi/shared_impl/ppapi_preferences.h" |
| 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" | 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" |
| 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" | 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" |
| 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 53 #include "ui/gfx/size.h" | 54 #include "ui/gfx/size.h" |
| 54 #include "ui/gfx/surface/transport_dib.h" | 55 #include "ui/gfx/surface/transport_dib.h" |
| 55 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 56 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 56 #include "webkit/glue/context_menu.h" | 57 #include "webkit/glue/context_menu.h" |
| 57 #include "webkit/plugins/npapi/webplugin.h" | 58 #include "webkit/plugins/npapi/webplugin.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 handle, socket_handle, length)); | 322 handle, socket_handle, length)); |
| 322 } | 323 } |
| 323 } | 324 } |
| 324 | 325 |
| 325 class DispatcherWrapper | 326 class DispatcherWrapper |
| 326 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { | 327 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { |
| 327 public: | 328 public: |
| 328 DispatcherWrapper() {} | 329 DispatcherWrapper() {} |
| 329 virtual ~DispatcherWrapper() {} | 330 virtual ~DispatcherWrapper() {} |
| 330 | 331 |
| 331 bool Init(base::ProcessHandle plugin_process_handle, | 332 bool Init(RenderView* render_view, |
| 333 base::ProcessHandle plugin_process_handle, |
| 332 const IPC::ChannelHandle& channel_handle, | 334 const IPC::ChannelHandle& channel_handle, |
| 333 PP_Module pp_module, | 335 PP_Module pp_module, |
| 334 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface); | 336 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface); |
| 335 | 337 |
| 336 // OutOfProcessProxy implementation. | 338 // OutOfProcessProxy implementation. |
| 337 virtual const void* GetProxiedInterface(const char* name) { | 339 virtual const void* GetProxiedInterface(const char* name) { |
| 338 return dispatcher_->GetProxiedInterface(name); | 340 return dispatcher_->GetProxiedInterface(name); |
| 339 } | 341 } |
| 340 virtual void AddInstance(PP_Instance instance) { | 342 virtual void AddInstance(PP_Instance instance) { |
| 341 pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); | 343 pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); |
| 342 } | 344 } |
| 343 virtual void RemoveInstance(PP_Instance instance) { | 345 virtual void RemoveInstance(PP_Instance instance) { |
| 344 pp::proxy::HostDispatcher::RemoveForInstance(instance); | 346 pp::proxy::HostDispatcher::RemoveForInstance(instance); |
| 345 } | 347 } |
| 346 | 348 |
| 347 private: | 349 private: |
| 348 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; | 350 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; |
| 349 }; | 351 }; |
| 350 | 352 |
| 351 } // namespace | 353 } // namespace |
| 352 | 354 |
| 353 bool DispatcherWrapper::Init( | 355 bool DispatcherWrapper::Init( |
| 356 RenderView* render_view, |
| 354 base::ProcessHandle plugin_process_handle, | 357 base::ProcessHandle plugin_process_handle, |
| 355 const IPC::ChannelHandle& channel_handle, | 358 const IPC::ChannelHandle& channel_handle, |
| 356 PP_Module pp_module, | 359 PP_Module pp_module, |
| 357 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { | 360 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { |
| 358 dispatcher_.reset(new pp::proxy::HostDispatcher( | 361 dispatcher_.reset(new pp::proxy::HostDispatcher( |
| 359 plugin_process_handle, pp_module, local_get_interface)); | 362 plugin_process_handle, pp_module, local_get_interface)); |
| 360 | 363 |
| 361 if (!dispatcher_->InitHostWithChannel(PepperPluginRegistry::GetInstance(), | 364 if (!dispatcher_->InitHostWithChannel( |
| 362 channel_handle, true)) { | 365 PepperPluginRegistry::GetInstance(), |
| 366 channel_handle, true, |
| 367 ppapi::Preferences(render_view->webkit_preferences()))) { |
| 363 dispatcher_.reset(); | 368 dispatcher_.reset(); |
| 364 return false; | 369 return false; |
| 365 } | 370 } |
| 366 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); | 371 dispatcher_->channel()->SetRestrictDispatchToSameChannel(true); |
| 367 return true; | 372 return true; |
| 368 } | 373 } |
| 369 | 374 |
| 370 BrokerDispatcherWrapper::BrokerDispatcherWrapper() { | 375 BrokerDispatcherWrapper::BrokerDispatcherWrapper() { |
| 371 } | 376 } |
| 372 | 377 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 606 } |
| 602 | 607 |
| 603 // Create a new HostDispatcher for the proxying, and hook it to a new | 608 // Create a new HostDispatcher for the proxying, and hook it to a new |
| 604 // PluginModule. Note that AddLiveModule must be called before any early | 609 // PluginModule. Note that AddLiveModule must be called before any early |
| 605 // returns since the module's destructor will remove itself. | 610 // returns since the module's destructor will remove itself. |
| 606 module = new webkit::ppapi::PluginModule(info->name, path, | 611 module = new webkit::ppapi::PluginModule(info->name, path, |
| 607 PepperPluginRegistry::GetInstance()); | 612 PepperPluginRegistry::GetInstance()); |
| 608 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); | 613 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); |
| 609 scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper); | 614 scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper); |
| 610 if (!dispatcher->Init( | 615 if (!dispatcher->Init( |
| 616 render_view_, |
| 611 plugin_process_handle, channel_handle, | 617 plugin_process_handle, channel_handle, |
| 612 module->pp_module(), | 618 module->pp_module(), |
| 613 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc())) | 619 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc())) |
| 614 return scoped_refptr<webkit::ppapi::PluginModule>(); | 620 return scoped_refptr<webkit::ppapi::PluginModule>(); |
| 615 module->InitAsProxied(dispatcher.release()); | 621 module->InitAsProxied(dispatcher.release()); |
| 616 return module; | 622 return module; |
| 617 } | 623 } |
| 618 | 624 |
| 619 scoped_refptr<PpapiBrokerImpl> PepperPluginDelegateImpl::CreatePpapiBroker( | 625 scoped_refptr<PpapiBrokerImpl> PepperPluginDelegateImpl::CreatePpapiBroker( |
| 620 webkit::ppapi::PluginModule* plugin_module) { | 626 webkit::ppapi::PluginModule* plugin_module) { |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 new ViewHostMsg_AllocateSharedMemoryBuffer(size, &handle))) { | 1312 new ViewHostMsg_AllocateSharedMemoryBuffer(size, &handle))) { |
| 1307 DLOG(WARNING) << "Browser allocation request message failed"; | 1313 DLOG(WARNING) << "Browser allocation request message failed"; |
| 1308 return NULL; | 1314 return NULL; |
| 1309 } | 1315 } |
| 1310 if (!base::SharedMemory::IsHandleValid(handle)) { | 1316 if (!base::SharedMemory::IsHandleValid(handle)) { |
| 1311 DLOG(WARNING) << "Browser failed to allocate shared memory"; | 1317 DLOG(WARNING) << "Browser failed to allocate shared memory"; |
| 1312 return NULL; | 1318 return NULL; |
| 1313 } | 1319 } |
| 1314 return new base::SharedMemory(handle, false); | 1320 return new base::SharedMemory(handle, false); |
| 1315 } | 1321 } |
| 1322 |
| 1323 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { |
| 1324 return ppapi::Preferences(render_view_->webkit_preferences()); |
| 1325 } |
| OLD | NEW |