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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/plugins/plugin_metadata.h" 5 #include "chrome/browser/plugins/plugin_metadata.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h"
8 #include "webkit/plugins/npapi/plugin_utils.h" 10 #include "webkit/plugins/npapi/plugin_utils.h"
9 #include "webkit/plugins/webplugininfo.h" 11 #include "webkit/plugins/webplugininfo.h"
10 12
11 // static 13 // static
12 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader"; 14 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader";
13 const char PluginMetadata::kJavaGroupName[] = "Java(TM)"; 15 const char PluginMetadata::kJavaGroupName[] = "Java(TM)";
14 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player"; 16 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player";
15 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player"; 17 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player";
16 const char PluginMetadata::kRealPlayerGroupName[] = "RealPlayer"; 18 const char PluginMetadata::kRealPlayerGroupName[] = "RealPlayer";
17 const char PluginMetadata::kSilverlightGroupName[] = "Silverlight"; 19 const char PluginMetadata::kSilverlightGroupName[] = "Silverlight";
18 const char PluginMetadata::kWindowsMediaPlayerGroupName[] = 20 const char PluginMetadata::kWindowsMediaPlayerGroupName[] =
19 "Windows Media Player"; 21 "Windows Media Player";
20 22
21 PluginMetadata::PluginMetadata(const std::string& identifier, 23 PluginMetadata::PluginMetadata(const std::string& identifier,
22 const string16& name, 24 const string16& name,
23 bool url_for_display, 25 bool url_for_display,
24 const GURL& plugin_url, 26 const GURL& plugin_url,
25 const GURL& help_url, 27 const GURL& help_url,
26 const string16& group_name_matcher) 28 const string16& group_name_matcher,
29 const std::string& language)
27 : identifier_(identifier), 30 : identifier_(identifier),
28 name_(name), 31 name_(name),
29 group_name_matcher_(group_name_matcher), 32 group_name_matcher_(group_name_matcher),
30 url_for_display_(url_for_display), 33 url_for_display_(url_for_display),
31 plugin_url_(plugin_url), 34 plugin_url_(plugin_url),
32 help_url_(help_url) { 35 help_url_(help_url),
36 language_(language) {
33 } 37 }
34 38
35 PluginMetadata::~PluginMetadata() { 39 PluginMetadata::~PluginMetadata() {
36 } 40 }
37 41
38 void PluginMetadata::AddVersion(const Version& version, 42 void PluginMetadata::AddVersion(const Version& version,
39 SecurityStatus status) { 43 SecurityStatus status) {
40 DCHECK(versions_.find(version) == versions_.end()); 44 DCHECK(versions_.find(version) == versions_.end());
41 versions_[version] = status; 45 versions_[version] = status;
42 } 46 }
43 47
44 bool PluginMetadata::MatchesPlugin(const webkit::WebPluginInfo& plugin) { 48 void PluginMetadata::AddMimeType(const std::string& mime_type,
49 bool use_in_matching) {
50 all_mime_types_.push_back(mime_type);
51 if (use_in_matching)
52 matching_mime_types_.push_back(mime_type);
53 }
54
55 bool PluginMetadata::HasMimeType(const std::string& mime_type) const {
56 return std::find(all_mime_types_.begin(), all_mime_types_.end(), mime_type) !=
57 all_mime_types_.end();
58 }
59
60 bool PluginMetadata::MatchesPlugin(const webkit::WebPluginInfo& plugin,
61 string16* matching_name) {
62 size_t mimetypes_size = plugin.mime_types.size();
63 for (size_t i = 0; i < matching_mime_types_.size(); ++i) {
64 size_t j = 0;
65 for (; j < mimetypes_size; ++j) {
66 if (plugin.mime_types[j].mime_type == matching_mime_types_[i])
67 break;
68 }
69 if (j == mimetypes_size)
70 return false;
71 }
72
73 *matching_name = matching_mime_types_.size() > 0 ?
74 ASCIIToUTF16(JoinString(matching_mime_types_, '+')) : name_;
45 return plugin.name.find(group_name_matcher_) != string16::npos; 75 return plugin.name.find(group_name_matcher_) != string16::npos;
46 } 76 }
47 77
48 // static 78 // static
49 bool PluginMetadata::ParseSecurityStatus( 79 bool PluginMetadata::ParseSecurityStatus(
50 const std::string& status_str, 80 const std::string& status_str,
51 PluginMetadata::SecurityStatus* status) { 81 PluginMetadata::SecurityStatus* status) {
52 if (status_str == "up_to_date") 82 if (status_str == "up_to_date")
53 *status = SECURITY_STATUS_UP_TO_DATE; 83 *status = SECURITY_STATUS_UP_TO_DATE;
54 else if (status_str == "out_of_date") 84 else if (status_str == "out_of_date")
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Keep versions ordered by newest (biggest) first. 123 // Keep versions ordered by newest (biggest) first.
94 return lhs.CompareTo(rhs) > 0; 124 return lhs.CompareTo(rhs) > 0;
95 } 125 }
96 126
97 scoped_ptr<PluginMetadata> PluginMetadata::Clone() const { 127 scoped_ptr<PluginMetadata> PluginMetadata::Clone() const {
98 PluginMetadata* copy = new PluginMetadata(identifier_, 128 PluginMetadata* copy = new PluginMetadata(identifier_,
99 name_, 129 name_,
100 url_for_display_, 130 url_for_display_,
101 plugin_url_, 131 plugin_url_,
102 help_url_, 132 help_url_,
103 group_name_matcher_); 133 group_name_matcher_,
134 language_);
104 copy->versions_ = versions_; 135 copy->versions_ = versions_;
105 return make_scoped_ptr(copy); 136 return make_scoped_ptr(copy);
106 } 137 }
OLDNEW
« 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