Chromium Code Reviews| Index: chrome/browser/google/google_util.cc |
| =================================================================== |
| --- chrome/browser/google/google_util.cc (revision 111693) |
| +++ chrome/browser/google/google_util.cc (working copy) |
| @@ -82,6 +82,42 @@ |
| return AppendParam(url, "sd", google_domain.substr(first_dot + 1)); |
| } |
| +bool IsGoogleHomePageUrl(const std::string& url) { |
|
SteveT
2011/11/28 21:04:49
Nit: Move down to roughly match header order.
Roger Tawa OOO till Jul 10th
2011/11/29 16:00:09
Done.
|
| + GURL original_url(url); |
| + if (!original_url.is_valid()) |
| + return false; |
| + |
| + // Make sure the scheme is valid. |
| + if (!original_url.SchemeIs("http") && !original_url.SchemeIs("https")) |
| + return false; |
| + |
| + // Make sure port is default for the respective scheme. |
| + if (!original_url.port().empty()) |
|
SteveT
2011/11/28 21:04:49
Do we want to allow :80 and :443 for http and http
Roger Tawa OOO till Jul 10th
2011/11/29 16:00:09
GURL does not make it easy to detect default port
|
| + return false; |
| + |
| + // Accept only valid TLD. |
| + size_t tld_length = net::RegistryControlledDomainService::GetRegistryLength( |
| + original_url, false); |
| + if (tld_length == 0 || tld_length == std::string::npos) |
| + return false; |
| + |
| + // We only accept "www.google." in front of the TLD. |
| + std::string host = original_url.host(); |
| + host = host.substr(0, host.length() - tld_length); |
| + if (!LowerCaseEqualsASCII(host, "www.google.")) |
| + return false; |
| + |
| + // Make sure the path is a known home page path. |
| + std::string path(original_url.path()); |
| + if (!LowerCaseEqualsASCII(path, "/") && |
| + !LowerCaseEqualsASCII(path, "/webhp") && |
| + !StartsWithASCII(path, "/ig", false)) { |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| #if defined(OS_WIN) |
| bool GetBrand(std::string* brand) { |