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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 group_name_matcher_(group_name_matcher), | 38 group_name_matcher_(group_name_matcher), |
39 url_for_display_(url_for_display), | 39 url_for_display_(url_for_display), |
40 plugin_url_(plugin_url), | 40 plugin_url_(plugin_url), |
41 help_url_(help_url), | 41 help_url_(help_url), |
42 language_(language) { | 42 language_(language) { |
43 } | 43 } |
44 | 44 |
45 PluginMetadata::~PluginMetadata() { | 45 PluginMetadata::~PluginMetadata() { |
46 } | 46 } |
47 | 47 |
48 void PluginMetadata::AddVersion(const Version& version, | 48 void PluginMetadata::AddVersion(const base::Version& version, |
49 SecurityStatus status) { | 49 SecurityStatus status) { |
50 DCHECK(versions_.find(version) == versions_.end()); | 50 DCHECK(versions_.find(version) == versions_.end()); |
51 versions_[version] = status; | 51 versions_[version] = status; |
52 } | 52 } |
53 | 53 |
54 void PluginMetadata::AddMimeType(const std::string& mime_type) { | 54 void PluginMetadata::AddMimeType(const std::string& mime_type) { |
55 all_mime_types_.push_back(mime_type); | 55 all_mime_types_.push_back(mime_type); |
56 } | 56 } |
57 | 57 |
58 void PluginMetadata::AddMatchingMimeType(const std::string& mime_type) { | 58 void PluginMetadata::AddMatchingMimeType(const std::string& mime_type) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return true; | 98 return true; |
99 } | 99 } |
100 | 100 |
101 PluginMetadata::SecurityStatus PluginMetadata::GetSecurityStatus( | 101 PluginMetadata::SecurityStatus PluginMetadata::GetSecurityStatus( |
102 const content::WebPluginInfo& plugin) const { | 102 const content::WebPluginInfo& plugin) const { |
103 if (versions_.empty()) { | 103 if (versions_.empty()) { |
104 // Unknown plugins require authorization. | 104 // Unknown plugins require authorization. |
105 return SECURITY_STATUS_REQUIRES_AUTHORIZATION; | 105 return SECURITY_STATUS_REQUIRES_AUTHORIZATION; |
106 } | 106 } |
107 | 107 |
108 Version version; | 108 base::Version version; |
109 content::WebPluginInfo::CreateVersionFromString(plugin.version, &version); | 109 content::WebPluginInfo::CreateVersionFromString(plugin.version, &version); |
110 if (!version.IsValid()) | 110 if (!version.IsValid()) |
111 version = Version("0"); | 111 version = base::Version("0"); |
112 | 112 |
113 // |lower_bound| returns the latest version that is not newer than |version|. | 113 // |lower_bound| returns the latest version that is not newer than |version|. |
114 std::map<Version, SecurityStatus, VersionComparator>::const_iterator it = | 114 std::map<base::Version, SecurityStatus, VersionComparator>::const_iterator |
115 versions_.lower_bound(version); | 115 it = versions_.lower_bound(version); |
116 // If there is at least one version defined, everything older than the oldest | 116 // If there is at least one version defined, everything older than the oldest |
117 // defined version is considered out-of-date. | 117 // defined version is considered out-of-date. |
118 if (it == versions_.end()) | 118 if (it == versions_.end()) |
119 return SECURITY_STATUS_OUT_OF_DATE; | 119 return SECURITY_STATUS_OUT_OF_DATE; |
120 | 120 |
121 return it->second; | 121 return it->second; |
122 } | 122 } |
123 | 123 |
124 bool PluginMetadata::VersionComparator::operator() (const Version& lhs, | 124 bool PluginMetadata::VersionComparator::operator() ( |
125 const Version& rhs) const { | 125 const base::Version& lhs, const base::Version& rhs) const { |
126 // Keep versions ordered by newest (biggest) first. | 126 // Keep versions ordered by newest (biggest) first. |
127 return lhs.CompareTo(rhs) > 0; | 127 return lhs.CompareTo(rhs) > 0; |
128 } | 128 } |
129 | 129 |
130 std::unique_ptr<PluginMetadata> PluginMetadata::Clone() const { | 130 std::unique_ptr<PluginMetadata> PluginMetadata::Clone() const { |
131 PluginMetadata* copy = new PluginMetadata(identifier_, | 131 PluginMetadata* copy = new PluginMetadata(identifier_, |
132 name_, | 132 name_, |
133 url_for_display_, | 133 url_for_display_, |
134 plugin_url_, | 134 plugin_url_, |
135 help_url_, | 135 help_url_, |
136 group_name_matcher_, | 136 group_name_matcher_, |
137 language_); | 137 language_); |
138 copy->versions_ = versions_; | 138 copy->versions_ = versions_; |
139 return base::WrapUnique(copy); | 139 return base::WrapUnique(copy); |
140 } | 140 } |
OLD | NEW |