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/renderer_ppapi_host_impl.h" | 5 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" | 9 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" |
10 #include "content/renderer/pepper/pepper_in_process_router.h" | 10 #include "content/renderer/pepper/pepper_in_process_router.h" |
11 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" | 11 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
12 #include "content/renderer/render_view_impl.h" | 12 #include "content/renderer/render_view_impl.h" |
13 #include "content/renderer/render_widget_fullscreen_pepper.h" | 13 #include "content/renderer/render_widget_fullscreen_pepper.h" |
14 #include "ppapi/proxy/host_dispatcher.h" | 14 #include "ppapi/proxy/host_dispatcher.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
16 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
17 #include "webkit/plugins/ppapi/fullscreen_container.h" | 17 #include "webkit/plugins/ppapi/fullscreen_container.h" |
18 #include "webkit/plugins/ppapi/host_globals.h" | 18 #include "webkit/plugins/ppapi/host_globals.h" |
19 #include "webkit/plugins/ppapi/plugin_module.h" | 19 #include "webkit/plugins/ppapi/plugin_module.h" |
20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
21 | 21 |
22 using webkit::ppapi::HostGlobals; | 22 using webkit::ppapi::HostGlobals; |
| 23 using webkit::ppapi::PluginDelegate; |
23 using webkit::ppapi::PluginInstance; | 24 using webkit::ppapi::PluginInstance; |
24 using webkit::ppapi::PluginModule; | 25 using webkit::ppapi::PluginModule; |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 | 28 |
28 // static | 29 // static |
29 CONTENT_EXPORT RendererPpapiHost* | 30 CONTENT_EXPORT RendererPpapiHost* |
30 RendererPpapiHost::CreateExternalPluginModule( | 31 RendererPpapiHost::CreateExternalPluginModule( |
31 scoped_refptr<PluginModule> plugin_module, | 32 scoped_refptr<PluginModule> plugin_module, |
32 PluginInstance* plugin_instance, | 33 PluginInstance* plugin_instance, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI( | 132 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI( |
132 PluginInstance* instance) { | 133 PluginInstance* instance) { |
133 return scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>( | 134 return scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>( |
134 new PepperInProcessResourceCreation(this, instance)); | 135 new PepperInProcessResourceCreation(this, instance)); |
135 } | 136 } |
136 | 137 |
137 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { | 138 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { |
138 return ppapi_host_.get(); | 139 return ppapi_host_.get(); |
139 } | 140 } |
140 | 141 |
141 RenderView* RendererPpapiHostImpl::GetRenderViewForInstance( | 142 PluginDelegate* RendererPpapiHostImpl::GetDelegateForInstance( |
142 PP_Instance instance) const { | 143 PP_Instance instance) const { |
143 PluginInstance* instance_object = GetAndValidateInstance(instance); | 144 PluginInstance* instance_object = GetAndValidateInstance(instance); |
144 if (!instance_object) | 145 if (!instance_object) |
145 return NULL; | 146 return NULL; |
146 | 147 |
| 148 return instance_object->delegate(); |
| 149 } |
| 150 |
| 151 RenderView* RendererPpapiHostImpl::GetRenderViewForInstance( |
| 152 PP_Instance instance) const { |
| 153 webkit::ppapi::PluginDelegate* delegate = GetDelegateForInstance(instance); |
| 154 if (!delegate) |
| 155 return NULL; |
| 156 |
147 // Since we're the embedder, we can make assumptions about the delegate on | 157 // Since we're the embedder, we can make assumptions about the delegate on |
148 // the instance and get back to our RenderView. | 158 // the instance and get back to our RenderView. |
149 return static_cast<PepperPluginDelegateImpl*>( | 159 return static_cast<PepperPluginDelegateImpl*>(delegate)->render_view(); |
150 instance_object->delegate())->render_view(); | |
151 } | 160 } |
152 | 161 |
153 bool RendererPpapiHostImpl::IsValidInstance( | 162 bool RendererPpapiHostImpl::IsValidInstance( |
154 PP_Instance instance) const { | 163 PP_Instance instance) const { |
155 return !!GetAndValidateInstance(instance); | 164 return !!GetAndValidateInstance(instance); |
156 } | 165 } |
157 | 166 |
158 webkit::ppapi::PluginInstance* RendererPpapiHostImpl::GetPluginInstance( | 167 webkit::ppapi::PluginInstance* RendererPpapiHostImpl::GetPluginInstance( |
159 PP_Instance instance) const { | 168 PP_Instance instance) const { |
160 return GetAndValidateInstance(instance); | 169 return GetAndValidateInstance(instance); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 PP_Instance pp_instance) const { | 237 PP_Instance pp_instance) const { |
229 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); | 238 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); |
230 if (!instance) | 239 if (!instance) |
231 return NULL; | 240 return NULL; |
232 if (instance->module() != module_) | 241 if (instance->module() != module_) |
233 return NULL; | 242 return NULL; |
234 return instance; | 243 return instance; |
235 } | 244 } |
236 | 245 |
237 } // namespace content | 246 } // namespace content |
OLD | NEW |