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

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

Issue 18119005: Misc. cleanup: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/google/google_util.cc
===================================================================
--- chrome/browser/google/google_util.cc (revision 209004)
+++ chrome/browser/google/google_util.cc (working copy)
@@ -152,14 +152,6 @@
#endif
-bool IsGoogleDomainUrl(const GURL& url,
- SubdomainPermission subdomain_permission,
- PortPermission port_permission) {
- return url.is_valid() && (url.SchemeIs("http") || url.SchemeIs("https")) &&
- (url.port().empty() || (port_permission == ALLOW_NON_STANDARD_PORTS)) &&
- google_util::IsGoogleHostname(url.host(), subdomain_permission);
-}
-
bool IsGoogleHostname(const std::string& host,
SubdomainPermission subdomain_permission) {
size_t tld_length = net::registry_controlled_domains::GetRegistryLength(
@@ -176,6 +168,14 @@
return LowerCaseEqualsASCII(host_minus_tld, "www.google.");
}
+bool IsGoogleDomainUrl(const GURL& url,
+ SubdomainPermission subdomain_permission,
+ PortPermission port_permission) {
+ return url.is_valid() && (url.SchemeIs("http") || url.SchemeIs("https")) &&
+ (url.port().empty() || (port_permission == ALLOW_NON_STANDARD_PORTS)) &&
+ google_util::IsGoogleHostname(url.host(), subdomain_permission);
+}
+
bool IsGoogleHomePageUrl(const GURL& url) {
// First check to see if this has a Google domain.
if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, DISALLOW_NON_STANDARD_PORTS))
@@ -183,12 +183,8 @@
// Make sure the path is a known home page path.
std::string path(url.path());
- if (path != "/" && path != "/webhp" &&
- !StartsWithASCII(path, "/ig", false)) {
- return false;
- }
-
- return true;
+ return (path == "/") || (path == "/webhp") ||
+ StartsWithASCII(path, "/ig", false);
}
bool IsGoogleSearchUrl(const GURL& url) {
@@ -198,25 +194,14 @@
// Make sure the path is a known search path.
std::string path(url.path());
- bool has_valid_path = false;
- bool is_home_page_base = false;
- if (path == "/search") {
- has_valid_path = true;
- } else if (path == "/webhp" || path == "/") {
- // Note that we allow both "/" and "" paths, but GURL spits them
- // both out as just "/".
- has_valid_path = true;
- is_home_page_base = true;
- }
- if (!has_valid_path)
+ bool is_home_page_base = (path == "/webhp") || (path == "/");
Jered 2013/06/28 21:57:28 nit: You could extract a helper function and call
Peter Kasting 2013/06/28 22:16:02 Done.
+ if (!is_home_page_base && (path != "/search"))
return false;
// Check for query parameter in URL parameter and hash fragment, depending on
// the path type.
- std::string query(url.query());
- std::string ref(url.ref());
- return HasGoogleSearchQueryParam(ref) ||
- (!is_home_page_base && HasGoogleSearchQueryParam(query));
+ return HasGoogleSearchQueryParam(url.ref()) ||
+ (!is_home_page_base && HasGoogleSearchQueryParam(url.query()));
}
bool IsOrganic(const std::string& brand) {

Powered by Google App Engine
This is Rietveld 408576698