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

Unified Diff: chrome/browser/plugins/plugin_metadata.cc

Issue 11016005: Using MIME types in addition to plugin name to differentiate between plugins. (Closed) Base URL: http://git.chromium.org/chromium/src.git@5_plugins_resource_service
Patch Set: .. Created 8 years, 3 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
Index: chrome/browser/plugins/plugin_metadata.cc
diff --git a/chrome/browser/plugins/plugin_metadata.cc b/chrome/browser/plugins/plugin_metadata.cc
index 5013c7f173401114be3753373d115038778ea23b..575328dc90f0d4a1279642203eea2659941843d1 100644
--- a/chrome/browser/plugins/plugin_metadata.cc
+++ b/chrome/browser/plugins/plugin_metadata.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/plugins/plugin_metadata.h"
#include "base/logging.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "webkit/plugins/npapi/plugin_utils.h"
#include "webkit/plugins/webplugininfo.h"
@@ -23,13 +25,15 @@ PluginMetadata::PluginMetadata(const std::string& identifier,
bool url_for_display,
const GURL& plugin_url,
const GURL& help_url,
- const string16& group_name_matcher)
+ const string16& group_name_matcher,
+ const std::string& language)
: identifier_(identifier),
name_(name),
group_name_matcher_(group_name_matcher),
url_for_display_(url_for_display),
plugin_url_(plugin_url),
- help_url_(help_url) {
+ help_url_(help_url),
+ language_(language) {
}
PluginMetadata::~PluginMetadata() {
@@ -41,7 +45,33 @@ void PluginMetadata::AddVersion(const Version& version,
versions_[version] = status;
}
-bool PluginMetadata::MatchesPlugin(const webkit::WebPluginInfo& plugin) {
+void PluginMetadata::AddMimeType(const std::string& mime_type,
+ bool use_in_matching) {
+ all_mime_types_.push_back(mime_type);
+ if (use_in_matching)
+ matching_mime_types_.push_back(mime_type);
+}
+
+bool PluginMetadata::HasMimeType(const std::string& mime_type) const {
+ return std::find(all_mime_types_.begin(), all_mime_types_.end(), mime_type) !=
+ all_mime_types_.end();
+}
+
+bool PluginMetadata::MatchesPlugin(const webkit::WebPluginInfo& plugin,
+ string16* matching_name) {
+ size_t mimetypes_size = plugin.mime_types.size();
+ for (size_t i = 0; i < matching_mime_types_.size(); ++i) {
+ size_t j = 0;
+ for (; j < mimetypes_size; ++j) {
+ if (plugin.mime_types[j].mime_type == matching_mime_types_[i])
+ break;
+ }
+ if (j == mimetypes_size)
+ return false;
+ }
+
+ *matching_name = matching_mime_types_.size() > 0 ?
+ ASCIIToUTF16(JoinString(matching_mime_types_, '+')) : name_;
return plugin.name.find(group_name_matcher_) != string16::npos;
}
@@ -100,7 +130,8 @@ scoped_ptr<PluginMetadata> PluginMetadata::Clone() const {
url_for_display_,
plugin_url_,
help_url_,
- group_name_matcher_);
+ group_name_matcher_,
+ language_);
copy->versions_ = versions_;
return make_scoped_ptr(copy);
}
« no previous file with comments | « chrome/browser/plugins/plugin_metadata.h ('k') | chrome/browser/resources/plugin_metadata/plugins_linux.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698