| 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 // Some Google related utility functions. | 5 // Some Google related utility functions. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ | 7 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ |
| 8 #define CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ | 8 #define CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // need to restrict some behavior to only happen on Google's officially-owned | 54 // need to restrict some behavior to only happen on Google's officially-owned |
| 55 // domains, use TransportSecurityState::IsGooglePinnedProperty() instead. | 55 // domains, use TransportSecurityState::IsGooglePinnedProperty() instead. |
| 56 | 56 |
| 57 // Designate whether or not a URL checking function also checks for specific | 57 // Designate whether or not a URL checking function also checks for specific |
| 58 // subdomains, or only "www" and empty subdomains. | 58 // subdomains, or only "www" and empty subdomains. |
| 59 enum SubdomainPermission { | 59 enum SubdomainPermission { |
| 60 ALLOW_SUBDOMAIN, | 60 ALLOW_SUBDOMAIN, |
| 61 DISALLOW_SUBDOMAIN, | 61 DISALLOW_SUBDOMAIN, |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 // True if |url| is an HTTP[S] request with host "[www.]google.<TLD>" and no | 64 // Designate whether or not a URL checking function also checks for standard |
| 65 // explicit port. If |permission| is ALLOW_SUBDOMAIN, we check against host | 65 // ports (80 for http, 443 for https), or if it allows all port numbers. |
| 66 enum PortPermission { |
| 67 ALLOW_NON_STANDARD_PORTS, |
| 68 DISALLOW_NON_STANDARD_PORTS, |
| 69 }; |
| 70 |
| 71 // True if |url| is an HTTP[S] request with host "[www.]google.<TLD>". If |
| 72 // |subdomain_permission| is ALLOW_SUBDOMAIN, this checks against host |
| 73 // "*.google.<TLD>" instead. If |port_permission| is ALLOW_NON_STANDARD_PORTS, |
| 74 // this also allows ports other than 80 for http or 443 for https. |
| 75 bool IsGoogleDomainUrl(const std::string& url, |
| 76 SubdomainPermission subdomain_permission, |
| 77 PortPermission port_permission); |
| 78 // True if |host| is "[www.]google.<TLD>" with a valid TLD. If |
| 79 // |subdomain_permission| is ALLOW_SUBDOMAIN, we check against host |
| 66 // "*.google.<TLD>" instead. | 80 // "*.google.<TLD>" instead. |
| 67 bool IsGoogleDomainUrl(const std::string& url, SubdomainPermission permission); | 81 bool IsGoogleHostname(const std::string& host, |
| 68 // True if |host| is "[www.]google.<TLD>" with a valid TLD. If | 82 SubdomainPermission subdomain_permission); |
| 69 // |permission| is ALLOW_SUBDOMAIN, we check against host "*.google.<TLD>" | |
| 70 // instead. | |
| 71 bool IsGoogleHostname(const std::string& host, SubdomainPermission permission); | |
| 72 // True if |url| represents a valid Google home page URL. | 83 // True if |url| represents a valid Google home page URL. |
| 73 bool IsGoogleHomePageUrl(const std::string& url); | 84 bool IsGoogleHomePageUrl(const std::string& url); |
| 74 // True if |url| represents a valid Google search URL. | 85 // True if |url| represents a valid Google search URL. |
| 75 bool IsGoogleSearchUrl(const std::string& url); | 86 bool IsGoogleSearchUrl(const std::string& url); |
| 76 // True if |url| represents a valid Google search URL used by the Instant | 87 // True if |url| represents a valid Google search URL used by the Instant |
| 77 // Extended API. | 88 // Extended API. |
| 78 bool IsInstantExtendedAPIGoogleSearchUrl(const std::string& url); | 89 bool IsInstantExtendedAPIGoogleSearchUrl(const std::string& url); |
| 79 | 90 |
| 80 // True if a build is strictly organic, according to its brand code. | 91 // True if a build is strictly organic, according to its brand code. |
| 81 bool IsOrganic(const std::string& brand); | 92 bool IsOrganic(const std::string& brand); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 96 ~BrandForTesting(); | 107 ~BrandForTesting(); |
| 97 | 108 |
| 98 private: | 109 private: |
| 99 std::string brand_; | 110 std::string brand_; |
| 100 DISALLOW_COPY_AND_ASSIGN(BrandForTesting); | 111 DISALLOW_COPY_AND_ASSIGN(BrandForTesting); |
| 101 }; | 112 }; |
| 102 | 113 |
| 103 } // namespace google_util | 114 } // namespace google_util |
| 104 | 115 |
| 105 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ | 116 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ |
| OLD | NEW |