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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 234 } |
235 | 235 |
236 std::string RendererPpapiHostImpl::GetPluginName() const { | 236 std::string RendererPpapiHostImpl::GetPluginName() const { |
237 return module_->name(); | 237 return module_->name(); |
238 } | 238 } |
239 | 239 |
240 void RendererPpapiHostImpl::SetToExternalPluginHost() { | 240 void RendererPpapiHostImpl::SetToExternalPluginHost() { |
241 is_external_plugin_host_ = true; | 241 is_external_plugin_host_ = true; |
242 } | 242 } |
243 | 243 |
244 void RendererPpapiHostImpl::CreateBrowserResourceHosts( | 244 int32_t RendererPpapiHostImpl::CreateBrowserResourceHosts( |
245 PP_Instance instance, | 245 PP_Instance instance, |
246 const std::vector<IPC::Message>& nested_msgs, | 246 const std::vector<IPC::Message>& nested_msgs, |
247 const base::Callback<void(const std::vector<int>&)>& callback) const { | 247 const PendingResourceCallback& callback) const { |
248 RenderFrame* render_frame = GetRenderFrameForInstance(instance); | 248 RenderFrame* render_frame = GetRenderFrameForInstance(instance); |
249 PepperBrowserConnection* browser_connection = | 249 PepperBrowserConnection* browser_connection = |
250 PepperBrowserConnection::Get(render_frame); | 250 PepperBrowserConnection::Get(render_frame); |
251 if (!browser_connection) { | 251 if (!browser_connection) { |
| 252 ppapi::proxy::CompletedBrowserResourceHosts empty; |
252 base::MessageLoop::current()->PostTask( | 253 base::MessageLoop::current()->PostTask( |
253 FROM_HERE, | 254 FROM_HERE, base::Bind(callback, empty)); |
254 base::Bind(callback, std::vector<int>(nested_msgs.size(), 0))); | 255 return -1; |
255 } else { | 256 } else { |
256 browser_connection->SendBrowserCreate( | 257 return browser_connection->SendBrowserCreate( |
257 module_->GetPluginChildId(), instance, nested_msgs, callback); | 258 module_->GetPluginChildId(), instance, nested_msgs, callback); |
258 } | 259 } |
259 } | 260 } |
260 | 261 |
261 GURL RendererPpapiHostImpl::GetDocumentURL(PP_Instance instance) const { | 262 GURL RendererPpapiHostImpl::GetDocumentURL(PP_Instance instance) const { |
262 PepperPluginInstanceImpl* instance_object = GetAndValidateInstance(instance); | 263 PepperPluginInstanceImpl* instance_object = GetAndValidateInstance(instance); |
263 if (!instance_object) | 264 if (!instance_object) |
264 return GURL(); | 265 return GURL(); |
265 | 266 |
266 return instance_object->container()->element().document().url(); | 267 return instance_object->container()->element().document().url(); |
267 } | 268 } |
268 | 269 |
269 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetAndValidateInstance( | 270 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetAndValidateInstance( |
270 PP_Instance pp_instance) const { | 271 PP_Instance pp_instance) const { |
271 PepperPluginInstanceImpl* instance = | 272 PepperPluginInstanceImpl* instance = |
272 HostGlobals::Get()->GetInstance(pp_instance); | 273 HostGlobals::Get()->GetInstance(pp_instance); |
273 if (!instance) | 274 if (!instance) |
274 return NULL; | 275 return NULL; |
275 if (!instance->IsValidInstanceOf(module_)) | 276 if (!instance->IsValidInstanceOf(module_)) |
276 return NULL; | 277 return NULL; |
277 return instance; | 278 return instance; |
278 } | 279 } |
279 | 280 |
280 } // namespace content | 281 } // namespace content |
OLD | NEW |