diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 02:23:23 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 02:23:23 +0000 |
commit | 6be08ae197f90f71e3804ff1e842000a5db2af20 (patch) | |
tree | 3016a1b15cbb62bb76d43d9811a610792fd56d8f /content/browser/plugin_loader_posix.cc | |
parent | d981cd2612938c3737d73922b5e2a9bc74da73ad (diff) | |
download | chromium_src-6be08ae197f90f71e3804ff1e842000a5db2af20.zip chromium_src-6be08ae197f90f71e3804ff1e842000a5db2af20.tar.gz chromium_src-6be08ae197f90f71e3804ff1e842000a5db2af20.tar.bz2 |
Move PluginLoaderClient to PluginLoaderPosix in its own file.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8334004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/plugin_loader_posix.cc')
-rw-r--r-- | content/browser/plugin_loader_posix.cc | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/content/browser/plugin_loader_posix.cc b/content/browser/plugin_loader_posix.cc new file mode 100644 index 0000000..da3d55a --- /dev/null +++ b/content/browser/plugin_loader_posix.cc @@ -0,0 +1,77 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/plugin_loader_posix.h" + +#include "base/bind.h" +#include "base/message_loop_proxy.h" +#include "content/browser/browser_thread.h" +#include "content/common/utility_messages.h" +#include "webkit/plugins/npapi/plugin_list.h" + +namespace { + +void RunGetPluginsCallback(const PluginService::GetPluginsCallback& callback, + const std::vector<webkit::WebPluginInfo> plugins) { + callback.Run(plugins); +} + +} // namespace + +// static +void PluginLoaderPosix::LoadPlugins( + base::MessageLoopProxy* target_loop, + const PluginService::GetPluginsCallback& callback) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + + PluginLoaderPosix* client = new PluginLoaderPosix(target_loop, callback); + UtilityProcessHost* process_host = + new UtilityProcessHost(client, BrowserThread::IO); + process_host->set_no_sandbox(true); +#if defined(OS_MACOSX) + process_host->set_child_flags(ChildProcessHost::CHILD_ALLOW_HEAP_EXECUTION); +#endif + + std::vector<FilePath> extra_plugin_paths; + std::vector<FilePath> extra_plugin_dirs; + std::vector<webkit::WebPluginInfo> internal_plugins; + webkit::npapi::PluginList::Singleton()->GetPluginPathListsToLoad( + &extra_plugin_paths, &extra_plugin_dirs, &internal_plugins); + + process_host->Send(new UtilityMsg_LoadPlugins( + extra_plugin_paths, extra_plugin_dirs, internal_plugins)); +} + +bool PluginLoaderPosix::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(PluginLoaderPosix, message) + IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadedPlugins, OnGotPlugins) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void PluginLoaderPosix::OnProcessCrashed(int exit_code) { + LOG(ERROR) << "Out-of-process plugin loader crashed with code " << exit_code + << ". You will have no plugins!"; + // Don't leave callers hanging. + OnGotPlugins(std::vector<webkit::WebPluginInfo>()); +} + +PluginLoaderPosix::PluginLoaderPosix( + base::MessageLoopProxy* target_loop, + const PluginService::GetPluginsCallback& callback) + : target_loop_(target_loop), + callback_(callback) { +} + +PluginLoaderPosix::~PluginLoaderPosix() { +} + +void PluginLoaderPosix::OnGotPlugins( + const std::vector<webkit::WebPluginInfo>& plugins) { + webkit::npapi::PluginList::Singleton()->SetPlugins(plugins); + target_loop_->PostTask(FROM_HERE, + base::Bind(&RunGetPluginsCallback, callback_, plugins)); +} |