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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 | 13 |
14 class GURL; | 14 class GURL; |
15 | 15 |
16 // This namespace provides various helpers around handling Google-related URLs | 16 // This namespace provides various helpers around handling Google-related URLs. |
17 // and state relating to Google Chrome distributions (such as RLZ). | |
18 namespace google_util { | 17 namespace google_util { |
19 | 18 |
20 // True iff |str| contains a "q=" query parameter with a non-empty value. | 19 // True iff |str| contains a "q=" query parameter with a non-empty value. |
21 // |str| should be a query or a hash fragment, without the ? or # (as | 20 // |str| should be a query or a hash fragment, without the ? or # (as |
22 // returned by GURL::query() or GURL::ref(). | 21 // returned by GURL::query() or GURL::ref(). |
23 bool HasGoogleSearchQueryParam(const std::string& str); | 22 bool HasGoogleSearchQueryParam(const std::string& str); |
24 | 23 |
25 // The query key that identifies a Google Extended API request for Instant. | 24 // The query key that identifies a Google Extended API request for Instant. |
26 const char kInstantExtendedAPIParam[] = "espv"; | 25 const char kInstantExtendedAPIParam[] = "espv"; |
27 | 26 |
(...skipping 10 matching lines...) Expand all Loading... |
38 | 37 |
39 // String version of AppendGoogleLocaleParam. | 38 // String version of AppendGoogleLocaleParam. |
40 std::string StringAppendGoogleLocaleParam(const std::string& url); | 39 std::string StringAppendGoogleLocaleParam(const std::string& url); |
41 | 40 |
42 // Returns the Google country code string for the given Google homepage URL. | 41 // Returns the Google country code string for the given Google homepage URL. |
43 std::string GetGoogleCountryCode(GURL google_homepage_url); | 42 std::string GetGoogleCountryCode(GURL google_homepage_url); |
44 | 43 |
45 // Returns the Google search URL for the given Google homepage URL. | 44 // Returns the Google search URL for the given Google homepage URL. |
46 GURL GetGoogleSearchURL(GURL google_homepage_url); | 45 GURL GetGoogleSearchURL(GURL google_homepage_url); |
47 | 46 |
48 // Returns in |brand| the brand code or distribution tag that has been | |
49 // assigned to a partner. Returns false if the information is not available. | |
50 bool GetBrand(std::string* brand); | |
51 | |
52 // Returns in |brand| the reactivation brand code or distribution tag | |
53 // that has been assigned to a partner for reactivating a dormant chrome | |
54 // install. Returns false if the information is not available. | |
55 bool GetReactivationBrand(std::string* brand); | |
56 | |
57 // Returns the Google base URL specified on the command line, if it exists. | 47 // Returns the Google base URL specified on the command line, if it exists. |
58 // This performs some fixup and sanity-checking to ensure that the resulting URL | 48 // This performs some fixup and sanity-checking to ensure that the resulting URL |
59 // is valid and has no query or ref. | 49 // is valid and has no query or ref. |
60 GURL CommandLineGoogleBaseURL(); | 50 GURL CommandLineGoogleBaseURL(); |
61 | 51 |
62 // Returns true if a Google base URL was specified on the command line and |url| | 52 // Returns true if a Google base URL was specified on the command line and |url| |
63 // begins with that base URL. This uses a simple string equality check. | 53 // begins with that base URL. This uses a simple string equality check. |
64 bool StartsWithCommandLineGoogleBaseURL(const GURL& url); | 54 bool StartsWithCommandLineGoogleBaseURL(const GURL& url); |
65 | 55 |
66 // WARNING: The following IsGoogleXXX() functions use heuristics to rule out | 56 // WARNING: The following IsGoogleXXX() functions use heuristics to rule out |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 bool IsGoogleDomainUrl(const GURL& url, | 96 bool IsGoogleDomainUrl(const GURL& url, |
107 SubdomainPermission subdomain_permission, | 97 SubdomainPermission subdomain_permission, |
108 PortPermission port_permission); | 98 PortPermission port_permission); |
109 | 99 |
110 // True if |url| represents a valid Google home page URL. | 100 // True if |url| represents a valid Google home page URL. |
111 bool IsGoogleHomePageUrl(const GURL& url); | 101 bool IsGoogleHomePageUrl(const GURL& url); |
112 | 102 |
113 // True if |url| represents a valid Google search URL. | 103 // True if |url| represents a valid Google search URL. |
114 bool IsGoogleSearchUrl(const GURL& url); | 104 bool IsGoogleSearchUrl(const GURL& url); |
115 | 105 |
116 // True if a build is strictly organic, according to its brand code. | |
117 bool IsOrganic(const std::string& brand); | |
118 | |
119 // True if a build should run as organic during first run. This uses | |
120 // a slightly different set of brand codes from the standard IsOrganic | |
121 // method. | |
122 bool IsOrganicFirstRun(const std::string& brand); | |
123 | |
124 // True if |brand| is an internet cafe brand code. | |
125 bool IsInternetCafeBrandCode(const std::string& brand); | |
126 | |
127 // This class is meant to be used only from test code, and sets the brand | |
128 // code returned by the function GetBrand() above while the object exists. | |
129 class BrandForTesting { | |
130 public: | |
131 explicit BrandForTesting(const std::string& brand); | |
132 ~BrandForTesting(); | |
133 | |
134 private: | |
135 std::string brand_; | |
136 DISALLOW_COPY_AND_ASSIGN(BrandForTesting); | |
137 }; | |
138 | |
139 } // namespace google_util | 106 } // namespace google_util |
140 | 107 |
141 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ | 108 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ |
OLD | NEW |