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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "webkit/plugins/npapi/plugin_list.h" |
8 #include "webkit/plugins/npapi/plugin_utils.h" | 9 #include "webkit/plugins/npapi/plugin_utils.h" |
9 #include "webkit/plugins/webplugininfo.h" | 10 #include "webkit/plugins/webplugininfo.h" |
10 | 11 |
11 // static | 12 // static |
12 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader"; | 13 const char PluginMetadata::kAdobeReaderGroupName[] = "Adobe Reader"; |
13 const char PluginMetadata::kJavaGroupName[] = "Java(TM)"; | 14 const char PluginMetadata::kJavaGroupName[] = "Java(TM)"; |
14 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player"; | 15 const char PluginMetadata::kQuickTimeGroupName[] = "QuickTime Player"; |
15 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player"; | 16 const char PluginMetadata::kShockwaveGroupName[] = "Adobe Shockwave Player"; |
16 const char PluginMetadata::kRealPlayerGroupName[] = "RealPlayer"; | 17 const char PluginMetadata::kRealPlayerGroupName[] = "RealPlayer"; |
17 const char PluginMetadata::kSilverlightGroupName[] = "Silverlight"; | 18 const char PluginMetadata::kSilverlightGroupName[] = "Silverlight"; |
18 const char PluginMetadata::kWindowsMediaPlayerGroupName[] = | 19 const char PluginMetadata::kWindowsMediaPlayerGroupName[] = |
19 "Windows Media Player"; | 20 "Windows Media Player"; |
20 | 21 |
21 PluginMetadata::PluginMetadata(const std::string& identifier, | 22 PluginMetadata::PluginMetadata(const std::string& identifier, |
22 const string16& name, | 23 const string16& name, |
23 bool url_for_display, | 24 bool url_for_display, |
24 const GURL& plugin_url, | 25 const GURL& plugin_url, |
25 const GURL& help_url, | 26 const GURL& help_url, |
26 const string16& group_name_matcher) | 27 const string16& group_name_matcher, |
| 28 const std::string& language) |
27 : identifier_(identifier), | 29 : identifier_(identifier), |
28 name_(name), | 30 name_(name), |
29 group_name_matcher_(group_name_matcher), | 31 group_name_matcher_(group_name_matcher), |
30 url_for_display_(url_for_display), | 32 url_for_display_(url_for_display), |
31 plugin_url_(plugin_url), | 33 plugin_url_(plugin_url), |
32 help_url_(help_url) { | 34 help_url_(help_url), |
| 35 language_(language) { |
33 } | 36 } |
34 | 37 |
35 PluginMetadata::~PluginMetadata() { | 38 PluginMetadata::~PluginMetadata() { |
36 } | 39 } |
37 | 40 |
38 void PluginMetadata::AddVersion(const Version& version, | 41 void PluginMetadata::AddVersion(const Version& version, |
39 SecurityStatus status) { | 42 SecurityStatus status) { |
40 DCHECK(versions_.find(version) == versions_.end()); | 43 DCHECK(versions_.find(version) == versions_.end()); |
41 versions_[version] = status; | 44 versions_[version] = status; |
42 } | 45 } |
43 | 46 |
| 47 void PluginMetadata::AddMimeType(const std::string& mime_type) { |
| 48 all_mime_types_.push_back(mime_type); |
| 49 } |
| 50 |
| 51 void PluginMetadata::AddMatchingMimeType(const std::string& mime_type) { |
| 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 |
44 bool PluginMetadata::MatchesPlugin(const webkit::WebPluginInfo& plugin) { | 60 bool PluginMetadata::MatchesPlugin(const webkit::WebPluginInfo& plugin) { |
| 61 using webkit::npapi::PluginList; |
| 62 |
| 63 for (size_t i = 0; i < matching_mime_types_.size(); ++i) { |
| 64 // To have a match, every one of the |matching_mime_types_| |
| 65 // must be handled by the plug-in. |
| 66 if (PluginList::SupportsType(plugin, matching_mime_types_[i], false)) |
| 67 return false; |
| 68 } |
| 69 |
45 return plugin.name.find(group_name_matcher_) != string16::npos; | 70 return plugin.name.find(group_name_matcher_) != string16::npos; |
46 } | 71 } |
47 | 72 |
48 // static | 73 // static |
49 bool PluginMetadata::ParseSecurityStatus( | 74 bool PluginMetadata::ParseSecurityStatus( |
50 const std::string& status_str, | 75 const std::string& status_str, |
51 PluginMetadata::SecurityStatus* status) { | 76 PluginMetadata::SecurityStatus* status) { |
52 if (status_str == "up_to_date") | 77 if (status_str == "up_to_date") |
53 *status = SECURITY_STATUS_UP_TO_DATE; | 78 *status = SECURITY_STATUS_UP_TO_DATE; |
54 else if (status_str == "out_of_date") | 79 else if (status_str == "out_of_date") |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // Keep versions ordered by newest (biggest) first. | 118 // Keep versions ordered by newest (biggest) first. |
94 return lhs.CompareTo(rhs) > 0; | 119 return lhs.CompareTo(rhs) > 0; |
95 } | 120 } |
96 | 121 |
97 scoped_ptr<PluginMetadata> PluginMetadata::Clone() const { | 122 scoped_ptr<PluginMetadata> PluginMetadata::Clone() const { |
98 PluginMetadata* copy = new PluginMetadata(identifier_, | 123 PluginMetadata* copy = new PluginMetadata(identifier_, |
99 name_, | 124 name_, |
100 url_for_display_, | 125 url_for_display_, |
101 plugin_url_, | 126 plugin_url_, |
102 help_url_, | 127 help_url_, |
103 group_name_matcher_); | 128 group_name_matcher_, |
| 129 language_); |
104 copy->versions_ = versions_; | 130 copy->versions_ = versions_; |
105 return make_scoped_ptr(copy); | 131 return make_scoped_ptr(copy); |
106 } | 132 } |
OLD | NEW |