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