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

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

Issue 1182183003: Move EndsWith to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « components/dom_distiller/core/page_features.cc ('k') | components/omnibox/keyword_provider.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 "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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (base::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 base::EndsWith(host_minus_tld, "." + domain_in_lower_case, false);
61 return base::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() ||
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 210 }
211 211
212 bool IsYoutubeDomainUrl(const GURL& url, 212 bool IsYoutubeDomainUrl(const GURL& url,
213 SubdomainPermission subdomain_permission, 213 SubdomainPermission subdomain_permission,
214 PortPermission port_permission) { 214 PortPermission port_permission) {
215 return IsValidURL(url, port_permission) && 215 return IsValidURL(url, port_permission) &&
216 IsValidHostName(url.host(), "youtube", subdomain_permission); 216 IsValidHostName(url.host(), "youtube", subdomain_permission);
217 } 217 }
218 218
219 } // namespace google_util 219 } // namespace google_util
OLDNEW
« no previous file with comments | « components/dom_distiller/core/page_features.cc ('k') | components/omnibox/keyword_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698