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

Side by Side Diff: chrome/browser/google/google_util.h

Issue 10908226: Introduces a search term extraction mechanism working for arbitrary search providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "base/string16.h"
14 13
15 class GURL; 14 class GURL;
16 class Profile; 15 class Profile;
17 16
18 // This namespace provides various helpers around handling Google-related URLs 17 // This namespace provides various helpers around handling Google-related URLs
19 // and state relating to Google Chrome distributions (such as RLZ). 18 // and state relating to Google Chrome distributions (such as RLZ).
20 namespace google_util { 19 namespace google_util {
21 20
22 // The query key that identifies a Google Extended API request for Instant. 21 // The query key that identifies a Google Extended API request for Instant.
23 const char kInstantExtendedAPIParam[] = "espv"; 22 const char kInstantExtendedAPIParam[] = "espv";
(...skipping 14 matching lines...) Expand all
38 37
39 // Returns in |brand| the brand code or distribution tag that has been 38 // Returns in |brand| the brand code or distribution tag that has been
40 // assigned to a partner. Returns false if the information is not available. 39 // assigned to a partner. Returns false if the information is not available.
41 bool GetBrand(std::string* brand); 40 bool GetBrand(std::string* brand);
42 41
43 // Returns in |brand| the reactivation brand code or distribution tag 42 // Returns in |brand| the reactivation brand code or distribution tag
44 // that has been assigned to a partner for reactivating a dormant chrome 43 // that has been assigned to a partner for reactivating a dormant chrome
45 // install. Returns false if the information is not available. 44 // install. Returns false if the information is not available.
46 bool GetReactivationBrand(std::string* brand); 45 bool GetReactivationBrand(std::string* brand);
47 46
48 // Returns in the search terms used to create the Google search URL |url|.
49 string16 GetSearchTermsFromGoogleSearchURL(const std::string& url);
50
51 // WARNING: The following IsGoogleXXX() functions use heuristics to rule out 47 // WARNING: The following IsGoogleXXX() functions use heuristics to rule out
52 // "obviously false" answers. They do NOT guarantee that the string in question 48 // "obviously false" answers. They do NOT guarantee that the string in question
53 // is actually on a Google-owned domain, just that it looks plausible. If you 49 // is actually on a Google-owned domain, just that it looks plausible. If you
54 // need to restrict some behavior to only happen on Google's officially-owned 50 // need to restrict some behavior to only happen on Google's officially-owned
55 // domains, use TransportSecurityState::IsGooglePinnedProperty() instead. 51 // domains, use TransportSecurityState::IsGooglePinnedProperty() instead.
56 52
57 // Designate whether or not a URL checking function also checks for specific 53 // Designate whether or not a URL checking function also checks for specific
58 // subdomains, or only "www" and empty subdomains. 54 // subdomains, or only "www" and empty subdomains.
59 enum SubdomainPermission { 55 enum SubdomainPermission {
60 ALLOW_SUBDOMAIN, 56 ALLOW_SUBDOMAIN,
(...skipping 18 matching lines...) Expand all
79 // |subdomain_permission| is ALLOW_SUBDOMAIN, we check against host 75 // |subdomain_permission| is ALLOW_SUBDOMAIN, we check against host
80 // "*.google.<TLD>" instead. 76 // "*.google.<TLD>" instead.
81 bool IsGoogleHostname(const std::string& host, 77 bool IsGoogleHostname(const std::string& host,
82 SubdomainPermission subdomain_permission); 78 SubdomainPermission subdomain_permission);
83 // True if |url| represents a valid Google home page URL. 79 // True if |url| represents a valid Google home page URL.
84 bool IsGoogleHomePageUrl(const std::string& url); 80 bool IsGoogleHomePageUrl(const std::string& url);
85 // True if |url| represents a valid Google search URL. 81 // True if |url| represents a valid Google search URL.
86 bool IsGoogleSearchUrl(const std::string& url); 82 bool IsGoogleSearchUrl(const std::string& url);
87 // True if |url| represents a valid Google search URL used by the Instant 83 // True if |url| represents a valid Google search URL used by the Instant
88 // Extended API. 84 // Extended API.
85 // TODO(beaudoin): Replace with the new mechanism based on the user's default
86 // search engine. See TemplateURL.
89 bool IsInstantExtendedAPIGoogleSearchUrl(const std::string& url); 87 bool IsInstantExtendedAPIGoogleSearchUrl(const std::string& url);
90 88
91 // True if a build is strictly organic, according to its brand code. 89 // True if a build is strictly organic, according to its brand code.
92 bool IsOrganic(const std::string& brand); 90 bool IsOrganic(const std::string& brand);
93 91
94 // True if a build should run as organic during first run. This uses 92 // True if a build should run as organic during first run. This uses
95 // a slightly different set of brand codes from the standard IsOrganic 93 // a slightly different set of brand codes from the standard IsOrganic
96 // method. 94 // method.
97 bool IsOrganicFirstRun(const std::string& brand); 95 bool IsOrganicFirstRun(const std::string& brand);
98 96
99 // True if |brand| is an internet cafe brand code. 97 // True if |brand| is an internet cafe brand code.
100 bool IsInternetCafeBrandCode(const std::string& brand); 98 bool IsInternetCafeBrandCode(const std::string& brand);
101 99
102 // This class is meant to be used only from test code, and sets the brand 100 // This class is meant to be used only from test code, and sets the brand
103 // code returned by the function GetBrand() above while the object exists. 101 // code returned by the function GetBrand() above while the object exists.
104 class BrandForTesting { 102 class BrandForTesting {
105 public: 103 public:
106 explicit BrandForTesting(const std::string& brand); 104 explicit BrandForTesting(const std::string& brand);
107 ~BrandForTesting(); 105 ~BrandForTesting();
108 106
109 private: 107 private:
110 std::string brand_; 108 std::string brand_;
111 DISALLOW_COPY_AND_ASSIGN(BrandForTesting); 109 DISALLOW_COPY_AND_ASSIGN(BrandForTesting);
112 }; 110 };
113 111
114 } // namespace google_util 112 } // namespace google_util
115 113
116 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ 114 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google/google_util.cc » ('j') | chrome/browser/search_engines/template_url.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698