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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 #include "webkit/plugins/ppapi/resource_helper.h" | 95 #include "webkit/plugins/ppapi/resource_helper.h" |
96 #include "webkit/plugins/webplugininfo.h" | 96 #include "webkit/plugins/webplugininfo.h" |
97 | 97 |
98 using WebKit::WebView; | 98 using WebKit::WebView; |
99 using WebKit::WebFrame; | 99 using WebKit::WebFrame; |
100 | 100 |
101 namespace content { | 101 namespace content { |
102 | 102 |
103 namespace { | 103 namespace { |
104 | 104 |
| 105 // This class wraps a dispatcher and has the same lifetime. A dispatcher has |
| 106 // the same lifetime as a plugin module, which is longer than any particular |
| 107 // RenderView or plugin instance. |
105 class HostDispatcherWrapper | 108 class HostDispatcherWrapper |
106 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { | 109 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { |
107 public: | 110 public: |
108 HostDispatcherWrapper(RenderViewImpl* rv, | 111 HostDispatcherWrapper(webkit::ppapi::PluginModule* module, |
109 webkit::ppapi::PluginModule* module, | |
110 int plugin_child_id, | 112 int plugin_child_id, |
111 const ppapi::PpapiPermissions& perms) | 113 const ppapi::PpapiPermissions& perms) |
112 : render_view_(rv), | 114 : module_(module), |
113 module_(module), | 115 /*TODO(brettw) bug 149850 put this back. |
114 plugin_child_id_(plugin_child_id), | 116 plugin_child_id_(plugin_child_id),*/ |
115 permissions_(perms) { | 117 permissions_(perms) { |
116 } | 118 } |
117 virtual ~HostDispatcherWrapper() {} | 119 virtual ~HostDispatcherWrapper() {} |
118 | 120 |
119 bool Init(const IPC::ChannelHandle& channel_handle, | 121 bool Init(const IPC::ChannelHandle& channel_handle, |
120 PP_GetInterface_Func local_get_interface, | 122 PP_GetInterface_Func local_get_interface, |
121 const ppapi::Preferences& preferences, | 123 const ppapi::Preferences& preferences, |
122 const ppapi::PpapiPermissions& permissions, | 124 const ppapi::PpapiPermissions& permissions, |
123 PepperHungPluginFilter* filter) { | 125 PepperHungPluginFilter* filter) { |
124 if (channel_handle.name.empty()) | 126 if (channel_handle.name.empty()) |
(...skipping 22 matching lines...) Expand all Loading... |
147 return true; | 149 return true; |
148 } | 150 } |
149 | 151 |
150 // OutOfProcessProxy implementation. | 152 // OutOfProcessProxy implementation. |
151 virtual const void* GetProxiedInterface(const char* name) { | 153 virtual const void* GetProxiedInterface(const char* name) { |
152 return dispatcher_->GetProxiedInterface(name); | 154 return dispatcher_->GetProxiedInterface(name); |
153 } | 155 } |
154 virtual void AddInstance(PP_Instance instance) { | 156 virtual void AddInstance(PP_Instance instance) { |
155 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); | 157 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); |
156 | 158 |
| 159 /* TODO(brettw) bug 149850 put this back with crash fix. |
157 render_view_->Send(new ViewHostMsg_DidCreateOutOfProcessPepperInstance( | 160 render_view_->Send(new ViewHostMsg_DidCreateOutOfProcessPepperInstance( |
158 plugin_child_id_, | 161 plugin_child_id_, |
159 instance, | 162 instance, |
160 render_view_->routing_id())); | 163 render_view_->routing_id())); |
| 164 */ |
161 } | 165 } |
162 virtual void RemoveInstance(PP_Instance instance) { | 166 virtual void RemoveInstance(PP_Instance instance) { |
163 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); | 167 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); |
164 | 168 |
| 169 /* TODO(brettw) bug 149850 put this back with crash fix. |
165 render_view_->Send(new ViewHostMsg_DidDeleteOutOfProcessPepperInstance( | 170 render_view_->Send(new ViewHostMsg_DidDeleteOutOfProcessPepperInstance( |
166 plugin_child_id_, | 171 plugin_child_id_, |
167 instance)); | 172 instance)); |
| 173 */ |
168 } | 174 } |
169 | 175 |
170 ppapi::proxy::HostDispatcher* dispatcher() { return dispatcher_.get(); } | 176 ppapi::proxy::HostDispatcher* dispatcher() { return dispatcher_.get(); } |
171 | 177 |
172 private: | 178 private: |
173 RenderViewImpl* render_view_; | |
174 | |
175 webkit::ppapi::PluginModule* module_; | 179 webkit::ppapi::PluginModule* module_; |
176 | 180 |
177 // ID that the browser process uses to idetify the child process for the | 181 // ID that the browser process uses to idetify the child process for the |
178 // plugin. This isn't directly useful from our process (the renderer) except | 182 // plugin. This isn't directly useful from our process (the renderer) except |
179 // in messages to the browser to disambiguate plugins. | 183 // in messages to the browser to disambiguate plugins. |
180 int plugin_child_id_; | 184 // TODO(brettw) bug 149850 put this back with crash fix. |
| 185 //int plugin_child_id_; |
181 | 186 |
182 ppapi::PpapiPermissions permissions_; | 187 ppapi::PpapiPermissions permissions_; |
183 | 188 |
184 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; | 189 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; |
185 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; | 190 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; |
186 }; | 191 }; |
187 | 192 |
188 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { | 193 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { |
189 public: | 194 public: |
190 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; | 195 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 378 |
374 // Create a new HostDispatcher for the proxying, and hook it to a new | 379 // Create a new HostDispatcher for the proxying, and hook it to a new |
375 // PluginModule. Note that AddLiveModule must be called before any early | 380 // PluginModule. Note that AddLiveModule must be called before any early |
376 // returns since the module's destructor will remove itself. | 381 // returns since the module's destructor will remove itself. |
377 module = new webkit::ppapi::PluginModule( | 382 module = new webkit::ppapi::PluginModule( |
378 info->name, path, | 383 info->name, path, |
379 PepperPluginRegistry::GetInstance(), | 384 PepperPluginRegistry::GetInstance(), |
380 permissions); | 385 permissions); |
381 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); | 386 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); |
382 scoped_ptr<HostDispatcherWrapper> dispatcher( | 387 scoped_ptr<HostDispatcherWrapper> dispatcher( |
383 new HostDispatcherWrapper(render_view_, module, plugin_child_id, | 388 new HostDispatcherWrapper(module, plugin_child_id, permissions)); |
384 permissions)); | |
385 if (!dispatcher->Init( | 389 if (!dispatcher->Init( |
386 channel_handle, | 390 channel_handle, |
387 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | 391 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), |
388 GetPreferences(), | 392 GetPreferences(), |
389 permissions, | 393 permissions, |
390 hung_filter.get())) | 394 hung_filter.get())) |
391 return scoped_refptr<webkit::ppapi::PluginModule>(); | 395 return scoped_refptr<webkit::ppapi::PluginModule>(); |
392 | 396 |
393 RendererPpapiHostImpl* host_impl = | 397 RendererPpapiHostImpl* host_impl = |
394 content::RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( | 398 content::RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( |
(...skipping 24 matching lines...) Expand all Loading... |
419 guest_process_id)); | 423 guest_process_id)); |
420 // Create a new HostDispatcher for the proxying, and hook it to a new | 424 // Create a new HostDispatcher for the proxying, and hook it to a new |
421 // PluginModule. | 425 // PluginModule. |
422 module = new webkit::ppapi::PluginModule(kBrowserPluginName, | 426 module = new webkit::ppapi::PluginModule(kBrowserPluginName, |
423 path, | 427 path, |
424 registry, | 428 registry, |
425 permissions); | 429 permissions); |
426 RenderThreadImpl::current()->browser_plugin_registry()->AddModule( | 430 RenderThreadImpl::current()->browser_plugin_registry()->AddModule( |
427 guest_process_id, module); | 431 guest_process_id, module); |
428 scoped_ptr<HostDispatcherWrapper> dispatcher( | 432 scoped_ptr<HostDispatcherWrapper> dispatcher( |
429 new HostDispatcherWrapper(render_view_, module, 0, permissions)); | 433 new HostDispatcherWrapper(module, 0, permissions)); |
430 if (!dispatcher->Init( | 434 if (!dispatcher->Init( |
431 channel_handle, | 435 channel_handle, |
432 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | 436 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), |
433 GetPreferences(), | 437 GetPreferences(), |
434 permissions, | 438 permissions, |
435 hung_filter.get())) | 439 hung_filter.get())) |
436 return scoped_refptr<webkit::ppapi::PluginModule>(); | 440 return scoped_refptr<webkit::ppapi::PluginModule>(); |
437 module->InitAsProxied(dispatcher.release()); | 441 module->InitAsProxied(dispatcher.release()); |
438 return module; | 442 return module; |
439 } | 443 } |
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 else | 1858 else |
1855 return render_view_->mouse_lock_dispatcher(); | 1859 return render_view_->mouse_lock_dispatcher(); |
1856 } | 1860 } |
1857 | 1861 |
1858 webkit_glue::ClipboardClient* | 1862 webkit_glue::ClipboardClient* |
1859 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1863 PepperPluginDelegateImpl::CreateClipboardClient() const { |
1860 return new RendererClipboardClient; | 1864 return new RendererClipboardClient; |
1861 } | 1865 } |
1862 | 1866 |
1863 } // namespace content | 1867 } // namespace content |
OLD | NEW |