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

Side by Side Diff: components/google/core/browser/google_util.cc

Issue 1172753003: Move LowerCaseEqualsASCII to base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util
Patch Set: Created 5 years, 6 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 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 "components/google/core/browser/google_util.h" 5 #include "components/google/core/browser/google_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 const std::string& domain_in_lower_case, 47 const std::string& domain_in_lower_case,
48 google_util::SubdomainPermission subdomain_permission) { 48 google_util::SubdomainPermission subdomain_permission) {
49 size_t tld_length = net::registry_controlled_domains::GetRegistryLength( 49 size_t tld_length = net::registry_controlled_domains::GetRegistryLength(
50 host, 50 host,
51 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, 51 net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
52 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); 52 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
53 if ((tld_length == 0) || (tld_length == std::string::npos)) 53 if ((tld_length == 0) || (tld_length == std::string::npos))
54 return false; 54 return false;
55 // Removes the tld and the preceding dot. 55 // Removes the tld and the preceding dot.
56 std::string host_minus_tld(host, 0, host.length() - tld_length - 1); 56 std::string host_minus_tld(host, 0, host.length() - tld_length - 1);
57 if (LowerCaseEqualsASCII(host_minus_tld, domain_in_lower_case.c_str())) 57 if (base::LowerCaseEqualsASCII(host_minus_tld, domain_in_lower_case.c_str()))
58 return true; 58 return true;
59 if (subdomain_permission == google_util::ALLOW_SUBDOMAIN) 59 if (subdomain_permission == google_util::ALLOW_SUBDOMAIN)
60 return EndsWith(host_minus_tld, "." + domain_in_lower_case, false); 60 return EndsWith(host_minus_tld, "." + domain_in_lower_case, false);
61 return LowerCaseEqualsASCII(host_minus_tld, 61 return base::LowerCaseEqualsASCII(host_minus_tld,
62 ("www." + domain_in_lower_case).c_str()); 62 ("www." + domain_in_lower_case).c_str());
63 } 63 }
64 64
65 // True if |url| is a valid URL with HTTP or HTTPS scheme. If |port_permission| 65 // True if |url| is a valid URL with HTTP or HTTPS scheme. If |port_permission|
66 // is DISALLOW_NON_STANDARD_PORTS, this also requires |url| to use the standard 66 // is DISALLOW_NON_STANDARD_PORTS, this also requires |url| to use the standard
67 // port for its scheme (80 for HTTP, 443 for HTTPS). 67 // port for its scheme (80 for HTTP, 443 for HTTPS).
68 bool IsValidURL(const GURL& url, google_util::PortPermission port_permission) { 68 bool IsValidURL(const GURL& url, google_util::PortPermission port_permission) {
69 return url.is_valid() && url.SchemeIsHTTPOrHTTPS() && 69 return url.is_valid() && url.SchemeIsHTTPOrHTTPS() &&
70 (url.port().empty() || 70 (url.port().empty() ||
71 (port_permission == google_util::ALLOW_NON_STANDARD_PORTS)); 71 (port_permission == google_util::ALLOW_NON_STANDARD_PORTS));
72 } 72 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 bool IsYoutubeDomainUrl(const GURL& url, 211 bool IsYoutubeDomainUrl(const GURL& url,
212 SubdomainPermission subdomain_permission, 212 SubdomainPermission subdomain_permission,
213 PortPermission port_permission) { 213 PortPermission port_permission) {
214 return IsValidURL(url, port_permission) && 214 return IsValidURL(url, port_permission) &&
215 IsValidHostName(url.host(), "youtube", subdomain_permission); 215 IsValidHostName(url.host(), "youtube", subdomain_permission);
216 } 216 }
217 217
218 } // namespace google_util 218 } // namespace google_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698