summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-13 00:54:21 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-13 00:54:21 +0000
commit046344c69b0e16f8fa2fdcaf7a8e486d26301486 (patch)
treea2ff22d44b1595158eb6ffa7eafca06af34524f5
parent7e8ede35f4a3e35e8d3948e7b0dec41d124a5244 (diff)
downloadchromium_src-046344c69b0e16f8fa2fdcaf7a8e486d26301486.zip
chromium_src-046344c69b0e16f8fa2fdcaf7a8e486d26301486.tar.gz
chromium_src-046344c69b0e16f8fa2fdcaf7a8e486d26301486.tar.bz2
Fix layout test failures. Looks like keying the plugins based on OriginalFileName didn't work, since different filenames might still have the same value (i.e. QuickTime). Instead I did what Firefox does, which is collect the list of directories in one pass, then crawl them in another.
Review URL: http://codereview.chromium.org/17367 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7907 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/metrics_log.cc3
-rw-r--r--chrome/common/render_messages.h3
-rw-r--r--webkit/glue/plugins/plugin_lib.cc23
-rw-r--r--webkit/glue/plugins/plugin_lib.h3
-rw-r--r--webkit/glue/plugins/plugin_list.cc183
-rw-r--r--webkit/glue/plugins/plugin_list.h45
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc3
-rw-r--r--webkit/glue/webplugin.h5
8 files changed, 123 insertions, 145 deletions
diff --git a/chrome/browser/metrics_log.cc b/chrome/browser/metrics_log.cc
index dc3ab86..c79ca04d 100644
--- a/chrome/browser/metrics_log.cc
+++ b/chrome/browser/metrics_log.cc
@@ -458,7 +458,8 @@ void MetricsLog::WritePluginList(
// Plugin name and filename are hashed for the privacy of those
// testing unreleased new extensions.
WriteAttribute("name", CreateBase64Hash(WideToUTF8(iter->name)));
- WriteAttribute("filename", CreateBase64Hash(iter->filename));
+ WriteAttribute("filename",
+ CreateBase64Hash(WideToUTF8(iter->path.BaseName().ToWStringHack())));
WriteAttribute("version", WideToUTF8(iter->version));
}
}
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 24e3c96a..b0338b7 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -1122,7 +1122,6 @@ struct ParamTraits<WebPluginInfo> {
typedef WebPluginInfo param_type;
static void Write(Message* m, const param_type& p) {
WriteParam(m, p.name);
- WriteParam(m, p.filename);
WriteParam(m, p.path);
WriteParam(m, p.version);
WriteParam(m, p.desc);
@@ -1131,7 +1130,6 @@ struct ParamTraits<WebPluginInfo> {
static bool Read(const Message* m, void** iter, param_type* r) {
return
ReadParam(m, iter, &r->name) &&
- ReadParam(m, iter, &r->filename) &&
ReadParam(m, iter, &r->path) &&
ReadParam(m, iter, &r->version) &&
ReadParam(m, iter, &r->desc) &&
@@ -1141,7 +1139,6 @@ struct ParamTraits<WebPluginInfo> {
l->append(L"(");
LogParam(p.name, l);
l->append(L", ");
- LogParam(p.filename, l);
l->append(L", ");
LogParam(p.path, l);
l->append(L", ");
diff --git a/webkit/glue/plugins/plugin_lib.cc b/webkit/glue/plugins/plugin_lib.cc
index 546c025..fee4055 100644
--- a/webkit/glue/plugins/plugin_lib.cc
+++ b/webkit/glue/plugins/plugin_lib.cc
@@ -33,8 +33,7 @@ const char kPluginInstancesActiveCounter[] = "PluginInstancesActive";
static const InternalPluginInfo g_internal_plugins[] = {
{
- {kActiveXShimFileName,
- kActiveXShimFileName,
+ {FilePath(kActiveXShimFileName),
L"ActiveX Plug-in",
L"ActiveX Plug-in provides a shim to support ActiveX controls",
L"1, 0, 0, 1",
@@ -47,8 +46,7 @@ static const InternalPluginInfo g_internal_plugins[] = {
activex_shim::ActiveX_Shim_NP_Shutdown
},
{
- {kActivexShimFileNameForMediaPlayer,
- kActivexShimFileNameForMediaPlayer,
+ {FilePath(kActivexShimFileNameForMediaPlayer),
kActivexShimFileNameForMediaPlayer,
L"Windows Media Player",
L"1, 0, 0, 1",
@@ -63,8 +61,7 @@ static const InternalPluginInfo g_internal_plugins[] = {
activex_shim::ActiveX_Shim_NP_Shutdown
},
{
- {kDefaultPluginLibraryName,
- kDefaultPluginLibraryName,
+ {FilePath(kDefaultPluginLibraryName),
L"Default Plug-in",
L"Provides functionality for installing third-party plug-ins",
L"1, 0, 0, 1",
@@ -129,9 +126,8 @@ PluginLib::PluginLib(const WebPluginInfo& info)
g_loaded_libs->push_back(this);
internal_ = false;
- std::wstring wide_filename = UTF8ToWide(info.filename);
for (int i = 0; i < arraysize(g_internal_plugins); ++i) {
- if (wide_filename == g_internal_plugins[i].version_info.filename) {
+ if (info.path == g_internal_plugins[i].version_info.path) {
internal_ = true;
NP_Initialize_ = g_internal_plugins[i].np_initialize;
NP_GetEntryPoints_ = g_internal_plugins[i].np_getentrypoints;
@@ -345,7 +341,6 @@ bool PluginLib::CreateWebPluginInfo(const PluginVersionInfo& pvi,
info->name = pvi.product_name;
info->desc = pvi.file_description;
info->version = pvi.file_version;
- info->filename = WideToUTF8(pvi.filename);
info->path = FilePath(pvi.path);
for (size_t i = 0; i < mime_types.size(); ++i) {
@@ -377,7 +372,7 @@ bool PluginLib::CreateWebPluginInfo(const PluginVersionInfo& pvi,
bool PluginLib::ReadWebPluginInfo(const FilePath &filename,
WebPluginInfo* info) {
for (int i = 0; i < arraysize(g_internal_plugins); ++i) {
- if (filename.value() == g_internal_plugins[i].version_info.filename)
+ if (filename == g_internal_plugins[i].version_info.path)
return CreateWebPluginInfo(g_internal_plugins[i].version_info, info);
}
@@ -391,18 +386,14 @@ bool PluginLib::CreateWebPluginInfo(const PluginVersionInfo& pvi,
if (!version_info.get())
return false;
- std::wstring original_filename = version_info->original_filename();
- std::wstring file_version = version_info->file_version();
-
PluginVersionInfo pvi;
version_info->GetValue(L"MIMEType", &pvi.mime_types);
version_info->GetValue(L"FileExtents", &pvi.file_extents);
version_info->GetValue(L"FileOpenName", &pvi.file_open_names);
pvi.product_name = version_info->product_name();
pvi.file_description = version_info->file_description();
- pvi.file_version = file_version;
- pvi.filename = original_filename;
- pvi.path = filename.value();
+ pvi.file_version = version_info->file_version();
+ pvi.path = filename;
return CreateWebPluginInfo(pvi, info);
}
diff --git a/webkit/glue/plugins/plugin_lib.h b/webkit/glue/plugins/plugin_lib.h
index 884f235..3882da9 100644
--- a/webkit/glue/plugins/plugin_lib.h
+++ b/webkit/glue/plugins/plugin_lib.h
@@ -28,8 +28,7 @@ class PluginInstance;
// This struct fully describes a plugin. For external plugins, it's read in from
// the version info of the dll; For internal plugins, it's predefined.
struct PluginVersionInfo {
- std::wstring filename;
- std::wstring path;
+ FilePath path;
std::wstring product_name;
std::wstring file_description;
std::wstring file_version;
diff --git a/webkit/glue/plugins/plugin_list.cc b/webkit/glue/plugins/plugin_list.cc
index b4b3dcb..5d27871 100644
--- a/webkit/glue/plugins/plugin_list.cc
+++ b/webkit/glue/plugins/plugin_list.cc
@@ -43,10 +43,10 @@ static const TCHAR kRegistryPath[] = _T("Path");
static const TCHAR kRegistryMozillaPlugins[] = _T("SOFTWARE\\MozillaPlugins");
static const TCHAR kRegistryFirefoxInstalled[] =
_T("SOFTWARE\\Mozilla\\Mozilla Firefox");
-static const char kMozillaActiveXPlugin[] = "npmozax.dll";
-static const char kNewWMPPlugin[] = "np-mswmp.dll";
-static const char kOldWMPPlugin[] = "npdsplay.dll";
-static const char kYahooApplicationStatePlugin[] = "npystate.dll";
+static const TCHAR kMozillaActiveXPlugin[] = _T("npmozax.dll");
+static const TCHAR kNewWMPPlugin[] = _T("np-mswmp.dll");
+static const TCHAR kOldWMPPlugin[] = _T("npdsplay.dll");
+static const TCHAR kYahooApplicationStatePlugin[] = _T("npystate.dll");
static const TCHAR kRegistryJava[] =
_T("Software\\JavaSoft\\Java Runtime Environment");
static const TCHAR kRegistryBrowserJavaVersion[] = _T("BrowserJavaVersion");
@@ -92,37 +92,44 @@ void PluginList::LoadPlugins(bool refresh) {
LoadInternalPlugins();
+ std::set<FilePath> directories_to_scan;
+
+
// Load any plugins listed in the registry
if (extra_plugin_paths_) {
- for (size_t i = 0; i < extra_plugin_paths_->size(); ++i) {
- LoadPlugin((*extra_plugin_paths_)[i]);
- }
+ for (size_t i = 0; i < extra_plugin_paths_->size(); ++i)
+ directories_to_scan.insert((*extra_plugin_paths_)[i].DirName());
}
// Load from the application-specific area
- LoadPlugins(GetPluginAppDirectory());
+ GetAppDirectory(&directories_to_scan);
// Load from the executable area
- LoadPlugins(GetPluginExeDirectory());
+ GetExeDirectory(&directories_to_scan);
// Load Java
- LoadJavaPlugin();
+ GetJavaDirectory(&directories_to_scan);
// Load firefox plugins too. This is mainly to try to locate
// a pre-installed Flash player.
- LoadFirefoxPlugins();
+ GetFirefoxDirectory(&directories_to_scan);
// Firefox hard-codes the paths of some popular plugins to ensure that
// the plugins are found. We are going to copy this as well.
- LoadAcrobatPlugins();
- LoadQuicktimePlugins();
- LoadWindowsMediaPlugins();
+ GetAcrobatDirectory(&directories_to_scan);
+ GetQuicktimeDirectory(&directories_to_scan);
+ GetWindowsMediaDirectory(&directories_to_scan);
+
+ for (std::set<FilePath>::const_iterator iter = directories_to_scan.begin();
+ iter != directories_to_scan.end(); ++iter) {
+ LoadPluginsFromDir(*iter);
+ }
if (webkit_glue::IsDefaultPluginEnabled()) {
WebPluginInfo info;
if (PluginLib::ReadWebPluginInfo(FilePath(kDefaultPluginLibraryName),
&info)) {
- plugins_[WideToUTF8(kDefaultPluginLibraryName)] = info;
+ plugins_.push_back(info);
}
}
@@ -131,7 +138,7 @@ void PluginList::LoadPlugins(bool refresh) {
DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms.";
}
-void PluginList::LoadPlugins(const FilePath &path) {
+void PluginList::LoadPluginsFromDir(const FilePath &path) {
WIN32_FIND_DATA find_file_data;
HANDLE find_handle;
@@ -179,16 +186,15 @@ void PluginList::LoadPlugin(const FilePath &path) {
if (!PluginLib::ReadWebPluginInfo(path, &plugin_info))
return;
- // Canonicalize names on Windows in case different versions of the plugin
- // have different case in the version string.
- std::string filename_lc = StringToLowerASCII(plugin_info.filename);
- if (!ShouldLoadPlugin(filename_lc))
+ if (!ShouldLoadPlugin(plugin_info.path))
return;
- PluginMap::const_iterator iter = plugins_.find(filename_lc);
- if (iter != plugins_.end() &&
- !IsNewerVersion(iter->second.version, plugin_info.version))
- return; // The loaded version is newer.
+ for (size_t i = 0; i < plugins_.size(); ++i) {
+ if (plugins_[i].path.BaseName() == path.BaseName() &&
+ !IsNewerVersion(plugins_[i].version, plugin_info.version)) {
+ return; // The loaded version is newer.
+ }
+ }
for (size_t i = 0; i < plugin_info.mime_types.size(); ++i) {
// TODO: don't load global handlers for now.
@@ -198,17 +204,18 @@ void PluginList::LoadPlugin(const FilePath &path) {
if (mime_type == "*" ) {
#ifndef NDEBUG
// Make an exception for NPSPY.
- if (filename_lc == "npspy.dll")
+ if (path.BaseName().value() == L"npspy.dll")
break;
#endif
return;
}
}
- plugins_[filename_lc] = plugin_info;
+ plugins_.push_back(plugin_info);
}
-bool PluginList::ShouldLoadPlugin(const std::string& filename) {
+bool PluginList::ShouldLoadPlugin(const FilePath& path) {
+ std::wstring filename = StringToLowerASCII(path.BaseName().value());
// Depends on XPCOM.
if (filename == kMozillaActiveXPlugin)
return false;
@@ -229,11 +236,17 @@ bool PluginList::ShouldLoadPlugin(const std::string& filename) {
if (dont_load_new_wmp_)
return false;
- if (plugins_.find(kOldWMPPlugin) != plugins_.end())
- plugins_.erase(kOldWMPPlugin);
+ for (size_t i = 0; i < plugins_.size(); ++i) {
+ if (plugins_[i].path.BaseName().value() == kOldWMPPlugin) {
+ plugins_.erase(plugins_.begin() + i);
+ break;
+ }
+ }
} else if (filename == kOldWMPPlugin) {
- if (plugins_.find(kOldWMPPlugin) != plugins_.end())
- return false;
+ for (size_t i = 0; i < plugins_.size(); ++i) {
+ if (plugins_[i].path.BaseName().value() == kNewWMPPlugin)
+ return false;
+ }
}
}
@@ -247,12 +260,12 @@ void PluginList::LoadInternalPlugins() {
WebPluginInfo info;
if (PluginLib::ReadWebPluginInfo(FilePath(kActiveXShimFileName),
&info)) {
- plugins_[WideToUTF8(kActiveXShimFileName)] = info;
+ plugins_.push_back(info);
}
if (PluginLib::ReadWebPluginInfo(FilePath(kActivexShimFileNameForMediaPlayer),
&info)) {
- plugins_[WideToUTF8(kActivexShimFileNameForMediaPlayer)] = info;
+ plugins_.push_back(info);
}
}
@@ -262,32 +275,19 @@ bool PluginList::FindPlugin(const std::string& mime_type,
WebPluginInfo* info) {
DCHECK(mime_type == StringToLowerASCII(mime_type));
- PluginMap::const_iterator default_iter = plugins_.end();
- for (PluginMap::const_iterator iter = plugins_.begin();
- iter != plugins_.end(); ++iter) {
- if (SupportsType(iter->second, mime_type, allow_wildcard)) {
- if (iter->second.path.value() == kDefaultPluginLibraryName) {
- // Only use the default plugin if it's the only one that's found.
- default_iter = iter;
- continue;
- }
-
- if (!clsid.empty() && iter->second.path.value() == kActiveXShimFileName) {
+ for (size_t i = 0; i < plugins_.size(); ++i) {
+ if (SupportsType(plugins_[i], mime_type, allow_wildcard)) {
+ if (!clsid.empty() && plugins_[i].path.value() == kActiveXShimFileName) {
// Special handling for ActiveX shim. If ActiveX is not installed, we
// should use the default plugin to show the installation UI.
if (!activex_shim::IsActiveXInstalled(clsid))
continue;
}
- *info = iter->second;
+ *info = plugins_[i];
return true;
}
}
- if (default_iter != plugins_.end()) {
- *info = default_iter->second;
- return true;
- }
-
return false;
}
@@ -301,10 +301,9 @@ bool PluginList::FindPlugin(const GURL &url, std::string* actual_mime_type,
std::string extension =
StringToLowerASCII(base::SysWideToNativeMB(extension_wide));
- for (PluginMap::const_iterator iter = plugins_.begin();
- iter != plugins_.end(); ++iter) {
- if (SupportsExtension(iter->second, extension, actual_mime_type)) {
- *info = iter->second;
+ for (size_t i = 0; i < plugins_.size(); ++i) {
+ if (SupportsExtension(plugins_[i], extension, actual_mime_type)) {
+ *info = plugins_[i];
return true;
}
}
@@ -353,12 +352,7 @@ bool PluginList::GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) {
if (refresh)
LoadPlugins(true);
- int i = 0;
- plugins->resize(plugins_.size());
- for (PluginMap::const_iterator iter = plugins_.begin();
- iter != plugins_.end(); ++iter) {
- (*plugins)[i++] = iter->second;
- }
+ *plugins = plugins_;
return true;
}
@@ -384,10 +378,9 @@ bool PluginList::GetPluginInfo(const GURL& url,
bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path,
WebPluginInfo* info) {
- for (PluginMap::const_iterator iter = plugins_.begin();
- iter != plugins_.end(); ++iter) {
- if (iter->second.path == plugin_path) {
- *info = iter->second;
+ for (size_t i = 0; i < plugins_.size(); ++i) {
+ if (plugins_[i].path == plugin_path) {
+ *info = plugins_[i];
return true;
}
}
@@ -399,22 +392,24 @@ void PluginList::Shutdown() {
// TODO
}
-FilePath PluginList::GetPluginAppDirectory() {
+void PluginList::GetAppDirectory(std::set<FilePath>* plugin_dirs) {
std::wstring app_path;
// TODO(avi): use PathService directly
- if (webkit_glue::GetApplicationDirectory(&app_path))
- app_path.append(L"\\plugins");
+ if (!webkit_glue::GetApplicationDirectory(&app_path))
+ return;
- return FilePath(app_path);
+ app_path.append(L"\\plugins");
+ plugin_dirs->insert(FilePath(app_path));
}
-FilePath PluginList::GetPluginExeDirectory() {
+void PluginList::GetExeDirectory(std::set<FilePath>* plugin_dirs) {
std::wstring exe_path;
// TODO(avi): use PathService directly
- if (webkit_glue::GetExeDirectory(&exe_path))
- exe_path.append(L"\\plugins");
+ if (!webkit_glue::GetExeDirectory(&exe_path))
+ return;
- return FilePath(exe_path);
+ exe_path.append(L"\\plugins");
+ plugin_dirs->insert(FilePath(exe_path));
}
// Gets the installed path for a registered app.
@@ -448,51 +443,48 @@ static void GetFirefoxInstalledPaths(std::vector<FilePath>* out) {
}
}
-void PluginList::LoadFirefoxPlugins() {
+void PluginList::GetFirefoxDirectory(std::set<FilePath>* plugin_dirs) {
std::vector<FilePath> paths;
GetFirefoxInstalledPaths(&paths);
for (unsigned int i = 0; i < paths.size(); ++i) {
- FilePath path = paths[i].Append(L"plugins");
- LoadPlugins(path);
+ plugin_dirs->insert(paths[i].Append(L"plugins"));
}
- LoadPluginsInRegistryFolder(HKEY_CURRENT_USER, kRegistryMozillaPlugins);
- LoadPluginsInRegistryFolder(HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins);
+ GetPluginsInRegistryDirectory(
+ HKEY_CURRENT_USER, kRegistryMozillaPlugins, plugin_dirs);
+ GetPluginsInRegistryDirectory(
+ HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, plugin_dirs);
std::wstring firefox_app_data_plugin_path;
if (PathService::Get(base::DIR_APP_DATA, &firefox_app_data_plugin_path)) {
firefox_app_data_plugin_path += L"\\Mozilla\\plugins";
- LoadPlugins(FilePath(firefox_app_data_plugin_path));
+ plugin_dirs->insert(FilePath(firefox_app_data_plugin_path));
}
}
-void PluginList::LoadAcrobatPlugins() {
+void PluginList::GetAcrobatDirectory(std::set<FilePath>* plugin_dirs) {
FilePath path;
if (!GetInstalledPath(kRegistryAcrobatReader, &path) &&
!GetInstalledPath(kRegistryAcrobat, &path)) {
return;
}
- path = path.Append(L"Browser");
- LoadPlugins(path);
+ plugin_dirs->insert(path.Append(L"Browser"));
}
-void PluginList::LoadQuicktimePlugins() {
+void PluginList::GetQuicktimeDirectory(std::set<FilePath>* plugin_dirs) {
FilePath path;
- if (GetInstalledPath(kRegistryQuickTime, &path)) {
- path = path.Append(L"plugins");
- LoadPlugins(path);
- }
+ if (GetInstalledPath(kRegistryQuickTime, &path))
+ plugin_dirs->insert(path.Append(L"plugins"));
}
-void PluginList::LoadWindowsMediaPlugins() {
+void PluginList::GetWindowsMediaDirectory(std::set<FilePath>* plugin_dirs) {
FilePath path;
- if (GetInstalledPath(kRegistryWindowsMedia, &path)) {
- LoadPlugins(path);
- }
+ if (GetInstalledPath(kRegistryWindowsMedia, &path))
+ plugin_dirs->insert(path);
}
-void PluginList::LoadJavaPlugin() {
+void PluginList::GetJavaDirectory(std::set<FilePath>* plugin_dirs) {
// Load the new NPAPI Java plugin
// 1. Open the main JRE key under HKLM
RegKey java_key(HKEY_LOCAL_MACHINE, kRegistryJava, KEY_QUERY_VALUE);
@@ -517,14 +509,15 @@ void PluginList::LoadJavaPlugin() {
// 5. We don't know the exact name of the DLL but it's in the form
// NP*.dll so just invoke LoadPlugins on this path.
- LoadPlugins(FilePath(java_plugin_directory));
+ plugin_dirs->insert(FilePath(java_plugin_directory));
}
}
}
-void PluginList::LoadPluginsInRegistryFolder(
+void PluginList::GetPluginsInRegistryDirectory(
HKEY root_key,
- const std::wstring& registry_folder) {
+ const std::wstring& registry_folder,
+ std::set<FilePath>* plugin_dirs) {
for (RegistryKeyIterator iter(root_key, registry_folder.c_str());
iter.Valid(); ++iter) {
// Use the registry to gather plugin across the file system.
@@ -535,7 +528,7 @@ void PluginList::LoadPluginsInRegistryFolder(
std::wstring path;
if (key.ReadValue(kRegistryPath, &path))
- LoadPlugin(FilePath(path));
+ plugin_dirs->insert(FilePath(path).DirName());
}
}
diff --git a/webkit/glue/plugins/plugin_list.h b/webkit/glue/plugins/plugin_list.h
index 6bb33aa..0b3eba2 100644
--- a/webkit/glue/plugins/plugin_list.h
+++ b/webkit/glue/plugins/plugin_list.h
@@ -7,10 +7,11 @@
#ifndef WEBKIT_GLUE_PLUGIN_PLUGIN_LIST_H__
#define WEBKIT_GLUE_PLUGIN_PLUGIN_LIST_H__
+#include <set>
#include <string>
+#include <vector>
#include "base/basictypes.h"
-#include "base/hash_tables.h"
#include "base/ref_counted.h"
#include "webkit/glue/webplugin.h"
@@ -87,13 +88,13 @@ class PluginList : public base::RefCounted<PluginList> {
void LoadPlugins(bool refresh);
// Load all plugins from a specific directory
- void LoadPlugins(const FilePath& path);
+ void LoadPluginsFromDir(const FilePath& path);
// Load a specific plugin with full path.
void LoadPlugin(const FilePath& filename);
// Returns true if we should load the given plugin, or false otherwise.
- bool ShouldLoadPlugin(const std::string& filename);
+ bool ShouldLoadPlugin(const FilePath& path);
// Load internal plugins. Right now there is only one: activex_shim.
void LoadInternalPlugins();
@@ -129,33 +130,34 @@ class PluginList : public base::RefCounted<PluginList> {
std::string* actual_mime_type);
// The application path where we expect to find plugins.
- static FilePath GetPluginAppDirectory();
+ static void GetAppDirectory(std::set<FilePath>* plugin_dirs);
// The executable path where we expect to find plugins.
- static FilePath GetPluginExeDirectory();
+ static void GetExeDirectory(std::set<FilePath>* plugin_dirs);
- // Load plugins from the Firefox install path. This is kind of
- // a kludge, but it helps us locate the flash player for users that
+ // Get plugin directory locations from the Firefox install path. This is kind
+ // of a kludge, but it helps us locate the flash player for users that
// already have it for firefox. Not having to download yet-another-plugin
// is a good thing.
- void LoadFirefoxPlugins();
+ void GetFirefoxDirectory(std::set<FilePath>* plugin_dirs);
- // Hardcoded logic to detect and load acrobat plugins
- void LoadAcrobatPlugins();
+ // Hardcoded logic to detect Acrobat plugins locations.
+ void GetAcrobatDirectory(std::set<FilePath>* plugin_dirs);
- // Hardcoded logic to detect and load quicktime plugins
- void LoadQuicktimePlugins();
+ // Hardcoded logic to detect QuickTime plugin location.
+ void GetQuicktimeDirectory(std::set<FilePath>* plugin_dirs);
- // Hardcoded logic to detect and load Windows Media Player plugins
- void LoadWindowsMediaPlugins();
+ // Hardcoded logic to detect Windows Media Player plugin location.
+ void GetWindowsMediaDirectory(std::set<FilePath>* plugin_dirs);
- // Hardcoded logic to detect and load Java plugins
- void LoadJavaPlugin();
+ // Hardcoded logic to detect Java plugin location.
+ void GetJavaDirectory(std::set<FilePath>* plugin_dirs);
#if defined(OS_WIN)
- // Search the registry at the given path and load plugins listed there.
- void LoadPluginsInRegistryFolder(HKEY root_key,
- const std::wstring& registry_folder);
+ // Search the registry at the given path and detect plugin directories.
+ void GetPluginsInRegistryDirectory(HKEY root_key,
+ const std::wstring& registry_folder,
+ std::set<FilePath>* plugin_dirs);
#endif
// true if we shouldn't load the new WMP plugin.
@@ -166,9 +168,8 @@ class PluginList : public base::RefCounted<PluginList> {
static scoped_refptr<PluginList> singleton_;
bool plugins_loaded_;
- // Maps from the name of the plugin file (NOT path) to WebPluginInfo.
- typedef base::hash_map<std::string, WebPluginInfo> PluginMap;
- PluginMap plugins_;
+ // Contains information about the available plugins.
+ std::vector<WebPluginInfo> plugins_;
DISALLOW_EVIL_CONSTRUCTORS(PluginList);
};
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index 9819132..c379a16 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -145,7 +145,8 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
memset(&window_, 0, sizeof(window_));
const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info();
- std::string filename = StringToLowerASCII(plugin_info.filename);
+ std::string filename =
+ WideToASCII(StringToLowerASCII(plugin_info.path.BaseName().value()));
if (instance_->mime_type() == "application/x-shockwave-flash" ||
filename == "npswf32.dll") {
diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h
index a0ac200..8354e7d 100644
--- a/webkit/glue/webplugin.h
+++ b/webkit/glue/webplugin.h
@@ -39,11 +39,6 @@ struct WebPluginInfo {
// The name of the plugin (i.e. Flash).
std::wstring name;
- // The UTF8 filename of the plugin, without the path. This may be in a
- // different case than FilePath on some systems. On Windows this comes from
- // the DLL's version information.
- std::string filename;
-
// The path to the plugin file (DLL/bundle/library).
FilePath path;