| 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 23 matching lines...) Expand all Loading... |
| 34 #include "content/public/common/referrer.h" | 34 #include "content/public/common/referrer.h" |
| 35 #include "content/public/renderer/content_renderer_client.h" | 35 #include "content/public/renderer/content_renderer_client.h" |
| 36 #include "content/renderer/browser_plugin/browser_plugin_constants.h" | 36 #include "content/renderer/browser_plugin/browser_plugin_constants.h" |
| 37 #include "content/renderer/browser_plugin/browser_plugin_registry.h" | 37 #include "content/renderer/browser_plugin/browser_plugin_registry.h" |
| 38 #include "content/renderer/gamepad_shared_memory_reader.h" | 38 #include "content/renderer/gamepad_shared_memory_reader.h" |
| 39 #include "content/renderer/media/audio_hardware.h" | 39 #include "content/renderer/media/audio_hardware.h" |
| 40 #include "content/renderer/media/media_stream_dispatcher.h" | 40 #include "content/renderer/media/media_stream_dispatcher.h" |
| 41 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" | 41 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" |
| 42 #include "content/renderer/p2p/p2p_transport_impl.h" | 42 #include "content/renderer/p2p/p2p_transport_impl.h" |
| 43 #include "content/renderer/p2p/socket_dispatcher.h" | 43 #include "content/renderer/p2p/socket_dispatcher.h" |
| 44 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" |
| 44 #include "content/renderer/pepper/pepper_broker_impl.h" | 45 #include "content/renderer/pepper/pepper_broker_impl.h" |
| 45 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h" | 46 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h" |
| 46 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" | 47 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" |
| 48 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" |
| 47 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h" | 49 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h" |
| 48 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" | 50 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" |
| 49 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h" | 51 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h" |
| 50 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h" | 52 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h" |
| 51 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h" | 53 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h" |
| 52 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" | 54 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" |
| 53 #include "content/renderer/render_thread_impl.h" | 55 #include "content/renderer/render_thread_impl.h" |
| 54 #include "content/renderer/render_view_impl.h" | 56 #include "content/renderer/render_view_impl.h" |
| 55 #include "content/renderer/render_widget_fullscreen_pepper.h" | 57 #include "content/renderer/render_widget_fullscreen_pepper.h" |
| 56 #include "content/renderer/renderer_clipboard_client.h" | 58 #include "content/renderer/renderer_clipboard_client.h" |
| 57 #include "content/renderer/renderer_restrict_dispatch_group.h" | 59 #include "content/renderer/renderer_restrict_dispatch_group.h" |
| 58 #include "content/renderer/webplugin_delegate_proxy.h" | 60 #include "content/renderer/webplugin_delegate_proxy.h" |
| 59 #include "googleurl/src/gurl.h" | 61 #include "googleurl/src/gurl.h" |
| 60 #include "ipc/ipc_channel_handle.h" | 62 #include "ipc/ipc_channel_handle.h" |
| 61 #include "media/video/capture/video_capture_proxy.h" | 63 #include "media/video/capture/video_capture_proxy.h" |
| 62 #include "ppapi/c/dev/pp_video_dev.h" | 64 #include "ppapi/c/dev/pp_video_dev.h" |
| 63 #include "ppapi/c/pp_errors.h" | 65 #include "ppapi/c/pp_errors.h" |
| 64 #include "ppapi/c/private/ppb_flash.h" | 66 #include "ppapi/c/private/ppb_flash.h" |
| 67 #include "ppapi/host/ppapi_host.h" |
| 65 #include "ppapi/proxy/host_dispatcher.h" | 68 #include "ppapi/proxy/host_dispatcher.h" |
| 66 #include "ppapi/proxy/pepper_file_messages.h" | 69 #include "ppapi/proxy/pepper_file_messages.h" |
| 67 #include "ppapi/proxy/ppapi_messages.h" | 70 #include "ppapi/proxy/ppapi_messages.h" |
| 68 #include "ppapi/shared_impl/file_path.h" | 71 #include "ppapi/shared_impl/file_path.h" |
| 69 #include "ppapi/shared_impl/platform_file.h" | 72 #include "ppapi/shared_impl/platform_file.h" |
| 70 #include "ppapi/shared_impl/ppapi_preferences.h" | 73 #include "ppapi/shared_impl/ppapi_preferences.h" |
| 71 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | 74 #include "ppapi/shared_impl/ppb_device_ref_shared.h" |
| 72 #include "ppapi/thunk/enter.h" | 75 #include "ppapi/thunk/enter.h" |
| 73 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h" | 76 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h" |
| 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 96 using WebKit::WebView; | 99 using WebKit::WebView; |
| 97 using WebKit::WebFrame; | 100 using WebKit::WebFrame; |
| 98 | 101 |
| 99 namespace content { | 102 namespace content { |
| 100 | 103 |
| 101 namespace { | 104 namespace { |
| 102 | 105 |
| 103 class HostDispatcherWrapper | 106 class HostDispatcherWrapper |
| 104 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { | 107 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { |
| 105 public: | 108 public: |
| 106 HostDispatcherWrapper() {} | 109 HostDispatcherWrapper(RenderViewImpl* rv) |
| 110 : render_view_(rv), |
| 111 host_factory_(rv) { |
| 112 } |
| 107 virtual ~HostDispatcherWrapper() {} | 113 virtual ~HostDispatcherWrapper() {} |
| 108 | 114 |
| 109 bool Init(const IPC::ChannelHandle& channel_handle, | 115 bool Init(const IPC::ChannelHandle& channel_handle, |
| 110 PP_Module pp_module, | 116 PP_Module pp_module, |
| 111 PP_GetInterface_Func local_get_interface, | 117 PP_GetInterface_Func local_get_interface, |
| 112 const ppapi::Preferences& preferences, | 118 const ppapi::Preferences& preferences, |
| 113 PepperHungPluginFilter* filter) { | 119 PepperHungPluginFilter* filter) { |
| 114 if (channel_handle.name.empty()) | 120 if (channel_handle.name.empty()) |
| 115 return false; | 121 return false; |
| 116 | 122 |
| 117 #if defined(OS_POSIX) | 123 #if defined(OS_POSIX) |
| 118 DCHECK_NE(-1, channel_handle.socket.fd); | 124 DCHECK_NE(-1, channel_handle.socket.fd); |
| 119 if (channel_handle.socket.fd == -1) | 125 if (channel_handle.socket.fd == -1) |
| 120 return false; | 126 return false; |
| 121 #endif | 127 #endif |
| 122 | 128 |
| 123 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); | 129 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); |
| 124 dispatcher_.reset(new ppapi::proxy::HostDispatcher( | 130 dispatcher_.reset(new ppapi::proxy::HostDispatcher( |
| 125 pp_module, local_get_interface, filter)); | 131 pp_module, local_get_interface, filter)); |
| 126 | 132 |
| 133 host_.reset(new ppapi::host::PpapiHost(dispatcher_.get(), &host_factory_)); |
| 134 dispatcher_->AddFilter(host_.get()); |
| 135 |
| 127 if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(), | 136 if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(), |
| 128 channel_handle, | 137 channel_handle, |
| 129 true, // Client. | 138 true, // Client. |
| 130 preferences)) { | 139 preferences)) { |
| 131 dispatcher_.reset(); | 140 dispatcher_.reset(); |
| 132 dispatcher_delegate_.reset(); | 141 dispatcher_delegate_.reset(); |
| 133 return false; | 142 return false; |
| 134 } | 143 } |
| 135 dispatcher_->channel()->SetRestrictDispatchChannelGroup( | 144 dispatcher_->channel()->SetRestrictDispatchChannelGroup( |
| 136 content::kRendererRestrictDispatchGroup_Pepper); | 145 content::kRendererRestrictDispatchGroup_Pepper); |
| 137 return true; | 146 return true; |
| 138 } | 147 } |
| 139 | 148 |
| 140 // OutOfProcessProxy implementation. | 149 // OutOfProcessProxy implementation. |
| 141 virtual const void* GetProxiedInterface(const char* name) { | 150 virtual const void* GetProxiedInterface(const char* name) { |
| 142 return dispatcher_->GetProxiedInterface(name); | 151 return dispatcher_->GetProxiedInterface(name); |
| 143 } | 152 } |
| 144 virtual void AddInstance(PP_Instance instance) { | 153 virtual void AddInstance(PP_Instance instance) { |
| 145 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); | 154 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); |
| 146 } | 155 } |
| 147 virtual void RemoveInstance(PP_Instance instance) { | 156 virtual void RemoveInstance(PP_Instance instance) { |
| 148 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); | 157 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); |
| 149 } | 158 } |
| 150 | 159 |
| 151 private: | 160 private: |
| 161 RenderViewImpl* render_view_; |
| 162 ContentRendererPepperHostFactory host_factory_; |
| 163 |
| 164 scoped_ptr<ppapi::host::PpapiHost> host_; |
| 165 |
| 152 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; | 166 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; |
| 153 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; | 167 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; |
| 154 }; | 168 }; |
| 155 | 169 |
| 156 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { | 170 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { |
| 157 public: | 171 public: |
| 158 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; | 172 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; |
| 159 explicit QuotaCallbackTranslator(const PluginCallback& cb) : callback_(cb) {} | 173 explicit QuotaCallbackTranslator(const PluginCallback& cb) : callback_(cb) {} |
| 160 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { | 174 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { |
| 161 callback_.Run(std::max(static_cast<int64>(0), quota - usage)); | 175 callback_.Run(std::max(static_cast<int64>(0), quota - usage)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 scoped_refptr<PepperHungPluginFilter> hung_filter( | 263 scoped_refptr<PepperHungPluginFilter> hung_filter( |
| 250 new PepperHungPluginFilter(path, render_view_->routing_id(), | 264 new PepperHungPluginFilter(path, render_view_->routing_id(), |
| 251 plugin_child_id)); | 265 plugin_child_id)); |
| 252 | 266 |
| 253 // Create a new HostDispatcher for the proxying, and hook it to a new | 267 // Create a new HostDispatcher for the proxying, and hook it to a new |
| 254 // PluginModule. Note that AddLiveModule must be called before any early | 268 // PluginModule. Note that AddLiveModule must be called before any early |
| 255 // returns since the module's destructor will remove itself. | 269 // returns since the module's destructor will remove itself. |
| 256 module = new webkit::ppapi::PluginModule(info->name, path, | 270 module = new webkit::ppapi::PluginModule(info->name, path, |
| 257 PepperPluginRegistry::GetInstance()); | 271 PepperPluginRegistry::GetInstance()); |
| 258 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); | 272 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); |
| 259 scoped_ptr<HostDispatcherWrapper> dispatcher(new HostDispatcherWrapper); | 273 scoped_ptr<HostDispatcherWrapper> dispatcher( |
| 274 new HostDispatcherWrapper(render_view_)); |
| 260 if (!dispatcher->Init( | 275 if (!dispatcher->Init( |
| 261 channel_handle, | 276 channel_handle, |
| 262 module->pp_module(), | 277 module->pp_module(), |
| 263 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | 278 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), |
| 264 GetPreferences(), | 279 GetPreferences(), |
| 265 hung_filter.get())) | 280 hung_filter.get())) |
| 266 return scoped_refptr<webkit::ppapi::PluginModule>(); | 281 return scoped_refptr<webkit::ppapi::PluginModule>(); |
| 267 module->InitAsProxied(dispatcher.release()); | 282 module->InitAsProxied(dispatcher.release()); |
| 268 return module; | 283 return module; |
| 269 } | 284 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 284 new PepperHungPluginFilter(path, | 299 new PepperHungPluginFilter(path, |
| 285 render_view_->routing_id(), | 300 render_view_->routing_id(), |
| 286 guest_process_id)); | 301 guest_process_id)); |
| 287 // Create a new HostDispatcher for the proxying, and hook it to a new | 302 // Create a new HostDispatcher for the proxying, and hook it to a new |
| 288 // PluginModule. | 303 // PluginModule. |
| 289 module = new webkit::ppapi::PluginModule(kBrowserPluginName, | 304 module = new webkit::ppapi::PluginModule(kBrowserPluginName, |
| 290 path, | 305 path, |
| 291 registry); | 306 registry); |
| 292 RenderThreadImpl::current()->browser_plugin_registry()->AddModule( | 307 RenderThreadImpl::current()->browser_plugin_registry()->AddModule( |
| 293 guest_process_id, module); | 308 guest_process_id, module); |
| 294 scoped_ptr<HostDispatcherWrapper> dispatcher(new HostDispatcherWrapper); | 309 scoped_ptr<HostDispatcherWrapper> dispatcher( |
| 310 new HostDispatcherWrapper(render_view_)); |
| 295 if (!dispatcher->Init( | 311 if (!dispatcher->Init( |
| 296 channel_handle, | 312 channel_handle, |
| 297 module->pp_module(), | 313 module->pp_module(), |
| 298 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | 314 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), |
| 299 GetPreferences(), | 315 GetPreferences(), |
| 300 hung_filter.get())) | 316 hung_filter.get())) |
| 301 return scoped_refptr<webkit::ppapi::PluginModule>(); | 317 return scoped_refptr<webkit::ppapi::PluginModule>(); |
| 302 module->InitAsProxied(dispatcher.release()); | 318 module->InitAsProxied(dispatcher.release()); |
| 303 return module; | 319 return module; |
| 304 } | 320 } |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 webkit::ppapi::PluginInstance* instance) { | 606 webkit::ppapi::PluginInstance* instance) { |
| 591 active_instances_.erase(instance); | 607 active_instances_.erase(instance); |
| 592 UnSetAndDeleteLockTargetAdapter(instance); | 608 UnSetAndDeleteLockTargetAdapter(instance); |
| 593 | 609 |
| 594 if (last_mouse_event_target_ == instance) | 610 if (last_mouse_event_target_ == instance) |
| 595 last_mouse_event_target_ = NULL; | 611 last_mouse_event_target_ = NULL; |
| 596 if (focused_plugin_ == instance) | 612 if (focused_plugin_ == instance) |
| 597 PluginFocusChanged(instance, false); | 613 PluginFocusChanged(instance, false); |
| 598 } | 614 } |
| 599 | 615 |
| 616 scoped_ptr< ::ppapi::thunk::ResourceCreationAPI> |
| 617 PepperPluginDelegateImpl::CreateResourceCreationAPI( |
| 618 webkit::ppapi::PluginInstance* instance) { |
| 619 return scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>( |
| 620 new PepperInProcessResourceCreation(render_view_, instance)); |
| 621 } |
| 622 |
| 600 SkBitmap* PepperPluginDelegateImpl::GetSadPluginBitmap() { | 623 SkBitmap* PepperPluginDelegateImpl::GetSadPluginBitmap() { |
| 601 return GetContentClient()->renderer()->GetSadPluginBitmap(); | 624 return GetContentClient()->renderer()->GetSadPluginBitmap(); |
| 602 } | 625 } |
| 603 | 626 |
| 604 WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePluginReplacement( | 627 WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePluginReplacement( |
| 605 const FilePath& file_path) { | 628 const FilePath& file_path) { |
| 606 return GetContentClient()->renderer()->CreatePluginReplacement( | 629 return GetContentClient()->renderer()->CreatePluginReplacement( |
| 607 render_view_, file_path); | 630 render_view_, file_path); |
| 608 } | 631 } |
| 609 | 632 |
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 else | 1728 else |
| 1706 return render_view_->mouse_lock_dispatcher(); | 1729 return render_view_->mouse_lock_dispatcher(); |
| 1707 } | 1730 } |
| 1708 | 1731 |
| 1709 webkit_glue::ClipboardClient* | 1732 webkit_glue::ClipboardClient* |
| 1710 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1733 PepperPluginDelegateImpl::CreateClipboardClient() const { |
| 1711 return new RendererClipboardClient; | 1734 return new RendererClipboardClient; |
| 1712 } | 1735 } |
| 1713 | 1736 |
| 1714 } // namespace content | 1737 } // namespace content |
| OLD | NEW |