Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: content/renderer/pepper/pepper_plugin_delegate_impl.cc

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 339 }
340 340
341 WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePepperWebPlugin( 341 WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePepperWebPlugin(
342 const webkit::WebPluginInfo& webplugin_info, 342 const webkit::WebPluginInfo& webplugin_info,
343 const WebKit::WebPluginParams& params) { 343 const WebKit::WebPluginParams& params) {
344 bool pepper_plugin_was_registered = false; 344 bool pepper_plugin_was_registered = false;
345 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( 345 scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
346 CreatePepperPluginModule(webplugin_info, &pepper_plugin_was_registered)); 346 CreatePepperPluginModule(webplugin_info, &pepper_plugin_was_registered));
347 347
348 if (pepper_plugin_was_registered) { 348 if (pepper_plugin_was_registered) {
349 if (!pepper_module) 349 if (!pepper_module.get())
350 return NULL; 350 return NULL;
351 return new webkit::ppapi::WebPluginImpl( 351 return new webkit::ppapi::WebPluginImpl(
352 pepper_module.get(), params, AsWeakPtr()); 352 pepper_module.get(), params, AsWeakPtr());
353 } 353 }
354 354
355 return NULL; 355 return NULL;
356 } 356 }
357 357
358 scoped_refptr<webkit::ppapi::PluginModule> 358 scoped_refptr<webkit::ppapi::PluginModule>
359 PepperPluginDelegateImpl::CreatePepperPluginModule( 359 PepperPluginDelegateImpl::CreatePepperPluginModule(
360 const webkit::WebPluginInfo& webplugin_info, 360 const webkit::WebPluginInfo& webplugin_info,
361 bool* pepper_plugin_was_registered) { 361 bool* pepper_plugin_was_registered) {
362 *pepper_plugin_was_registered = true; 362 *pepper_plugin_was_registered = true;
363 363
364 // See if a module has already been loaded for this plugin. 364 // See if a module has already been loaded for this plugin.
365 base::FilePath path(webplugin_info.path); 365 base::FilePath path(webplugin_info.path);
366 scoped_refptr<webkit::ppapi::PluginModule> module = 366 scoped_refptr<webkit::ppapi::PluginModule> module =
367 PepperPluginRegistry::GetInstance()->GetLiveModule(path); 367 PepperPluginRegistry::GetInstance()->GetLiveModule(path);
368 if (module) { 368 if (module.get()) {
369 if (!module->GetEmbedderState()) { 369 if (!module->GetEmbedderState()) {
370 // If the module exists and no embedder state was associated with it, 370 // If the module exists and no embedder state was associated with it,
371 // then the module was one of the ones preloaded and is an in-process 371 // then the module was one of the ones preloaded and is an in-process
372 // plugin. We need to associate our host state with it. 372 // plugin. We need to associate our host state with it.
373 CreateHostForInProcessModule(render_view_, module, webplugin_info); 373 CreateHostForInProcessModule(render_view_, module.get(), webplugin_info);
374 } 374 }
375 return module; 375 return module;
376 } 376 }
377 377
378 // In-process plugins will have always been created up-front to avoid the 378 // In-process plugins will have always been created up-front to avoid the
379 // sandbox restrictions. So getting here implies it doesn't exist or should 379 // sandbox restrictions. So getting here implies it doesn't exist or should
380 // be out of process. 380 // be out of process.
381 const PepperPluginInfo* info = 381 const PepperPluginInfo* info =
382 PepperPluginRegistry::GetInstance()->GetInfoForPlugin(webplugin_info); 382 PepperPluginRegistry::GetInstance()->GetInfoForPlugin(webplugin_info);
383 if (!info) { 383 if (!info) {
(...skipping 17 matching lines...) Expand all
401 // Couldn't be initialized. 401 // Couldn't be initialized.
402 return scoped_refptr<webkit::ppapi::PluginModule>(); 402 return scoped_refptr<webkit::ppapi::PluginModule>();
403 } 403 }
404 404
405 // AddLiveModule must be called before any early returns since the 405 // AddLiveModule must be called before any early returns since the
406 // module's destructor will remove itself. 406 // module's destructor will remove itself.
407 module = new webkit::ppapi::PluginModule( 407 module = new webkit::ppapi::PluginModule(
408 info->name, path, 408 info->name, path,
409 PepperPluginRegistry::GetInstance(), 409 PepperPluginRegistry::GetInstance(),
410 permissions); 410 permissions);
411 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); 411 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module.get());
412 412
413 if (!CreateOutOfProcessModule(module, 413 if (!CreateOutOfProcessModule(module.get(),
414 path, 414 path,
415 permissions, 415 permissions,
416 channel_handle, 416 channel_handle,
417 peer_pid, 417 peer_pid,
418 plugin_child_id, 418 plugin_child_id,
419 false)) // is_external = false 419 false)) // is_external = false
420 return scoped_refptr<webkit::ppapi::PluginModule>(); 420 return scoped_refptr<webkit::ppapi::PluginModule>();
421 421
422 return module; 422 return module;
423 } 423 }
424 424
425 RendererPpapiHost* PepperPluginDelegateImpl::CreateExternalPluginModule( 425 RendererPpapiHost* PepperPluginDelegateImpl::CreateExternalPluginModule(
426 scoped_refptr<webkit::ppapi::PluginModule> module, 426 scoped_refptr<webkit::ppapi::PluginModule> module,
427 const base::FilePath& path, 427 const base::FilePath& path,
428 ppapi::PpapiPermissions permissions, 428 ppapi::PpapiPermissions permissions,
429 const IPC::ChannelHandle& channel_handle, 429 const IPC::ChannelHandle& channel_handle,
430 base::ProcessId peer_pid, 430 base::ProcessId peer_pid,
431 int plugin_child_id) { 431 int plugin_child_id) {
432 // We don't call PepperPluginRegistry::AddLiveModule, as this module is 432 // We don't call PepperPluginRegistry::AddLiveModule, as this module is
433 // managed externally. 433 // managed externally.
434 return CreateOutOfProcessModule(module, 434 return CreateOutOfProcessModule(module.get(),
435 path, 435 path,
436 permissions, 436 permissions,
437 channel_handle, 437 channel_handle,
438 peer_pid, 438 peer_pid,
439 plugin_child_id, 439 plugin_child_id,
440 true); // is_external = true 440 true); // is_external = true
441 } 441 }
442 442
443 scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker( 443 scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker(
444 webkit::ppapi::PluginModule* plugin_module) { 444 webkit::ppapi::PluginModule* plugin_module) {
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 webkit::ppapi::PPB_Broker_Impl* client) { 891 webkit::ppapi::PPB_Broker_Impl* client) {
892 DCHECK(client); 892 DCHECK(client);
893 893
894 webkit::ppapi::PluginModule* plugin_module = 894 webkit::ppapi::PluginModule* plugin_module =
895 webkit::ppapi::ResourceHelper::GetPluginModule(client); 895 webkit::ppapi::ResourceHelper::GetPluginModule(client);
896 if (!plugin_module) 896 if (!plugin_module)
897 return NULL; 897 return NULL;
898 898
899 scoped_refptr<PepperBrokerImpl> broker = 899 scoped_refptr<PepperBrokerImpl> broker =
900 static_cast<PepperBrokerImpl*>(plugin_module->GetBroker()); 900 static_cast<PepperBrokerImpl*>(plugin_module->GetBroker());
901 if (!broker) { 901 if (!broker.get()) {
902 broker = CreateBroker(plugin_module); 902 broker = CreateBroker(plugin_module);
903 if (!broker) 903 if (!broker.get())
904 return NULL; 904 return NULL;
905 } 905 }
906 906
907 int request_id = pending_permission_requests_.Add( 907 int request_id = pending_permission_requests_.Add(
908 new base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>(client->AsWeakPtr())); 908 new base::WeakPtr<webkit::ppapi::PPB_Broker_Impl>(client->AsWeakPtr()));
909 if (!render_view_->Send( 909 if (!render_view_->Send(
910 new ViewHostMsg_RequestPpapiBrokerPermission( 910 new ViewHostMsg_RequestPpapiBrokerPermission(
911 render_view_->routing_id(), 911 render_view_->routing_id(),
912 request_id, 912 request_id,
913 client->GetDocumentUrl(), 913 client->GetDocumentUrl(),
914 plugin_module->path()))) { 914 plugin_module->path()))) {
915 return NULL; 915 return NULL;
916 } 916 }
917 917
918 // Adds a reference, ensuring that the broker is not deleted when 918 // Adds a reference, ensuring that the broker is not deleted when
919 // |broker| goes out of scope. 919 // |broker| goes out of scope.
920 broker->AddPendingConnect(client); 920 broker->AddPendingConnect(client);
921 921
922 return broker; 922 return broker.get();
923 } 923 }
924 924
925 void PepperPluginDelegateImpl::OnPpapiBrokerPermissionResult( 925 void PepperPluginDelegateImpl::OnPpapiBrokerPermissionResult(
926 int request_id, 926 int request_id,
927 bool result) { 927 bool result) {
928 scoped_ptr<base::WeakPtr<webkit::ppapi::PPB_Broker_Impl> > client_ptr( 928 scoped_ptr<base::WeakPtr<webkit::ppapi::PPB_Broker_Impl> > client_ptr(
929 pending_permission_requests_.Lookup(request_id)); 929 pending_permission_requests_.Lookup(request_id));
930 DCHECK(client_ptr.get()); 930 DCHECK(client_ptr.get());
931 pending_permission_requests_.Remove(request_id); 931 pending_permission_requests_.Remove(request_id);
932 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl> client = *client_ptr; 932 base::WeakPtr<webkit::ppapi::PPB_Broker_Impl> client = *client_ptr;
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 should_close_source); 1686 should_close_source);
1687 } 1687 }
1688 1688
1689 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const { 1689 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const {
1690 RendererPpapiHostImpl* host = 1690 RendererPpapiHostImpl* host =
1691 RendererPpapiHostImpl::GetForPPInstance(instance); 1691 RendererPpapiHostImpl::GetForPPInstance(instance);
1692 return host && host->IsRunningInProcess(); 1692 return host && host->IsRunningInProcess();
1693 } 1693 }
1694 1694
1695 } // namespace content 1695 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_platform_context_3d_impl.cc ('k') | content/renderer/pepper/pepper_video_capture_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698