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

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: fix up some tests Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/google/google_util.cc
diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc
index 4f7b0301e5a8ae992c9aa649e332510188387f90..cfaa7799393a92dddf28b0062e48d0584e43a345 100644
--- a/chrome/browser/google/google_util.cc
+++ b/chrome/browser/google/google_util.cc
@@ -198,15 +198,18 @@ 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);
- return original_url.is_valid() && original_url.port().empty() &&
+ return original_url.is_valid() &&
+ (original_url.port().empty() || port_permission == ALLOW_ALL_PORTS) &&
(original_url.SchemeIs("http") || original_url.SchemeIs("https")) &&
- google_util::IsGoogleHostname(original_url.host(), permission);
+ 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))
@@ -214,7 +217,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.");
}
@@ -223,7 +226,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, ALLOW_STANDARD_PORTS))
return false;
// Make sure the path is a known home page path.
@@ -240,7 +243,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, ALLOW_STANDARD_PORTS))
return false;
// Make sure the path is a known search path.

Powered by Google App Engine
This is Rietveld 408576698