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

Side by Side Diff: extensions/common/permissions/socket_permission_entry.cc

Issue 448853002: Move StringToLowerASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « extensions/common/message_bundle.cc ('k') | google_apis/gaia/gaia_auth_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/common/permissions/socket_permission_entry.h" 5 #include "extensions/common/permissions/socket_permission_entry.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <sstream> 8 #include <sstream>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 (pattern_.host == rhs.pattern_.host) && 68 (pattern_.host == rhs.pattern_.host) &&
69 (match_subdomains_ == rhs.match_subdomains_) && 69 (match_subdomains_ == rhs.match_subdomains_) &&
70 (pattern_.port == rhs.pattern_.port); 70 (pattern_.port == rhs.pattern_.port);
71 } 71 }
72 72
73 bool SocketPermissionEntry::Check( 73 bool SocketPermissionEntry::Check(
74 const content::SocketPermissionRequest& request) const { 74 const content::SocketPermissionRequest& request) const {
75 if (pattern_.type != request.type) 75 if (pattern_.type != request.type)
76 return false; 76 return false;
77 77
78 std::string lhost = StringToLowerASCII(request.host); 78 std::string lhost = base::StringToLowerASCII(request.host);
79 if (pattern_.host != lhost) { 79 if (pattern_.host != lhost) {
80 if (!match_subdomains_) 80 if (!match_subdomains_)
81 return false; 81 return false;
82 82
83 if (!pattern_.host.empty()) { 83 if (!pattern_.host.empty()) {
84 // Do not wildcard part of IP address. 84 // Do not wildcard part of IP address.
85 url::Component component(0, lhost.length()); 85 url::Component component(0, lhost.length());
86 url::RawCanonOutputT<char, 128> ignored_output; 86 url::RawCanonOutputT<char, 128> ignored_output;
87 url::CanonHostInfo host_info; 87 url::CanonHostInfo host_info;
88 url::CanonicalizeIPAddress( 88 url::CanonicalizeIPAddress(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 // Return an error if address is specified for permissions that don't 159 // Return an error if address is specified for permissions that don't
160 // need it (such as 'resolve-host'). 160 // need it (such as 'resolve-host').
161 if (!result.IsAddressBoundType()) 161 if (!result.IsAddressBoundType())
162 return false; 162 return false;
163 163
164 result.pattern_.host = pattern_tokens[0]; 164 result.pattern_.host = pattern_tokens[0];
165 if (!result.pattern_.host.empty()) { 165 if (!result.pattern_.host.empty()) {
166 if (StartsOrEndsWithWhitespace(result.pattern_.host)) 166 if (StartsOrEndsWithWhitespace(result.pattern_.host))
167 return false; 167 return false;
168 result.pattern_.host = StringToLowerASCII(result.pattern_.host); 168 result.pattern_.host = base::StringToLowerASCII(result.pattern_.host);
169 169
170 // The first component can optionally be '*' to match all subdomains. 170 // The first component can optionally be '*' to match all subdomains.
171 std::vector<std::string> host_components; 171 std::vector<std::string> host_components;
172 base::SplitString(result.pattern_.host, kDot, &host_components); 172 base::SplitString(result.pattern_.host, kDot, &host_components);
173 DCHECK(!host_components.empty()); 173 DCHECK(!host_components.empty());
174 174
175 if (host_components[0] == kWildcard || host_components[0].empty()) { 175 if (host_components[0] == kWildcard || host_components[0].empty()) {
176 host_components.erase(host_components.begin(), 176 host_components.erase(host_components.begin(),
177 host_components.begin() + 1); 177 host_components.begin() + 1);
178 } else { 178 } else {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 if (pattern_.port == kWildcardPortNumber) 215 if (pattern_.port == kWildcardPortNumber)
216 result.append(1, kColon).append(kWildcard); 216 result.append(1, kColon).append(kWildcard);
217 else 217 else
218 result.append(1, kColon).append(base::IntToString(pattern_.port)); 218 result.append(1, kColon).append(base::IntToString(pattern_.port));
219 219
220 return result; 220 return result;
221 } 221 }
222 222
223 } // namespace extensions 223 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/message_bundle.cc ('k') | google_apis/gaia/gaia_auth_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698