Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: chrome/browser/plugins/plugin_metadata.cc

Issue 1301883002: Revert of base: Remove using:: declaration from version.h header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 base::Version& version, 45 void PluginMetadata::AddVersion(const 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
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 base::Version version; 103 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 = base::Version("0"); 106 version = 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<base::Version, SecurityStatus, VersionComparator>::const_iterator 109 std::map<Version, SecurityStatus, VersionComparator>::const_iterator it =
110 it = versions_.lower_bound(version); 110 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()( 119 bool PluginMetadata::VersionComparator::operator() (const Version& lhs,
120 const base::Version& lhs, 120 const Version& rhs) const {
121 const base::Version& rhs) const {
122 // Keep versions ordered by newest (biggest) first. 121 // Keep versions ordered by newest (biggest) first.
123 return lhs.CompareTo(rhs) > 0; 122 return lhs.CompareTo(rhs) > 0;
124 } 123 }
125 124
126 scoped_ptr<PluginMetadata> PluginMetadata::Clone() const { 125 scoped_ptr<PluginMetadata> PluginMetadata::Clone() const {
127 PluginMetadata* copy = new PluginMetadata(identifier_, 126 PluginMetadata* copy = new PluginMetadata(identifier_,
128 name_, 127 name_,
129 url_for_display_, 128 url_for_display_,
130 plugin_url_, 129 plugin_url_,
131 help_url_, 130 help_url_,
132 group_name_matcher_, 131 group_name_matcher_,
133 language_); 132 language_);
134 copy->versions_ = versions_; 133 copy->versions_ = versions_;
135 return make_scoped_ptr(copy); 134 return make_scoped_ptr(copy);
136 } 135 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_metadata.h ('k') | chrome/browser/plugins/plugin_metadata_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698