diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-07 17:35:45 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-07 17:35:45 +0000 |
commit | 4923a338552b0b10747a7ee3c5d424089db2293d (patch) | |
tree | eba4da9f4d58eb04ddced35bf5d3e2166e3f2b80 /chrome/renderer | |
parent | 525c657a4051abcad9a95631b2074ae27caac41f (diff) | |
download | chromium_src-4923a338552b0b10747a7ee3c5d424089db2293d.zip chromium_src-4923a338552b0b10747a7ee3c5d424089db2293d.tar.gz chromium_src-4923a338552b0b10747a7ee3c5d424089db2293d.tar.bz2 |
Revert 68482 - Make webkit/glue/plugins no longer depend on ppapi/proxy directly. This causes
things that use webkit but otherwise don't need IPC to include the IPC
directory.
This patch moves the set-up of the proxy into the renderer. I also did a lot
of clean-up of the initialization and it seems much nicer now.
BUG=63684
TEST=manual PPAPI proxy testing
Review URL: http://codereview.chromium.org/5592005
TBR=brettw@chromium.org
Review URL: http://codereview.chromium.org/5616004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/DEPS | 1 | ||||
-rw-r--r-- | chrome/renderer/pepper_plugin_delegate_impl.cc | 88 | ||||
-rw-r--r-- | chrome/renderer/pepper_plugin_delegate_impl.h | 3 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 25 |
4 files changed, 29 insertions, 88 deletions
diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS index 9b488d4..02bb449 100644 --- a/chrome/renderer/DEPS +++ b/chrome/renderer/DEPS @@ -8,7 +8,6 @@ include_rules = [ "+media/filters", "+media/video", "+ppapi/c", - "+ppapi/proxy", "+sandbox/src", "+skia", "+webkit/extensions", diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc index a949ffb8..c3a85d9 100644 --- a/chrome/renderer/pepper_plugin_delegate_impl.cc +++ b/chrome/renderer/pepper_plugin_delegate_impl.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/renderer/pepper_plugin_delegate_impl.h" - #include <cmath> +#include "chrome/renderer/pepper_plugin_delegate_impl.h" + #include "app/l10n_util.h" #include "app/surface/transport_dib.h" #include "base/callback.h" @@ -18,7 +18,6 @@ #include "base/utf_string_conversions.h" #include "chrome/common/child_thread.h" #include "chrome/common/file_system/file_system_dispatcher.h" -#include "chrome/common/pepper_plugin_registry.h" #include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" #include "chrome/renderer/audio_message_filter.h" @@ -33,7 +32,6 @@ #include "grit/locale_settings.h" #include "ipc/ipc_channel_handle.h" #include "ppapi/c/dev/pp_video_dev.h" -#include "ppapi/proxy/host_dispatcher.h" #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserCompletion.h" #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" @@ -49,10 +47,6 @@ #include "chrome/renderer/render_thread.h" #endif -#if defined(OS_POSIX) -#include "ipc/ipc_channel_posix.h" -#endif - using WebKit::WebView; namespace { @@ -419,60 +413,6 @@ class PlatformVideoDecoderImpl DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl); }; -class DispatcherWrapper : public pepper::PluginDelegate::OutOfProcessProxy { - public: - DispatcherWrapper() {} - virtual ~DispatcherWrapper() {} - - bool Init(base::ProcessHandle plugin_process_handle, - IPC::ChannelHandle channel_handle, - PP_Module pp_module, - pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface); - - // OutOfProcessProxy implementation. - virtual const void* GetProxiedInterface(const char* name) { - return dispatcher_->GetProxiedInterface(name); - } - virtual void AddInstance(PP_Instance instance) { - pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); - } - virtual void RemoveInstance(PP_Instance instance) { - pp::proxy::HostDispatcher::RemoveForInstance(instance); - } - - private: - scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; -}; - -bool DispatcherWrapper::Init( - base::ProcessHandle plugin_process_handle, - IPC::ChannelHandle channel_handle, - PP_Module pp_module, - pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { - dispatcher_.reset(new pp::proxy::HostDispatcher( - plugin_process_handle, pp_module, local_get_interface)); - -#if defined(OS_POSIX) - // If we received a ChannelHandle, register it now. - if (channel_handle.socket.fd >= 0) - IPC::AddChannelSocket(channel_handle.name, channel_handle.socket.fd); -#endif - - if (!dispatcher_->InitWithChannel( - ChildProcess::current()->io_message_loop(), channel_handle.name, - true, ChildProcess::current()->GetShutDownEvent())) { - dispatcher_.reset(); - return false; - } - - if (!dispatcher_->InitializeModule()) { - // TODO(brettw) does the module get unloaded in this case? - dispatcher_.reset(); - return false; - } - return true; -} - } // namespace PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) @@ -484,29 +424,19 @@ PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { } scoped_refptr<pepper::PluginModule> -PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) { - // Easy case is in-process plugins. - if (!PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin(path)) - return PepperPluginRegistry::GetInstance()->GetModule(path); - - // Out of process: have the browser start the plugin process for us. +PepperPluginDelegateImpl::CreateOutOfProcessPepperPlugin( + const FilePath& path) { base::ProcessHandle plugin_process_handle = NULL; IPC::ChannelHandle channel_handle; render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin( path, &plugin_process_handle, &channel_handle)); if (channel_handle.name.empty()) return scoped_refptr<pepper::PluginModule>(); // Couldn't be initialized. - - // Create a new HostDispatcher for the proxying, and hook it to a new - // PluginModule. - scoped_refptr<pepper::PluginModule> module(new pepper::PluginModule); - scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper); - if (!dispatcher->Init(plugin_process_handle, channel_handle, - module->pp_module(), - pepper::PluginModule::GetLocalGetInterfaceFunc())) - return scoped_refptr<pepper::PluginModule>(); - module->InitAsProxied(dispatcher.release()); - return module; + return pepper::PluginModule::CreateOutOfProcessModule( + ChildProcess::current()->io_message_loop(), + plugin_process_handle, + channel_handle, + ChildProcess::current()->GetShutDownEvent()); } void PepperPluginDelegateImpl::ViewInitiatedPaint() { diff --git a/chrome/renderer/pepper_plugin_delegate_impl.h b/chrome/renderer/pepper_plugin_delegate_impl.h index d59be3b..9402ae2 100644 --- a/chrome/renderer/pepper_plugin_delegate_impl.h +++ b/chrome/renderer/pepper_plugin_delegate_impl.h @@ -44,7 +44,8 @@ class PepperPluginDelegateImpl explicit PepperPluginDelegateImpl(RenderView* render_view); virtual ~PepperPluginDelegateImpl(); - scoped_refptr<pepper::PluginModule> CreatePepperPlugin(const FilePath& path); + scoped_refptr<pepper::PluginModule> CreateOutOfProcessPepperPlugin( + const FilePath& path); // Called by RenderView to tell us about painting events, these two functions // just correspond to the DidInitiatePaint and DidFlushPaint in R.V.. diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 0c93047..509c066 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -833,12 +833,12 @@ WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, &info, &setting, &mime_type)); if (!found || !info.enabled) return NULL; - scoped_refptr<pepper::PluginModule> pepper_module( - pepper_delegate_.CreatePepperPlugin(info.path)); + PepperPluginRegistry::GetInstance()->GetModule(info.path)); if (pepper_module) return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); - return CreateNPAPIPlugin(frame, params, info.path, mime_type); + else + return CreateNPAPIPlugin(frame, params, info.path, mime_type); } void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { @@ -2743,10 +2743,21 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, if (info.path.value() == kDefaultPluginLibraryName || plugin_setting == CONTENT_SETTING_ALLOW || host_setting == CONTENT_SETTING_ALLOW) { - scoped_refptr<pepper::PluginModule> pepper_module( - pepper_delegate_.CreatePepperPlugin(info.path)); - if (pepper_module) - return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); + scoped_refptr<pepper::PluginModule> pepper_module; + if (PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin( + info.path)) { + pepper_module = + pepper_delegate_.CreateOutOfProcessPepperPlugin(info.path); + } else { + pepper_module = + PepperPluginRegistry::GetInstance()->GetModule(info.path); + } + if (pepper_module) { + return CreatePepperPlugin(frame, + params, + info.path, + pepper_module.get()); + } return CreateNPAPIPlugin(frame, params, info.path, actual_mime_type); } std::string resource; |