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

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

Issue 1282363003: Convert remaining StringToLowerASCII to ToLowerASCII (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
« 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 = base::StringToLowerASCII(request.host); 78 std::string lhost = base::ToLowerASCII(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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 // Return an error if address is specified for permissions that don't 160 // Return an error if address is specified for permissions that don't
161 // need it (such as 'resolve-host'). 161 // need it (such as 'resolve-host').
162 if (!result.IsAddressBoundType()) 162 if (!result.IsAddressBoundType())
163 return false; 163 return false;
164 164
165 result.pattern_.host = pattern_tokens[0]; 165 result.pattern_.host = pattern_tokens[0];
166 if (!result.pattern_.host.empty()) { 166 if (!result.pattern_.host.empty()) {
167 if (StartsOrEndsWithWhitespace(result.pattern_.host)) 167 if (StartsOrEndsWithWhitespace(result.pattern_.host))
168 return false; 168 return false;
169 result.pattern_.host = base::StringToLowerASCII(result.pattern_.host); 169 result.pattern_.host = base::ToLowerASCII(result.pattern_.host);
170 170
171 // The first component can optionally be '*' to match all subdomains. 171 // The first component can optionally be '*' to match all subdomains.
172 std::vector<std::string> host_components = 172 std::vector<std::string> host_components =
173 base::SplitString(result.pattern_.host, std::string(1, kDot), 173 base::SplitString(result.pattern_.host, std::string(1, kDot),
174 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 174 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
175 DCHECK(!host_components.empty()); 175 DCHECK(!host_components.empty());
176 176
177 if (host_components[0] == kWildcard || host_components[0].empty()) { 177 if (host_components[0] == kWildcard || host_components[0].empty()) {
178 host_components.erase(host_components.begin(), 178 host_components.erase(host_components.begin(),
179 host_components.begin() + 1); 179 host_components.begin() + 1);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 217
218 if (pattern_.port == kWildcardPortNumber) 218 if (pattern_.port == kWildcardPortNumber)
219 result.append(1, kColon).append(kWildcard); 219 result.append(1, kColon).append(kWildcard);
220 else 220 else
221 result.append(1, kColon).append(base::IntToString(pattern_.port)); 221 result.append(1, kColon).append(base::IntToString(pattern_.port));
222 222
223 return result; 223 return result;
224 } 224 }
225 225
226 } // namespace extensions 226 } // 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