Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2216)

Unified Diff: content/common/pepper_plugin_registry.cc

Issue 6869051: Move PepperPluginRegistry to content, while leaving the Chrome specific bits (NaCl, registration ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/pepper_plugin_registry.h ('k') | content/content_common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/pepper_plugin_registry.cc
===================================================================
--- content/common/pepper_plugin_registry.cc (revision 81920)
+++ content/common/pepper_plugin_registry.cc (working copy)
@@ -2,164 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/pepper_plugin_registry.h"
+#include "content/common/pepper_plugin_registry.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/native_library.h"
-#include "base/path_service.h"
#include "base/string_split.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_switches.h"
#include "content/common/child_process.h"
+#include "content/common/content_client.h"
#include "content/common/content_switches.h"
-#include "remoting/client/plugin/pepper_entrypoints.h"
#include "webkit/plugins/npapi/plugin_list.h"
namespace {
-const char* kPDFPluginName = "Chrome PDF Viewer";
-const char* kPDFPluginMimeType = "application/pdf";
-const char* kPDFPluginExtension = "pdf";
-const char* kPDFPluginDescription = "Portable Document Format";
-
-const char* kNaClPluginName = "Chrome NaCl";
-const char* kNaClPluginMimeType = "application/x-nacl";
-const char* kNaClPluginExtension = "nexe";
-const char* kNaClPluginDescription = "Native Client Executable";
-
-#if defined(ENABLE_REMOTING)
-const char* kRemotingPluginMimeType = "pepper-application/x-chromoting";
-#endif
-
-const char* kFlashPluginName = "Shockwave Flash";
-const char* kFlashPluginSwfMimeType = "application/x-shockwave-flash";
-const char* kFlashPluginSwfExtension = "swf";
-const char* kFlashPluginSwfDescription = "Shockwave Flash";
-const char* kFlashPluginSplMimeType = "application/futuresplash";
-const char* kFlashPluginSplExtension = "spl";
-const char* kFlashPluginSplDescription = "FutureSplash Player";
-
-// Appends the known built-in plugins to the given vector. Some built-in
-// plugins are "internal" which means they are compiled into the Chrome binary,
-// and some are extra shared libraries distributed with the browser (these are
-// not marked internal, aside from being automatically registered, they're just
-// regular plugins).
-void ComputeBuiltInPlugins(std::vector<PepperPluginInfo>* plugins) {
- // PDF.
- //
- // Once we're sandboxed, we can't know if the PDF plugin is available or not;
- // but (on Linux) this function is always called once before we're sandboxed.
- // So the first time through test if the file is available and then skip the
- // check on subsequent calls if yes.
- static bool skip_pdf_file_check = false;
- FilePath path;
- if (PathService::Get(chrome::FILE_PDF_PLUGIN, &path)) {
- if (skip_pdf_file_check || file_util::PathExists(path)) {
- PepperPluginInfo pdf;
- pdf.path = path;
- pdf.name = kPDFPluginName;
- webkit::npapi::WebPluginMimeType pdf_mime_type(kPDFPluginMimeType,
- kPDFPluginExtension,
- kPDFPluginDescription);
- pdf.mime_types.push_back(pdf_mime_type);
- plugins->push_back(pdf);
-
- skip_pdf_file_check = true;
- }
- }
-
- // Handle the Native Client plugin just like the PDF plugin.
- static bool skip_nacl_file_check = false;
- if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) {
- if (skip_nacl_file_check || file_util::PathExists(path)) {
- PepperPluginInfo nacl;
- nacl.path = path;
- nacl.name = kNaClPluginName;
- webkit::npapi::WebPluginMimeType nacl_mime_type(kNaClPluginMimeType,
- kNaClPluginExtension,
- kNaClPluginDescription);
- nacl.mime_types.push_back(nacl_mime_type);
- plugins->push_back(nacl);
-
- skip_nacl_file_check = true;
- }
- }
-
- // Remoting.
-#if defined(ENABLE_REMOTING)
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableRemoting)) {
- PepperPluginInfo info;
- info.is_internal = true;
- info.path = FilePath(FILE_PATH_LITERAL("internal-chromoting"));
- webkit::npapi::WebPluginMimeType remoting_mime_type(kRemotingPluginMimeType,
- std::string(),
- std::string());
- info.mime_types.push_back(remoting_mime_type);
- info.internal_entry_points.get_interface = remoting::PPP_GetInterface;
- info.internal_entry_points.initialize_module =
- remoting::PPP_InitializeModule;
- info.internal_entry_points.shutdown_module = remoting::PPP_ShutdownModule;
-
- plugins->push_back(info);
- }
-#endif
-}
-
// Appends any plugins from the command line to the given vector.
void ComputePluginsFromCommandLine(std::vector<PepperPluginInfo>* plugins) {
- // Flash being out of process is handled separately than general plugins
- // for testing purposes.
bool out_of_process =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiOutOfProcess);
- bool flash_out_of_process = !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kPpapiFlashInProcess);
-
- // Handle any Pepper Flash first.
- const CommandLine::StringType flash_path =
- CommandLine::ForCurrentProcess()->GetSwitchValueNative(
- switches::kPpapiFlashPath);
- if (!flash_path.empty()) {
- PepperPluginInfo plugin;
- plugin.is_out_of_process = flash_out_of_process;
- plugin.path = FilePath(flash_path);
- plugin.name = kFlashPluginName;
-
- const std::string flash_version =
- CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kPpapiFlashVersion);
- std::vector<std::string> flash_version_numbers;
- base::SplitString(flash_version, '.', &flash_version_numbers);
- if (flash_version_numbers.size() < 1)
- flash_version_numbers.push_back("10");
- // |SplitString()| puts in an empty string given an empty string. :(
- else if (flash_version_numbers[0].empty())
- flash_version_numbers[0] = "10";
- if (flash_version_numbers.size() < 2)
- flash_version_numbers.push_back("2");
- if (flash_version_numbers.size() < 3)
- flash_version_numbers.push_back("999");
- if (flash_version_numbers.size() < 4)
- flash_version_numbers.push_back("999");
- // E.g., "Shockwave Flash 10.2 r154":
- plugin.description = plugin.name + " " + flash_version_numbers[0] + "." +
- flash_version_numbers[1] + " r" + flash_version_numbers[2];
- plugin.version = JoinString(flash_version_numbers, '.');
- webkit::npapi::WebPluginMimeType swf_mime_type(kFlashPluginSwfMimeType,
- kFlashPluginSwfExtension,
- kFlashPluginSwfDescription);
- plugin.mime_types.push_back(swf_mime_type);
- webkit::npapi::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType,
- kFlashPluginSplExtension,
- kFlashPluginSplDescription);
- plugin.mime_types.push_back(spl_mime_type);
- plugins->push_back(plugin);
- }
-
- // Handle other plugins.
const std::string value =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kRegisterPepperPlugins);
@@ -215,8 +76,6 @@
} // namespace
-const char* PepperPluginRegistry::kPDFPluginName = ::kPDFPluginName;
-
webkit::npapi::WebPluginInfo PepperPluginInfo::ToWebPluginInfo() const {
webkit::npapi::WebPluginInfo info;
@@ -230,33 +89,24 @@
webkit::npapi::WebPluginInfo::EnabledStates enabled_state =
webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED;
- // Enable the Native Client Plugin based on the command line.
- // TODO(abarth): This is the wrong place to do this work!
- if (name == kNaClPluginName) {
- bool nacl_enabled =
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableNaCl);
- enabled_state = nacl_enabled ?
- webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED :
+ if (!enabled) {
+ enabled_state =
webkit::npapi::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED;
}
+
info.enabled = enabled_state;
return info;
}
PepperPluginInfo::PepperPluginInfo()
: is_internal(false),
- is_out_of_process(false) {
+ is_out_of_process(false),
+ enabled(true) {
}
PepperPluginInfo::~PepperPluginInfo() {
}
-NaClModuleInfo::NaClModuleInfo() {
-}
-
-NaClModuleInfo::~NaClModuleInfo() {
-}
-
// static
PepperPluginRegistry* PepperPluginRegistry::GetInstance() {
static PepperPluginRegistry* registry = NULL;
@@ -269,7 +119,7 @@
// static
void PepperPluginRegistry::ComputeList(std::vector<PepperPluginInfo>* plugins) {
- ComputeBuiltInPlugins(plugins);
+ content::GetContentClient()->AddPepperPlugins(plugins);
ComputePluginsFromCommandLine(plugins);
}
@@ -381,53 +231,3 @@
// This function is not needed on the host side of the proxy.
return NULL;
}
-
-void PepperPluginRegistry::RegisterNaClModule(const GURL& url,
- const std::string& mime_type) {
- NaClModuleInfo info;
- info.url = url;
- info.mime_type = mime_type;
-
- DCHECK(FindNaClModule(url) == nacl_module_list_.end());
- nacl_module_list_.push_front(info);
-}
-
-void PepperPluginRegistry::UnregisterNaClModule(const GURL& url) {
- NaClModuleInfoList::iterator iter = FindNaClModule(url);
- DCHECK(iter != nacl_module_list_.end());
- nacl_module_list_.erase(iter);
-}
-
-void PepperPluginRegistry::UpdatePluginListWithNaClModules() {
- FilePath path;
- PathService::Get(chrome::FILE_NACL_PLUGIN, &path);
-
- webkit::npapi::PluginList::Singleton()->UnregisterInternalPlugin(path);
-
- const PepperPluginInfo* pepper_info = GetInfoForPlugin(path);
- webkit::npapi::WebPluginInfo info = pepper_info->ToWebPluginInfo();
-
- DCHECK(nacl_module_list_.size() <= 1);
- for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
- iter != nacl_module_list_.end(); ++iter) {
- webkit::npapi::WebPluginMimeType mime_type_info;
- mime_type_info.mime_type = iter->mime_type;
- mime_type_info.additional_param_names.push_back(UTF8ToUTF16("nacl"));
- mime_type_info.additional_param_values.push_back(
- UTF8ToUTF16(iter->url.spec()));
- info.mime_types.push_back(mime_type_info);
- }
-
- webkit::npapi::PluginList::Singleton()->RefreshPlugins();
- webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info);
-}
-
-PepperPluginRegistry::NaClModuleInfoList::iterator
- PepperPluginRegistry::FindNaClModule(const GURL& url) {
- for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
- iter != nacl_module_list_.end(); ++iter) {
- if (iter->url == url)
- return iter;
- }
- return nacl_module_list_.end();
-}
« no previous file with comments | « content/common/pepper_plugin_registry.h ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698