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