OLD | NEW |
---|---|
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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | |
10 #include "webkit/plugins/npapi/plugin_list.h" | 11 #include "webkit/plugins/npapi/plugin_list.h" |
11 #include "webkit/plugins/npapi/plugin_utils.h" | 12 #include "webkit/plugins/npapi/plugin_utils.h" |
12 #include "webkit/plugins/webplugininfo.h" | 13 #include "webkit/plugins/webplugininfo.h" |
13 | 14 |
14 // static | 15 // static |
15 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader"; | 16 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader"; |
16 const char PluginMetadata::kJavaGroupName[] = "Java(TM)"; | 17 const char PluginMetadata::kJavaGroupName[] = "Java(TM)"; |
17 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player"; | 18 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player"; |
18 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player"; | 19 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player"; |
19 const char PluginMetadata::kRealPlayerGroupName[] = "RealPlayer"; | 20 const char PluginMetadata::kRealPlayerGroupName[] = "RealPlayer"; |
20 const char PluginMetadata::kSilverlightGroupName[] = "Silverlight"; | 21 const char PluginMetadata::kSilverlightGroupName[] = "Silverlight"; |
21 const char PluginMetadata::kWindowsMediaPlayerGroupName[] = | 22 const char PluginMetadata::kWindowsMediaPlayerGroupName[] = |
22 "Windows Media Player"; | 23 "Windows Media Player"; |
23 | 24 |
24 PluginMetadata::PluginMetadata(const std::string& identifier, | 25 PluginMetadata::PluginMetadata(const std::string& identifier, |
25 const string16& name, | 26 const string16& name, |
26 bool url_for_display, | 27 bool url_for_display, |
27 const GURL& plugin_url, | 28 const GURL& plugin_url, |
28 const GURL& help_url, | 29 const GURL& help_url, |
29 const string16& group_name_matcher, | 30 const string16& group_name_matcher, |
30 const std::string& language) | 31 const std::string& language, |
32 bool use_pattern_matching) | |
31 : identifier_(identifier), | 33 : identifier_(identifier), |
32 name_(name), | 34 name_(name), |
33 group_name_matcher_(group_name_matcher), | 35 group_name_matcher_(group_name_matcher), |
34 url_for_display_(url_for_display), | 36 url_for_display_(url_for_display), |
35 plugin_url_(plugin_url), | 37 plugin_url_(plugin_url), |
36 help_url_(help_url), | 38 help_url_(help_url), |
37 language_(language) { | 39 language_(language), |
40 use_pattern_matching_(use_pattern_matching) { | |
38 } | 41 } |
39 | 42 |
40 PluginMetadata::~PluginMetadata() { | 43 PluginMetadata::~PluginMetadata() { |
41 } | 44 } |
42 | 45 |
43 void PluginMetadata::AddVersion(const Version& version, | 46 void PluginMetadata::AddVersion(const Version& version, |
44 SecurityStatus status) { | 47 SecurityStatus status) { |
45 DCHECK(versions_.find(version) == versions_.end()); | 48 DCHECK(versions_.find(version) == versions_.end()); |
46 versions_[version] = status; | 49 versions_[version] = status; |
47 } | 50 } |
(...skipping 14 matching lines...) Expand all Loading... | |
62 bool PluginMetadata::MatchesPlugin(const webkit::WebPluginInfo& plugin) { | 65 bool PluginMetadata::MatchesPlugin(const webkit::WebPluginInfo& plugin) { |
63 using webkit::npapi::PluginList; | 66 using webkit::npapi::PluginList; |
64 | 67 |
65 for (size_t i = 0; i < matching_mime_types_.size(); ++i) { | 68 for (size_t i = 0; i < matching_mime_types_.size(); ++i) { |
66 // To have a match, every one of the |matching_mime_types_| | 69 // To have a match, every one of the |matching_mime_types_| |
67 // must be handled by the plug-in. | 70 // must be handled by the plug-in. |
68 if (!PluginList::SupportsType(plugin, matching_mime_types_[i], false)) | 71 if (!PluginList::SupportsType(plugin, matching_mime_types_[i], false)) |
69 return false; | 72 return false; |
70 } | 73 } |
71 | 74 |
72 return plugin.name.find(group_name_matcher_) != string16::npos; | 75 return use_pattern_matching_ ? |
Bernhard Bauer
2012/11/22 18:40:48
Hm, we might be able to keep this a bit simpler by
| |
76 MatchPattern(plugin.name, group_name_matcher_) : | |
77 plugin.name.find(group_name_matcher_) != string16::npos; | |
73 } | 78 } |
74 | 79 |
75 // static | 80 // static |
76 bool PluginMetadata::ParseSecurityStatus( | 81 bool PluginMetadata::ParseSecurityStatus( |
77 const std::string& status_str, | 82 const std::string& status_str, |
78 PluginMetadata::SecurityStatus* status) { | 83 PluginMetadata::SecurityStatus* status) { |
79 if (status_str == "up_to_date") | 84 if (status_str == "up_to_date") |
80 *status = SECURITY_STATUS_UP_TO_DATE; | 85 *status = SECURITY_STATUS_UP_TO_DATE; |
81 else if (status_str == "out_of_date") | 86 else if (status_str == "out_of_date") |
82 *status = SECURITY_STATUS_OUT_OF_DATE; | 87 *status = SECURITY_STATUS_OUT_OF_DATE; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 return lhs.CompareTo(rhs) > 0; | 126 return lhs.CompareTo(rhs) > 0; |
122 } | 127 } |
123 | 128 |
124 scoped_ptr<PluginMetadata> PluginMetadata::Clone() const { | 129 scoped_ptr<PluginMetadata> PluginMetadata::Clone() const { |
125 PluginMetadata* copy = new PluginMetadata(identifier_, | 130 PluginMetadata* copy = new PluginMetadata(identifier_, |
126 name_, | 131 name_, |
127 url_for_display_, | 132 url_for_display_, |
128 plugin_url_, | 133 plugin_url_, |
129 help_url_, | 134 help_url_, |
130 group_name_matcher_, | 135 group_name_matcher_, |
131 language_); | 136 language_, |
137 use_pattern_matching_); | |
132 copy->versions_ = versions_; | 138 copy->versions_ = versions_; |
133 return make_scoped_ptr(copy); | 139 return make_scoped_ptr(copy); |
134 } | 140 } |
OLD | NEW |