Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1381)

Unified Diff: webkit/glue/plugins/plugin_list.cc

Issue 3796011: Merge 62261, 62267, 62265 & 62679... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/552/src/
Patch Set: Created 10 years, 2 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 | « webkit/glue/plugins/plugin_list.h ('k') | webkit/support/webkit_support.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/plugin_list.cc
===================================================================
--- webkit/glue/plugins/plugin_list.cc (revision 62937)
+++ webkit/glue/plugins/plugin_list.cc (working copy)
@@ -307,65 +307,6 @@
plugins->push_back(plugin_info);
}
-bool PluginList::FindPlugin(const std::string& mime_type,
- bool allow_wildcard,
- WebPluginInfo* info) {
- DCHECK(mime_type == StringToLowerASCII(mime_type));
-
- LoadPlugins(false);
- AutoLock lock(lock_);
- for (size_t i = 0; i < plugins_.size(); ++i) {
- if (plugins_[i].enabled &&
- SupportsType(plugins_[i], mime_type, allow_wildcard)) {
- *info = plugins_[i];
- return true;
- }
- }
-
- return false;
-}
-
-bool PluginList::FindDisabledPlugin(const std::string& mime_type,
- bool allow_wildcard,
- WebPluginInfo* info) {
- DCHECK(mime_type == StringToLowerASCII(mime_type));
-
- LoadPlugins(false);
- AutoLock lock(lock_);
- for (size_t i = 0; i < plugins_.size(); ++i) {
- if (!plugins_[i].enabled &&
- SupportsType(plugins_[i], mime_type, allow_wildcard)) {
- *info = plugins_[i];
- return true;
- }
- }
-
- return false;
-}
-
-bool PluginList::FindPlugin(const GURL &url,
- std::string* actual_mime_type,
- WebPluginInfo* info) {
- LoadPlugins(false);
- AutoLock lock(lock_);
- std::string path = url.path();
- std::string::size_type last_dot = path.rfind('.');
- if (last_dot == std::string::npos)
- return false;
-
- std::string extension = StringToLowerASCII(std::string(path, last_dot+1));
-
- for (size_t i = 0; i < plugins_.size(); ++i) {
- if (plugins_[i].enabled &&
- SupportsExtension(plugins_[i], extension, actual_mime_type)) {
- *info = plugins_[i];
- return true;
- }
- }
-
- return false;
-}
-
bool PluginList::SupportsType(const WebPluginInfo& info,
const std::string &mime_type,
bool allow_wildcard) {
@@ -424,20 +365,111 @@
}
}
+void PluginList::GetPluginInfoArray(
+ const GURL& url,
+ const std::string& mime_type,
+ bool allow_wildcard,
+ std::vector<WebPluginInfo>* info,
+ std::vector<std::string>* actual_mime_types) {
+ DCHECK(mime_type == StringToLowerASCII(mime_type));
+ DCHECK(info);
+
+ LoadPlugins(false);
+ AutoLock lock(lock_);
+ info->clear();
+ if (actual_mime_types)
+ actual_mime_types->clear();
+
+ std::set<FilePath> visited_plugins;
+
+ // Add in enabled plugins by mime type.
+ WebPluginInfo default_plugin;
+ for (size_t i = 0; i < plugins_.size(); ++i) {
+ if (plugins_[i].enabled &&
+ SupportsType(plugins_[i], mime_type, allow_wildcard)) {
+ FilePath path = plugins_[i].path;
+ if (path.value() != kDefaultPluginLibraryName &&
+ visited_plugins.insert(path).second) {
+ info->push_back(plugins_[i]);
+ if (actual_mime_types)
+ actual_mime_types->push_back(mime_type);
+ }
+ }
+ }
+
+ // Add in enabled plugins by url.
+ std::string path = url.path();
+ std::string::size_type last_dot = path.rfind('.');
+ if (last_dot != std::string::npos) {
+ std::string extension = StringToLowerASCII(std::string(path, last_dot+1));
+ std::string actual_mime_type;
+ for (size_t i = 0; i < plugins_.size(); ++i) {
+ if (plugins_[i].enabled &&
+ SupportsExtension(plugins_[i], extension, &actual_mime_type)) {
+ FilePath path = plugins_[i].path;
+ if (path.value() != kDefaultPluginLibraryName &&
+ visited_plugins.insert(path).second) {
+ info->push_back(plugins_[i]);
+ if (actual_mime_types)
+ actual_mime_types->push_back(actual_mime_type);
+ }
+ }
+ }
+ }
+
+ // Add in disabled plugins by mime type.
+ for (size_t i = 0; i < plugins_.size(); ++i) {
+ if (!plugins_[i].enabled &&
+ SupportsType(plugins_[i], mime_type, allow_wildcard)) {
+ FilePath path = plugins_[i].path;
+ if (path.value() != kDefaultPluginLibraryName &&
+ visited_plugins.insert(path).second) {
+ info->push_back(plugins_[i]);
+ if (actual_mime_types)
+ actual_mime_types->push_back(mime_type);
+ }
+ }
+ }
+
+ // Add the default plugin at the end if it supports the mime type given,
+ // and the default plugin is enabled.
+ if (!plugins_.empty() && webkit_glue::IsDefaultPluginEnabled()) {
+ const WebPluginInfo& default_info = plugins_.back();
+ if (SupportsType(default_info, mime_type, allow_wildcard)) {
+ info->push_back(default_info);
+ if (actual_mime_types)
+ actual_mime_types->push_back(mime_type);
+ }
+ }
+}
+
bool PluginList::GetPluginInfo(const GURL& url,
const std::string& mime_type,
bool allow_wildcard,
WebPluginInfo* info,
std::string* actual_mime_type) {
- bool found = FindPlugin(mime_type, allow_wildcard, info);
- if (!found || (info->path.value() == kDefaultPluginLibraryName)) {
- if (FindPlugin(url, actual_mime_type, info) ||
- FindDisabledPlugin(mime_type, allow_wildcard, info)) {
- found = true;
+ DCHECK(info);
+ std::vector<WebPluginInfo> info_list;
+
+ // GetPluginInfoArray has slightly less work to do if we can pass
+ // NULL for the mime type list...
+ if (actual_mime_type) {
+ std::vector<std::string> mime_type_list;
+ GetPluginInfoArray(url, mime_type, allow_wildcard, &info_list,
+ &mime_type_list);
+ if (!info_list.empty()) {
+ *info = info_list[0];
+ *actual_mime_type = mime_type_list[0];
+ return true;
}
+ } else {
+ GetPluginInfoArray(url, mime_type, allow_wildcard, &info_list, NULL);
+ if (!info_list.empty()) {
+ *info = info_list[0];
+ return true;
+ }
}
-
- return found;
+ return false;
}
bool PluginList::GetPluginInfoByPath(const FilePath& plugin_path,
« no previous file with comments | « webkit/glue/plugins/plugin_list.h ('k') | webkit/support/webkit_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698