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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 namespace content { | 101 namespace content { |
102 | 102 |
103 namespace { | 103 namespace { |
104 | 104 |
105 class HostDispatcherWrapper | 105 class HostDispatcherWrapper |
106 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { | 106 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { |
107 public: | 107 public: |
108 HostDispatcherWrapper(RenderViewImpl* rv, | 108 HostDispatcherWrapper(RenderViewImpl* rv, |
109 webkit::ppapi::PluginModule* module, | 109 webkit::ppapi::PluginModule* module, |
| 110 int plugin_child_id, |
110 const ppapi::PpapiPermissions& perms) | 111 const ppapi::PpapiPermissions& perms) |
111 : module_(module), | 112 : render_view_(rv), |
| 113 module_(module), |
| 114 plugin_child_id_(plugin_child_id), |
112 permissions_(perms) { | 115 permissions_(perms) { |
113 } | 116 } |
114 virtual ~HostDispatcherWrapper() {} | 117 virtual ~HostDispatcherWrapper() {} |
115 | 118 |
116 bool Init(const IPC::ChannelHandle& channel_handle, | 119 bool Init(const IPC::ChannelHandle& channel_handle, |
117 PP_GetInterface_Func local_get_interface, | 120 PP_GetInterface_Func local_get_interface, |
118 const ppapi::Preferences& preferences, | 121 const ppapi::Preferences& preferences, |
119 const ppapi::PpapiPermissions& permissions, | 122 const ppapi::PpapiPermissions& permissions, |
120 PepperHungPluginFilter* filter) { | 123 PepperHungPluginFilter* filter) { |
121 if (channel_handle.name.empty()) | 124 if (channel_handle.name.empty()) |
(...skipping 21 matching lines...) Expand all Loading... |
143 content::kRendererRestrictDispatchGroup_Pepper); | 146 content::kRendererRestrictDispatchGroup_Pepper); |
144 return true; | 147 return true; |
145 } | 148 } |
146 | 149 |
147 // OutOfProcessProxy implementation. | 150 // OutOfProcessProxy implementation. |
148 virtual const void* GetProxiedInterface(const char* name) { | 151 virtual const void* GetProxiedInterface(const char* name) { |
149 return dispatcher_->GetProxiedInterface(name); | 152 return dispatcher_->GetProxiedInterface(name); |
150 } | 153 } |
151 virtual void AddInstance(PP_Instance instance) { | 154 virtual void AddInstance(PP_Instance instance) { |
152 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); | 155 ppapi::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); |
| 156 |
| 157 render_view_->Send(new ViewHostMsg_DidCreateOutOfProcessPepperInstance( |
| 158 plugin_child_id_, |
| 159 instance, |
| 160 render_view_->routing_id())); |
153 } | 161 } |
154 virtual void RemoveInstance(PP_Instance instance) { | 162 virtual void RemoveInstance(PP_Instance instance) { |
155 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); | 163 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); |
| 164 |
| 165 render_view_->Send(new ViewHostMsg_DidDeleteOutOfProcessPepperInstance( |
| 166 plugin_child_id_, |
| 167 instance)); |
156 } | 168 } |
157 | 169 |
158 ppapi::proxy::HostDispatcher* dispatcher() { return dispatcher_.get(); } | 170 ppapi::proxy::HostDispatcher* dispatcher() { return dispatcher_.get(); } |
159 | 171 |
160 private: | 172 private: |
| 173 RenderViewImpl* render_view_; |
| 174 |
161 webkit::ppapi::PluginModule* module_; | 175 webkit::ppapi::PluginModule* module_; |
162 | 176 |
| 177 // 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 |
| 179 // in messages to the browser to disambiguate plugins. |
| 180 int plugin_child_id_; |
| 181 |
163 ppapi::PpapiPermissions permissions_; | 182 ppapi::PpapiPermissions permissions_; |
164 | 183 |
165 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; | 184 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; |
166 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; | 185 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; |
167 }; | 186 }; |
168 | 187 |
169 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { | 188 class QuotaCallbackTranslator : public QuotaDispatcher::Callback { |
170 public: | 189 public: |
171 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; | 190 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; |
172 explicit QuotaCallbackTranslator(const PluginCallback& cb) : callback_(cb) {} | 191 explicit QuotaCallbackTranslator(const PluginCallback& cb) : callback_(cb) {} |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 373 |
355 // Create a new HostDispatcher for the proxying, and hook it to a new | 374 // Create a new HostDispatcher for the proxying, and hook it to a new |
356 // PluginModule. Note that AddLiveModule must be called before any early | 375 // PluginModule. Note that AddLiveModule must be called before any early |
357 // returns since the module's destructor will remove itself. | 376 // returns since the module's destructor will remove itself. |
358 module = new webkit::ppapi::PluginModule( | 377 module = new webkit::ppapi::PluginModule( |
359 info->name, path, | 378 info->name, path, |
360 PepperPluginRegistry::GetInstance(), | 379 PepperPluginRegistry::GetInstance(), |
361 permissions); | 380 permissions); |
362 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); | 381 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); |
363 scoped_ptr<HostDispatcherWrapper> dispatcher( | 382 scoped_ptr<HostDispatcherWrapper> dispatcher( |
364 new HostDispatcherWrapper(render_view_, module, permissions)); | 383 new HostDispatcherWrapper(render_view_, module, plugin_child_id, |
| 384 permissions)); |
365 if (!dispatcher->Init( | 385 if (!dispatcher->Init( |
366 channel_handle, | 386 channel_handle, |
367 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | 387 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), |
368 GetPreferences(), | 388 GetPreferences(), |
369 permissions, | 389 permissions, |
370 hung_filter.get())) | 390 hung_filter.get())) |
371 return scoped_refptr<webkit::ppapi::PluginModule>(); | 391 return scoped_refptr<webkit::ppapi::PluginModule>(); |
372 | 392 |
373 RendererPpapiHostImpl* host_impl = | 393 RendererPpapiHostImpl* host_impl = |
374 content::RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( | 394 content::RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( |
(...skipping 24 matching lines...) Expand all Loading... |
399 guest_process_id)); | 419 guest_process_id)); |
400 // Create a new HostDispatcher for the proxying, and hook it to a new | 420 // Create a new HostDispatcher for the proxying, and hook it to a new |
401 // PluginModule. | 421 // PluginModule. |
402 module = new webkit::ppapi::PluginModule(kBrowserPluginName, | 422 module = new webkit::ppapi::PluginModule(kBrowserPluginName, |
403 path, | 423 path, |
404 registry, | 424 registry, |
405 permissions); | 425 permissions); |
406 RenderThreadImpl::current()->browser_plugin_registry()->AddModule( | 426 RenderThreadImpl::current()->browser_plugin_registry()->AddModule( |
407 guest_process_id, module); | 427 guest_process_id, module); |
408 scoped_ptr<HostDispatcherWrapper> dispatcher( | 428 scoped_ptr<HostDispatcherWrapper> dispatcher( |
409 new HostDispatcherWrapper(render_view_, module, permissions)); | 429 new HostDispatcherWrapper(render_view_, module, 0, permissions)); |
410 if (!dispatcher->Init( | 430 if (!dispatcher->Init( |
411 channel_handle, | 431 channel_handle, |
412 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), | 432 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), |
413 GetPreferences(), | 433 GetPreferences(), |
414 permissions, | 434 permissions, |
415 hung_filter.get())) | 435 hung_filter.get())) |
416 return scoped_refptr<webkit::ppapi::PluginModule>(); | 436 return scoped_refptr<webkit::ppapi::PluginModule>(); |
417 module->InitAsProxied(dispatcher.release()); | 437 module->InitAsProxied(dispatcher.release()); |
418 return module; | 438 return module; |
419 } | 439 } |
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 else | 1854 else |
1835 return render_view_->mouse_lock_dispatcher(); | 1855 return render_view_->mouse_lock_dispatcher(); |
1836 } | 1856 } |
1837 | 1857 |
1838 webkit_glue::ClipboardClient* | 1858 webkit_glue::ClipboardClient* |
1839 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1859 PepperPluginDelegateImpl::CreateClipboardClient() const { |
1840 return new RendererClipboardClient; | 1860 return new RendererClipboardClient; |
1841 } | 1861 } |
1842 | 1862 |
1843 } // namespace content | 1863 } // namespace content |
OLD | NEW |