summaryrefslogtreecommitdiffstats
path: root/chrome/browser/google/google_util.cc
diff options
context:
space:
mode:
authorstevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-30 22:54:25 +0000
committerstevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-30 22:54:25 +0000
commite34a8641e34b437e2c3295986ebe4522ff42baf9 (patch)
treea9a31bfab42fbfaefc839e53fc6c6382549c959d /chrome/browser/google/google_util.cc
parent4866066dae7ed82bf802d5e6da310f06a570dcd1 (diff)
downloadchromium_src-e34a8641e34b437e2c3295986ebe4522ff42baf9.zip
chromium_src-e34a8641e34b437e2c3295986ebe4522ff42baf9.tar.gz
chromium_src-e34a8641e34b437e2c3295986ebe4522ff42baf9.tar.bz2
Transmit a X-Chrome-UMA-Enabled bit to Google domains from clients that have UMA enabled.
This requires a change to the ChromeNetworkDelegate where we feed the incognito state (a bool) into the object at creation time, so we can check that field when doing our header setting. BUG=123609 TEST=With UMA enabled (not Chromium), visit www.google.com and ensure that the request header includes X-Chrome-UMA-Enabled with value "1". Ensure that disabling UMA also disables the transmission of this header entirely. Also, ensure that unit_tests GoogleUtilTests all pass. TBR=ivankr@chromium.org Review URL: http://codereview.chromium.org/10108026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/google/google_util.cc')
-rw-r--r--chrome/browser/google/google_util.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc
index d95b116..22b17fc 100644
--- a/chrome/browser/google/google_util.cc
+++ b/chrome/browser/google/google_util.cc
@@ -44,13 +44,6 @@ bool HasQueryParameter(const std::string& str) {
return false;
}
-// True if |url| is an HTTP[S] request with host "[www.]google.<TLD>" and no
-// explicit port.
-bool IsGoogleDomainUrl(const GURL& url) {
- return url.is_valid() && (url.SchemeIs("http") || url.SchemeIs("https")) &&
- url.port().empty() && google_util::IsGoogleHostname(url.host());
-}
-
} // anonymous namespace
namespace google_util {
@@ -142,21 +135,32 @@ bool GetReactivationBrand(std::string* brand) {
#endif
-bool IsGoogleHostname(const std::string& host) {
+bool IsGoogleDomainUrl(const std::string& url, SubdomainPermission permission) {
+ GURL original_url(url);
+ return original_url.is_valid() && original_url.port().empty() &&
+ (original_url.SchemeIs("http") || original_url.SchemeIs("https")) &&
+ google_util::IsGoogleHostname(original_url.host(), permission);
+}
+
+bool IsGoogleHostname(const std::string& host,
+ SubdomainPermission permission) {
size_t tld_length =
net::RegistryControlledDomainService::GetRegistryLength(host, false);
if ((tld_length == 0) || (tld_length == std::string::npos))
return false;
std::string host_minus_tld(host, 0, host.length() - tld_length);
- return LowerCaseEqualsASCII(host_minus_tld, "www.google.") ||
- LowerCaseEqualsASCII(host_minus_tld, "google.");
+ if (LowerCaseEqualsASCII(host_minus_tld, "google."))
+ return true;
+ if (permission == ALLOW_SUBDOMAIN)
+ return EndsWith(host_minus_tld, ".google.", false);
+ return LowerCaseEqualsASCII(host_minus_tld, "www.google.");
}
bool IsGoogleHomePageUrl(const std::string& url) {
GURL original_url(url);
// First check to see if this has a Google domain.
- if (!IsGoogleDomainUrl(original_url))
+ if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN))
return false;
// Make sure the path is a known home page path.
@@ -173,7 +177,7 @@ bool IsGoogleSearchUrl(const std::string& url) {
GURL original_url(url);
// First check to see if this has a Google domain.
- if (!IsGoogleDomainUrl(original_url))
+ if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN))
return false;
// Make sure the path is a known search path.