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

Unified Diff: chrome/browser/google/google_util.cc

Issue 10908028: Allow the X-Chrome-Variations header to transmit to all ports. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/google/google_util.h ('k') | chrome/browser/google/google_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google/google_util.cc
diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc
index 16153c92d81f6d5898a3e8f649908274450edf1f..013437ec00a71f0e88795690e6a3e22d8578bf56 100644
--- a/chrome/browser/google/google_util.cc
+++ b/chrome/browser/google/google_util.cc
@@ -198,7 +198,9 @@ string16 GetSearchTermsFromGoogleSearchURL(const std::string& url) {
return string16();
}
-bool IsGoogleDomainUrl(const std::string& url, SubdomainPermission permission) {
+bool IsGoogleDomainUrl(const std::string& url,
+ SubdomainPermission subdomain_permission,
+ PortPermission port_permission) {
GURL original_url(url);
if (!original_url.is_valid() ||
!(original_url.SchemeIs("http") || original_url.SchemeIs("https")))
@@ -215,12 +217,13 @@ bool IsGoogleDomainUrl(const std::string& url, SubdomainPermission permission) {
return true;
}
- return original_url.port().empty() &&
- google_util::IsGoogleHostname(original_url.host(), permission);
+ return (original_url.port().empty() ||
+ port_permission == ALLOW_NON_STANDARD_PORTS) &&
+ google_util::IsGoogleHostname(original_url.host(), subdomain_permission);
}
bool IsGoogleHostname(const std::string& host,
- SubdomainPermission permission) {
+ SubdomainPermission subdomain_permission) {
size_t tld_length =
net::RegistryControlledDomainService::GetRegistryLength(host, false);
if ((tld_length == 0) || (tld_length == std::string::npos))
@@ -228,7 +231,7 @@ bool IsGoogleHostname(const std::string& host,
std::string host_minus_tld(host, 0, host.length() - tld_length);
if (LowerCaseEqualsASCII(host_minus_tld, "google."))
return true;
- if (permission == ALLOW_SUBDOMAIN)
+ if (subdomain_permission == ALLOW_SUBDOMAIN)
return EndsWith(host_minus_tld, ".google.", false);
return LowerCaseEqualsASCII(host_minus_tld, "www.google.");
}
@@ -237,7 +240,7 @@ bool IsGoogleHomePageUrl(const std::string& url) {
GURL original_url(url);
// First check to see if this has a Google domain.
- if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN))
+ if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, DISALLOW_NON_STANDARD_PORTS))
return false;
// Make sure the path is a known home page path.
@@ -254,7 +257,7 @@ bool IsGoogleSearchUrl(const std::string& url) {
GURL original_url(url);
// First check to see if this has a Google domain.
- if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN))
+ if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, DISALLOW_NON_STANDARD_PORTS))
return false;
// Make sure the path is a known search path.
« no previous file with comments | « chrome/browser/google/google_util.h ('k') | chrome/browser/google/google_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698