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

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

Issue 10108026: Transmit a X-Chrome-UMA-Enabled bit to Google domains from clients that have UMA enabled. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: merge to tot Created 8 years, 8 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 d95b116045a0246ec9d7e3f54b07d9bc7865c328..22b17fc1edae237796b5296a60a9a6490ee8e221 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.
« 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