| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 close_file_callback_(close_file_callback) { | 264 close_file_callback_(close_file_callback) { |
| 265 } | 265 } |
| 266 | 266 |
| 267 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} | 267 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} |
| 268 | 268 |
| 269 virtual void DidSucceed() OVERRIDE { | 269 virtual void DidSucceed() OVERRIDE { |
| 270 NOTREACHED(); | 270 NOTREACHED(); |
| 271 } | 271 } |
| 272 virtual void DidReadMetadata( | 272 virtual void DidReadMetadata( |
| 273 const base::PlatformFileInfo& file_info, | 273 const base::PlatformFileInfo& file_info, |
| 274 const FilePath& platform_path) OVERRIDE { | 274 const base::FilePath& platform_path) OVERRIDE { |
| 275 NOTREACHED(); | 275 NOTREACHED(); |
| 276 } | 276 } |
| 277 virtual void DidCreateSnapshotFile( | 277 virtual void DidCreateSnapshotFile( |
| 278 const base::PlatformFileInfo& file_info, | 278 const base::PlatformFileInfo& file_info, |
| 279 const base::FilePath& platform_path) OVERRIDE { | 279 const base::FilePath& platform_path) OVERRIDE { |
| 280 NOTREACHED(); | 280 NOTREACHED(); |
| 281 } | 281 } |
| 282 virtual void DidReadDirectory( | 282 virtual void DidReadDirectory( |
| 283 const std::vector<base::FileUtilProxy::Entry>& entries, | 283 const std::vector<base::FileUtilProxy::Entry>& entries, |
| 284 bool has_more) OVERRIDE { | 284 bool has_more) OVERRIDE { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 return NULL; | 370 return NULL; |
| 371 } | 371 } |
| 372 | 372 |
| 373 scoped_refptr<webkit::ppapi::PluginModule> | 373 scoped_refptr<webkit::ppapi::PluginModule> |
| 374 PepperPluginDelegateImpl::CreatePepperPluginModule( | 374 PepperPluginDelegateImpl::CreatePepperPluginModule( |
| 375 const webkit::WebPluginInfo& webplugin_info, | 375 const webkit::WebPluginInfo& webplugin_info, |
| 376 bool* pepper_plugin_was_registered) { | 376 bool* pepper_plugin_was_registered) { |
| 377 *pepper_plugin_was_registered = true; | 377 *pepper_plugin_was_registered = true; |
| 378 | 378 |
| 379 // See if a module has already been loaded for this plugin. | 379 // See if a module has already been loaded for this plugin. |
| 380 FilePath path(webplugin_info.path); | 380 base::FilePath path(webplugin_info.path); |
| 381 scoped_refptr<webkit::ppapi::PluginModule> module = | 381 scoped_refptr<webkit::ppapi::PluginModule> module = |
| 382 PepperPluginRegistry::GetInstance()->GetLiveModule(path); | 382 PepperPluginRegistry::GetInstance()->GetLiveModule(path); |
| 383 if (module) { | 383 if (module) { |
| 384 if (!module->GetEmbedderState()) { | 384 if (!module->GetEmbedderState()) { |
| 385 // If the module exists and no embedder state was associated with it, | 385 // If the module exists and no embedder state was associated with it, |
| 386 // then the module was one of the ones preloaded and is an in-process | 386 // then the module was one of the ones preloaded and is an in-process |
| 387 // plugin. We need to associate our host state with it. | 387 // plugin. We need to associate our host state with it. |
| 388 CreateHostForInProcessModule(render_view_, module, webplugin_info); | 388 CreateHostForInProcessModule(render_view_, module, webplugin_info); |
| 389 } | 389 } |
| 390 return module; | 390 return module; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 peer_pid, | 432 peer_pid, |
| 433 plugin_child_id, | 433 plugin_child_id, |
| 434 false)) // is_external = false | 434 false)) // is_external = false |
| 435 return scoped_refptr<webkit::ppapi::PluginModule>(); | 435 return scoped_refptr<webkit::ppapi::PluginModule>(); |
| 436 | 436 |
| 437 return module; | 437 return module; |
| 438 } | 438 } |
| 439 | 439 |
| 440 RendererPpapiHost* PepperPluginDelegateImpl::CreateExternalPluginModule( | 440 RendererPpapiHost* PepperPluginDelegateImpl::CreateExternalPluginModule( |
| 441 scoped_refptr<webkit::ppapi::PluginModule> module, | 441 scoped_refptr<webkit::ppapi::PluginModule> module, |
| 442 const FilePath& path, | 442 const base::FilePath& path, |
| 443 ppapi::PpapiPermissions permissions, | 443 ppapi::PpapiPermissions permissions, |
| 444 const IPC::ChannelHandle& channel_handle, | 444 const IPC::ChannelHandle& channel_handle, |
| 445 base::ProcessId peer_pid, | 445 base::ProcessId peer_pid, |
| 446 int plugin_child_id) { | 446 int plugin_child_id) { |
| 447 // We don't call PepperPluginRegistry::AddLiveModule, as this module is | 447 // We don't call PepperPluginRegistry::AddLiveModule, as this module is |
| 448 // managed externally. | 448 // managed externally. |
| 449 return CreateOutOfProcessModule(module, | 449 return CreateOutOfProcessModule(module, |
| 450 path, | 450 path, |
| 451 permissions, | 451 permissions, |
| 452 channel_handle, | 452 channel_handle, |
| 453 peer_pid, | 453 peer_pid, |
| 454 plugin_child_id, | 454 plugin_child_id, |
| 455 true); // is_external = true | 455 true); // is_external = true |
| 456 } | 456 } |
| 457 | 457 |
| 458 scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker( | 458 scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker( |
| 459 webkit::ppapi::PluginModule* plugin_module) { | 459 webkit::ppapi::PluginModule* plugin_module) { |
| 460 DCHECK(plugin_module); | 460 DCHECK(plugin_module); |
| 461 DCHECK(!plugin_module->GetBroker()); | 461 DCHECK(!plugin_module->GetBroker()); |
| 462 | 462 |
| 463 // The broker path is the same as the plugin. | 463 // The broker path is the same as the plugin. |
| 464 const FilePath& broker_path = plugin_module->path(); | 464 const base::FilePath& broker_path = plugin_module->path(); |
| 465 | 465 |
| 466 scoped_refptr<PepperBrokerImpl> broker = | 466 scoped_refptr<PepperBrokerImpl> broker = |
| 467 new PepperBrokerImpl(plugin_module, this); | 467 new PepperBrokerImpl(plugin_module, this); |
| 468 | 468 |
| 469 int request_id = | 469 int request_id = |
| 470 pending_connect_broker_.Add(new scoped_refptr<PepperBrokerImpl>(broker)); | 470 pending_connect_broker_.Add(new scoped_refptr<PepperBrokerImpl>(broker)); |
| 471 | 471 |
| 472 // Have the browser start the broker process for us. | 472 // Have the browser start the broker process for us. |
| 473 IPC::Message* msg = | 473 IPC::Message* msg = |
| 474 new ViewHostMsg_OpenChannelToPpapiBroker(render_view_->routing_id(), | 474 new ViewHostMsg_OpenChannelToPpapiBroker(render_view_->routing_id(), |
| 475 request_id, | 475 request_id, |
| 476 broker_path); | 476 broker_path); |
| 477 if (!render_view_->Send(msg)) { | 477 if (!render_view_->Send(msg)) { |
| 478 pending_connect_broker_.Remove(request_id); | 478 pending_connect_broker_.Remove(request_id); |
| 479 return scoped_refptr<PepperBrokerImpl>(); | 479 return scoped_refptr<PepperBrokerImpl>(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 return broker; | 482 return broker; |
| 483 } | 483 } |
| 484 | 484 |
| 485 RendererPpapiHost* PepperPluginDelegateImpl::CreateOutOfProcessModule( | 485 RendererPpapiHost* PepperPluginDelegateImpl::CreateOutOfProcessModule( |
| 486 webkit::ppapi::PluginModule* module, | 486 webkit::ppapi::PluginModule* module, |
| 487 const FilePath& path, | 487 const base::FilePath& path, |
| 488 ppapi::PpapiPermissions permissions, | 488 ppapi::PpapiPermissions permissions, |
| 489 const IPC::ChannelHandle& channel_handle, | 489 const IPC::ChannelHandle& channel_handle, |
| 490 base::ProcessId peer_pid, | 490 base::ProcessId peer_pid, |
| 491 int plugin_child_id, | 491 int plugin_child_id, |
| 492 bool is_external) { | 492 bool is_external) { |
| 493 scoped_refptr<PepperHungPluginFilter> hung_filter( | 493 scoped_refptr<PepperHungPluginFilter> hung_filter( |
| 494 new PepperHungPluginFilter(path, | 494 new PepperHungPluginFilter(path, |
| 495 render_view_->routing_id(), | 495 render_view_->routing_id(), |
| 496 plugin_child_id)); | 496 plugin_child_id)); |
| 497 scoped_ptr<HostDispatcherWrapper> dispatcher( | 497 scoped_ptr<HostDispatcherWrapper> dispatcher( |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 RendererPpapiHostImpl* host_impl = static_cast<RendererPpapiHostImpl*>( | 796 RendererPpapiHostImpl* host_impl = static_cast<RendererPpapiHostImpl*>( |
| 797 instance->module()->GetEmbedderState()); | 797 instance->module()->GetEmbedderState()); |
| 798 return host_impl->CreateInProcessResourceCreationAPI(instance); | 798 return host_impl->CreateInProcessResourceCreationAPI(instance); |
| 799 } | 799 } |
| 800 | 800 |
| 801 SkBitmap* PepperPluginDelegateImpl::GetSadPluginBitmap() { | 801 SkBitmap* PepperPluginDelegateImpl::GetSadPluginBitmap() { |
| 802 return GetContentClient()->renderer()->GetSadPluginBitmap(); | 802 return GetContentClient()->renderer()->GetSadPluginBitmap(); |
| 803 } | 803 } |
| 804 | 804 |
| 805 WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePluginReplacement( | 805 WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePluginReplacement( |
| 806 const FilePath& file_path) { | 806 const base::FilePath& file_path) { |
| 807 return GetContentClient()->renderer()->CreatePluginReplacement( | 807 return GetContentClient()->renderer()->CreatePluginReplacement( |
| 808 render_view_, file_path); | 808 render_view_, file_path); |
| 809 } | 809 } |
| 810 | 810 |
| 811 webkit::ppapi::PluginDelegate::PlatformImage2D* | 811 webkit::ppapi::PluginDelegate::PlatformImage2D* |
| 812 PepperPluginDelegateImpl::CreateImage2D(int width, int height) { | 812 PepperPluginDelegateImpl::CreateImage2D(int width, int height) { |
| 813 return PepperPlatformImage2DImpl::Create(width, height); | 813 return PepperPlatformImage2DImpl::Create(width, height); |
| 814 } | 814 } |
| 815 | 815 |
| 816 webkit::ppapi::PluginDelegate::PlatformGraphics2D* | 816 webkit::ppapi::PluginDelegate::PlatformGraphics2D* |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 webkit::ppapi::ResourceHelper::GetPluginModule(client); | 951 webkit::ppapi::ResourceHelper::GetPluginModule(client); |
| 952 if (!plugin_module) | 952 if (!plugin_module) |
| 953 return; | 953 return; |
| 954 | 954 |
| 955 PepperBrokerImpl* broker = | 955 PepperBrokerImpl* broker = |
| 956 static_cast<PepperBrokerImpl*>(plugin_module->GetBroker()); | 956 static_cast<PepperBrokerImpl*>(plugin_module->GetBroker()); |
| 957 broker->OnBrokerPermissionResult(client, result); | 957 broker->OnBrokerPermissionResult(client, result); |
| 958 } | 958 } |
| 959 | 959 |
| 960 bool PepperPluginDelegateImpl::AsyncOpenFile( | 960 bool PepperPluginDelegateImpl::AsyncOpenFile( |
| 961 const FilePath& path, | 961 const base::FilePath& path, |
| 962 int flags, | 962 int flags, |
| 963 const AsyncOpenFileCallback& callback) { | 963 const AsyncOpenFileCallback& callback) { |
| 964 int message_id = pending_async_open_files_.Add( | 964 int message_id = pending_async_open_files_.Add( |
| 965 new AsyncOpenFileCallback(callback)); | 965 new AsyncOpenFileCallback(callback)); |
| 966 IPC::Message* msg = new ViewHostMsg_AsyncOpenFile( | 966 IPC::Message* msg = new ViewHostMsg_AsyncOpenFile( |
| 967 render_view_->routing_id(), path, flags, message_id); | 967 render_view_->routing_id(), path, flags, message_id); |
| 968 return render_view_->Send(msg); | 968 return render_view_->Send(msg); |
| 969 } | 969 } |
| 970 | 970 |
| 971 void PepperPluginDelegateImpl::OnAsyncFileOpened( | 971 void PepperPluginDelegateImpl::OnAsyncFileOpened( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 | 1110 |
| 1111 FileSystemDispatcher* file_system_dispatcher = | 1111 FileSystemDispatcher* file_system_dispatcher = |
| 1112 ChildThread::current()->file_system_dispatcher(); | 1112 ChildThread::current()->file_system_dispatcher(); |
| 1113 return file_system_dispatcher->OpenFile(path, flags, | 1113 return file_system_dispatcher->OpenFile(path, flags, |
| 1114 new AsyncOpenFileSystemURLCallbackTranslator( | 1114 new AsyncOpenFileSystemURLCallbackTranslator( |
| 1115 callback, | 1115 callback, |
| 1116 base::Bind(&DoNotifyCloseFile, path))); | 1116 base::Bind(&DoNotifyCloseFile, path))); |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 void PepperPluginDelegateImpl::SyncGetFileSystemPlatformPath( | 1119 void PepperPluginDelegateImpl::SyncGetFileSystemPlatformPath( |
| 1120 const GURL& url, FilePath* platform_path) { | 1120 const GURL& url, base::FilePath* platform_path) { |
| 1121 RenderThreadImpl::current()->Send(new FileSystemHostMsg_SyncGetPlatformPath( | 1121 RenderThreadImpl::current()->Send(new FileSystemHostMsg_SyncGetPlatformPath( |
| 1122 url, platform_path)); | 1122 url, platform_path)); |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 scoped_refptr<base::MessageLoopProxy> | 1125 scoped_refptr<base::MessageLoopProxy> |
| 1126 PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() { | 1126 PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() { |
| 1127 return RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(); | 1127 return RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(); |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 uint32 PepperPluginDelegateImpl::TCPSocketCreate() { | 1130 uint32 PepperPluginDelegateImpl::TCPSocketCreate() { |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 RenderWidgetFullscreenPepper* container = | 1593 RenderWidgetFullscreenPepper* container = |
| 1594 static_cast<RenderWidgetFullscreenPepper*>( | 1594 static_cast<RenderWidgetFullscreenPepper*>( |
| 1595 instance->fullscreen_container()); | 1595 instance->fullscreen_container()); |
| 1596 return container->mouse_lock_dispatcher(); | 1596 return container->mouse_lock_dispatcher(); |
| 1597 } else { | 1597 } else { |
| 1598 return render_view_->mouse_lock_dispatcher(); | 1598 return render_view_->mouse_lock_dispatcher(); |
| 1599 } | 1599 } |
| 1600 } | 1600 } |
| 1601 | 1601 |
| 1602 } // namespace content | 1602 } // namespace content |
| OLD | NEW |