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/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "content/common/sandbox_util.h" | 10 #include "content/common/sandbox_util.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 return instance->module()->renderer_ppapi_host(); | 115 return instance->module()->renderer_ppapi_host(); |
116 } | 116 } |
117 | 117 |
118 scoped_ptr< ::ppapi::thunk::ResourceCreationAPI> | 118 scoped_ptr< ::ppapi::thunk::ResourceCreationAPI> |
119 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI( | 119 RendererPpapiHostImpl::CreateInProcessResourceCreationAPI( |
120 PepperPluginInstanceImpl* instance) { | 120 PepperPluginInstanceImpl* instance) { |
121 return scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>( | 121 return scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>( |
122 new PepperInProcessResourceCreation(this, instance)); | 122 new PepperInProcessResourceCreation(this, instance)); |
123 } | 123 } |
124 | 124 |
125 PepperBrowserConnection* | |
126 RendererPpapiHostImpl::GetBrowserConnection(PP_Instance instance) const { | |
127 PepperPluginInstanceImpl* instance_object = GetAndValidateInstance(instance); | |
128 if (!instance_object) | |
129 return NULL; | |
130 | |
131 // Since we're the embedder, we can make assumptions about the helper on | |
132 // the instance. | |
133 PepperHelperImpl* helper = instance_object->helper(); | |
134 if (!helper) | |
135 return NULL; | |
136 | |
137 return helper->pepper_browser_connection(); | |
138 } | |
139 | |
140 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetPluginInstanceImpl( | 125 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetPluginInstanceImpl( |
141 PP_Instance instance) const { | 126 PP_Instance instance) const { |
142 return GetAndValidateInstance(instance); | 127 return GetAndValidateInstance(instance); |
143 } | 128 } |
144 | 129 |
145 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { | 130 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { |
146 return ppapi_host_.get(); | 131 return ppapi_host_.get(); |
147 } | 132 } |
148 | 133 |
149 RenderView* RendererPpapiHostImpl::GetRenderViewForInstance( | 134 RenderView* RendererPpapiHostImpl::GetRenderViewForInstance( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 223 } |
239 | 224 |
240 bool RendererPpapiHostImpl::IsRunningInProcess() const { | 225 bool RendererPpapiHostImpl::IsRunningInProcess() const { |
241 return is_running_in_process_; | 226 return is_running_in_process_; |
242 } | 227 } |
243 | 228 |
244 void RendererPpapiHostImpl::CreateBrowserResourceHost( | 229 void RendererPpapiHostImpl::CreateBrowserResourceHost( |
245 PP_Instance instance, | 230 PP_Instance instance, |
246 const IPC::Message& nested_msg, | 231 const IPC::Message& nested_msg, |
247 const base::Callback<void(int)>& callback) const { | 232 const base::Callback<void(int)>& callback) const { |
248 PepperBrowserConnection* browser_connection = GetBrowserConnection(instance); | 233 RenderView* render_view = GetRenderViewForInstance(instance); |
249 if (browser_connection == NULL) { | 234 PepperBrowserConnection* browser_connection = |
| 235 PepperBrowserConnection::Get(render_view); |
| 236 if (!browser_connection) { |
250 callback.Run(0); | 237 callback.Run(0); |
251 } else { | 238 } else { |
252 browser_connection->SendBrowserCreate(module_->GetPluginChildId(), | 239 browser_connection->SendBrowserCreate(module_->GetPluginChildId(), |
253 instance, | 240 instance, |
254 nested_msg, | 241 nested_msg, |
255 callback); | 242 callback); |
256 } | 243 } |
257 } | 244 } |
258 | 245 |
259 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetAndValidateInstance( | 246 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetAndValidateInstance( |
260 PP_Instance pp_instance) const { | 247 PP_Instance pp_instance) const { |
261 PepperPluginInstanceImpl* instance = | 248 PepperPluginInstanceImpl* instance = |
262 HostGlobals::Get()->GetInstance(pp_instance); | 249 HostGlobals::Get()->GetInstance(pp_instance); |
263 if (!instance) | 250 if (!instance) |
264 return NULL; | 251 return NULL; |
265 if (!instance->IsValidInstanceOf(module_)) | 252 if (!instance->IsValidInstanceOf(module_)) |
266 return NULL; | 253 return NULL; |
267 return instance; | 254 return instance; |
268 } | 255 } |
269 | 256 |
270 } // namespace content | 257 } // namespace content |
OLD | NEW |