| Index: content/common/plugin_list.cc
|
| diff --git a/content/common/plugin_list.cc b/content/common/plugin_list.cc
|
| index 80438818181f7f3577fb9f88ec91f6e736224a5d..eff0f66b26964b38d5dd6dec5e05f144b0150a5b 100644
|
| --- a/content/common/plugin_list.cc
|
| +++ b/content/common/plugin_list.cc
|
| @@ -20,10 +20,6 @@
|
| #include "net/base/mime_util.h"
|
| #include "url/gurl.h"
|
|
|
| -#if defined(OS_WIN)
|
| -#include "content/common/plugin_constants_win.h"
|
| -#endif
|
| -
|
| namespace content {
|
|
|
| namespace {
|
| @@ -37,42 +33,11 @@ PluginList* PluginList::Singleton() {
|
| return g_singleton.Pointer();
|
| }
|
|
|
| -// static
|
| -bool PluginList::DebugPluginLoading() {
|
| - return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kDebugPluginLoading);
|
| -}
|
| -
|
| -void PluginList::DisablePluginsDiscovery() {
|
| - plugins_discovery_disabled_ = true;
|
| -}
|
| -
|
| void PluginList::RefreshPlugins() {
|
| base::AutoLock lock(lock_);
|
| loading_state_ = LOADING_STATE_NEEDS_REFRESH;
|
| }
|
|
|
| -void PluginList::AddExtraPluginPath(const base::FilePath& plugin_path) {
|
| - // Chrome OS only loads plugins from /opt/google/chrome/plugins.
|
| -#if !defined(OS_CHROMEOS)
|
| - base::AutoLock lock(lock_);
|
| - extra_plugin_paths_.push_back(plugin_path);
|
| -#endif
|
| -}
|
| -
|
| -void PluginList::RemoveExtraPluginPath(const base::FilePath& plugin_path) {
|
| - base::AutoLock lock(lock_);
|
| - RemoveExtraPluginPathLocked(plugin_path);
|
| -}
|
| -
|
| -void PluginList::AddExtraPluginDir(const base::FilePath& plugin_dir) {
|
| - // Chrome OS only loads plugins from /opt/google/chrome/plugins.
|
| -#if !defined(OS_CHROMEOS)
|
| - base::AutoLock lock(lock_);
|
| - extra_plugin_dirs_.push_back(plugin_dir);
|
| -#endif
|
| -}
|
| -
|
| void PluginList::RegisterInternalPlugin(const WebPluginInfo& info,
|
| bool add_at_beginning) {
|
| base::AutoLock lock(lock_);
|
| @@ -114,70 +79,18 @@ void PluginList::GetInternalPlugins(
|
|
|
| bool PluginList::ReadPluginInfo(const base::FilePath& filename,
|
| WebPluginInfo* info) {
|
| - {
|
| - base::AutoLock lock(lock_);
|
| - for (size_t i = 0; i < internal_plugins_.size(); ++i) {
|
| - if (filename == internal_plugins_[i].path) {
|
| - *info = internal_plugins_[i];
|
| - return true;
|
| - }
|
| - }
|
| - }
|
| -
|
| - return PluginList::ReadWebPluginInfo(filename, info);
|
| -}
|
| -
|
| -// static
|
| -bool PluginList::ParseMimeTypes(
|
| - const std::string& mime_types_str,
|
| - const std::string& file_extensions_str,
|
| - const base::string16& mime_type_descriptions_str,
|
| - std::vector<WebPluginMimeType>* parsed_mime_types) {
|
| - std::vector<std::string> mime_types = base::SplitString(
|
| - mime_types_str, "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
| - std::vector<std::string> file_extensions = base::SplitString(
|
| - file_extensions_str, "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
| - std::vector<base::string16> descriptions = base::SplitString(
|
| - mime_type_descriptions_str, base::string16(1, '|'), base::TRIM_WHITESPACE,
|
| - base::SPLIT_WANT_ALL);
|
| -
|
| - parsed_mime_types->clear();
|
| -
|
| - if (mime_types.empty())
|
| - return false;
|
| -
|
| - for (size_t i = 0; i < mime_types.size(); ++i) {
|
| - WebPluginMimeType mime_type;
|
| - mime_type.mime_type = base::ToLowerASCII(mime_types[i]);
|
| - if (file_extensions.size() > i) {
|
| - mime_type.file_extensions = base::SplitString(
|
| - file_extensions[i], ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
| - }
|
| -
|
| - if (descriptions.size() > i) {
|
| - mime_type.description = descriptions[i];
|
| -
|
| - // On Windows, the description likely has a list of file extensions
|
| - // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension
|
| - // list from the description if it is present.
|
| - size_t ext = mime_type.description.find(base::ASCIIToUTF16("(*"));
|
| - if (ext != base::string16::npos) {
|
| - if (ext > 1 && mime_type.description[ext - 1] == ' ')
|
| - ext--;
|
| -
|
| - mime_type.description.erase(ext);
|
| - }
|
| + base::AutoLock lock(lock_);
|
| + for (const auto& plugin : internal_plugins_) {
|
| + if (filename == plugin.path) {
|
| + *info = plugin;
|
| + return true;
|
| }
|
| -
|
| - parsed_mime_types->push_back(mime_type);
|
| }
|
| -
|
| - return true;
|
| + return false;
|
| }
|
|
|
| PluginList::PluginList()
|
| - : loading_state_(LOADING_STATE_NEEDS_REFRESH),
|
| - plugins_discovery_disabled_(false) {
|
| + : loading_state_(LOADING_STATE_NEEDS_REFRESH) {
|
| }
|
|
|
| bool PluginList::PrepareForPluginLoading() {
|
| @@ -189,7 +102,7 @@ bool PluginList::PrepareForPluginLoading() {
|
| return true;
|
| }
|
|
|
| -void PluginList::LoadPlugins(bool include_npapi) {
|
| +void PluginList::LoadPlugins() {
|
| if (!PrepareForPluginLoading())
|
| return;
|
|
|
| @@ -203,7 +116,7 @@ void PluginList::LoadPlugins(bool include_npapi) {
|
| will_load_callback.Run();
|
|
|
| std::vector<base::FilePath> plugin_paths;
|
| - GetPluginPathsToLoad(&plugin_paths, include_npapi);
|
| + GetPluginPathsToLoad(&plugin_paths);
|
|
|
| for (std::vector<base::FilePath>::const_iterator it = plugin_paths.begin();
|
| it != plugin_paths.end();
|
| @@ -219,41 +132,30 @@ bool PluginList::LoadPluginIntoPluginList(
|
| const base::FilePath& path,
|
| std::vector<WebPluginInfo>* plugins,
|
| WebPluginInfo* plugin_info) {
|
| - LOG_IF(ERROR, PluginList::DebugPluginLoading())
|
| - << "Loading plugin " << path.value();
|
| if (!ReadPluginInfo(path, plugin_info))
|
| return false;
|
|
|
| - if (!ShouldLoadPluginUsingPluginList(*plugin_info, plugins))
|
| - return false;
|
| -
|
| -#if defined(OS_WIN) && !defined(NDEBUG)
|
| - if (path.BaseName().value() != L"npspy.dll") // Make an exception for NPSPY
|
| -#endif
|
| - {
|
| - for (size_t i = 0; i < plugin_info->mime_types.size(); ++i) {
|
| - // TODO: don't load global handlers for now.
|
| - // WebKit hands to the Plugin before it tries
|
| - // to handle mimeTypes on its own.
|
| - const std::string &mime_type = plugin_info->mime_types[i].mime_type;
|
| - if (mime_type == "*")
|
| - return false;
|
| - }
|
| + // TODO(piman): Do we still need this after NPAPI removal?
|
| + for (size_t i = 0; i < plugin_info->mime_types.size(); ++i) {
|
| + // TODO: don't load global handlers for now.
|
| + // WebKit hands to the Plugin before it tries
|
| + // to handle mimeTypes on its own.
|
| + const std::string &mime_type = plugin_info->mime_types[i].mime_type;
|
| + if (mime_type == "*")
|
| + return false;
|
| }
|
| plugins->push_back(*plugin_info);
|
| return true;
|
| }
|
|
|
| -void PluginList::GetPluginPathsToLoad(std::vector<base::FilePath>* plugin_paths,
|
| - bool include_npapi) {
|
| +void PluginList::GetPluginPathsToLoad(
|
| + std::vector<base::FilePath>* plugin_paths) {
|
| // Don't want to hold the lock while loading new plugins, so we don't block
|
| // other methods if they're called on other threads.
|
| std::vector<base::FilePath> extra_plugin_paths;
|
| - std::vector<base::FilePath> extra_plugin_dirs;
|
| {
|
| base::AutoLock lock(lock_);
|
| extra_plugin_paths = extra_plugin_paths_;
|
| - extra_plugin_dirs = extra_plugin_dirs_;
|
| }
|
|
|
| for (size_t i = 0; i < extra_plugin_paths.size(); ++i) {
|
| @@ -264,22 +166,6 @@ void PluginList::GetPluginPathsToLoad(std::vector<base::FilePath>* plugin_paths,
|
| }
|
| plugin_paths->push_back(path);
|
| }
|
| -
|
| - if (include_npapi) {
|
| - // A bit confusingly, this function is used to load Pepper plugins as well.
|
| - // Those are all internal plugins so we have to use extra_plugin_paths.
|
| - for (size_t i = 0; i < extra_plugin_dirs.size(); ++i)
|
| - GetPluginsInDir(extra_plugin_dirs[i], plugin_paths);
|
| -
|
| - std::vector<base::FilePath> directories_to_scan;
|
| - GetPluginDirectories(&directories_to_scan);
|
| - for (size_t i = 0; i < directories_to_scan.size(); ++i)
|
| - GetPluginsInDir(directories_to_scan[i], plugin_paths);
|
| -
|
| -#if defined(OS_WIN)
|
| - GetPluginPathsFromRegistry(plugin_paths);
|
| -#endif
|
| - }
|
| }
|
|
|
| void PluginList::SetPlugins(const std::vector<WebPluginInfo>& plugins) {
|
| @@ -298,9 +184,8 @@ void PluginList::set_will_load_plugins_callback(const base::Closure& callback) {
|
| will_load_plugins_callback_ = callback;
|
| }
|
|
|
| -void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins,
|
| - bool include_npapi) {
|
| - LoadPlugins(include_npapi);
|
| +void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) {
|
| + LoadPlugins();
|
| base::AutoLock lock(lock_);
|
| plugins->insert(plugins->end(), plugins_list_.begin(), plugins_list_.end());
|
| }
|
| @@ -317,14 +202,13 @@ void PluginList::GetPluginInfoArray(
|
| const std::string& mime_type,
|
| bool allow_wildcard,
|
| bool* use_stale,
|
| - bool include_npapi,
|
| std::vector<WebPluginInfo>* info,
|
| std::vector<std::string>* actual_mime_types) {
|
| DCHECK(mime_type == base::ToLowerASCII(mime_type));
|
| DCHECK(info);
|
|
|
| if (!use_stale)
|
| - LoadPlugins(include_npapi);
|
| + LoadPlugins();
|
| base::AutoLock lock(lock_);
|
| if (use_stale)
|
| *use_stale = (loading_state_ != LOADING_STATE_UP_TO_DATE);
|
|
|