| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/google/google_util.h" | 5 #include "chrome/browser/google/google_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 if (LowerCaseEqualsASCII(host_minus_tld, "google.")) | 179 if (LowerCaseEqualsASCII(host_minus_tld, "google.")) |
| 180 return true; | 180 return true; |
| 181 if (subdomain_permission == ALLOW_SUBDOMAIN) | 181 if (subdomain_permission == ALLOW_SUBDOMAIN) |
| 182 return EndsWith(host_minus_tld, ".google.", false); | 182 return EndsWith(host_minus_tld, ".google.", false); |
| 183 return LowerCaseEqualsASCII(host_minus_tld, "www.google."); | 183 return LowerCaseEqualsASCII(host_minus_tld, "www.google."); |
| 184 } | 184 } |
| 185 | 185 |
| 186 bool IsGoogleDomainUrl(const GURL& url, | 186 bool IsGoogleDomainUrl(const GURL& url, |
| 187 SubdomainPermission subdomain_permission, | 187 SubdomainPermission subdomain_permission, |
| 188 PortPermission port_permission) { | 188 PortPermission port_permission) { |
| 189 return url.is_valid() && (url.SchemeIs("http") || url.SchemeIs("https")) && | 189 return url.is_valid() && url.SchemeIsHttp() && |
| 190 (url.port().empty() || (port_permission == ALLOW_NON_STANDARD_PORTS)) && | 190 (url.port().empty() || (port_permission == ALLOW_NON_STANDARD_PORTS)) && |
| 191 google_util::IsGoogleHostname(url.host(), subdomain_permission); | 191 google_util::IsGoogleHostname(url.host(), subdomain_permission); |
| 192 } | 192 } |
| 193 | 193 |
| 194 bool IsGoogleHomePageUrl(const GURL& url) { | 194 bool IsGoogleHomePageUrl(const GURL& url) { |
| 195 // First check to see if this has a Google domain. | 195 // First check to see if this has a Google domain. |
| 196 if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, DISALLOW_NON_STANDARD_PORTS)) | 196 if (!IsGoogleDomainUrl(url, DISALLOW_SUBDOMAIN, DISALLOW_NON_STANDARD_PORTS)) |
| 197 return false; | 197 return false; |
| 198 | 198 |
| 199 // Make sure the path is a known home page path. | 199 // Make sure the path is a known home page path. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 DCHECK(brand_for_testing == NULL); | 286 DCHECK(brand_for_testing == NULL); |
| 287 brand_for_testing = brand_.c_str(); | 287 brand_for_testing = brand_.c_str(); |
| 288 } | 288 } |
| 289 | 289 |
| 290 BrandForTesting::~BrandForTesting() { | 290 BrandForTesting::~BrandForTesting() { |
| 291 brand_for_testing = NULL; | 291 brand_for_testing = NULL; |
| 292 } | 292 } |
| 293 | 293 |
| 294 | 294 |
| 295 } // namespace google_util | 295 } // namespace google_util |
| OLD | NEW |