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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ |
6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // requests. See GetSuggestRequestIdentifier() for more details. | 44 // requests. See GetSuggestRequestIdentifier() for more details. |
45 // This implementation returns the empty string. | 45 // This implementation returns the empty string. |
46 virtual std::string GetSuggestClient() const; | 46 virtual std::string GetSuggestClient() const; |
47 | 47 |
48 // The suggest request identifier parameter ("gs_ri") passed with Google | 48 // The suggest request identifier parameter ("gs_ri") passed with Google |
49 // suggest requests. Along with suggestclient (See GetSuggestClient()), | 49 // suggest requests. Along with suggestclient (See GetSuggestClient()), |
50 // this parameter controls what suggestion results are returned. | 50 // this parameter controls what suggestion results are returned. |
51 // This implementation returns the empty string. | 51 // This implementation returns the empty string. |
52 virtual std::string GetSuggestRequestIdentifier() const; | 52 virtual std::string GetSuggestRequestIdentifier() const; |
53 | 53 |
54 // Returns a string that will cause the search results page to update | |
55 // incrementally. Currently, Instant Extended passes a different param to | |
56 // search results pages that also has this effect, so by default this function | |
57 // returns the empty string when Instant Extended is enabled. However, when | |
58 // doing instant search result prerendering, we still need to pass this param, | |
59 // as Instant Extended does not cause incremental updates by default for the | |
60 // prerender page. Callers should set |for_prerender| in this case to force | |
61 // the returned string to be non-empty. | |
62 virtual std::string ForceInstantResultsParam(bool for_prerender) const; | |
63 | |
64 // Returns a string indicating whether a non-default theme is active, | 54 // Returns a string indicating whether a non-default theme is active, |
65 // suitable for adding as a query string param to the homepage. This only | 55 // suitable for adding as a query string param to the homepage. This only |
66 // applies if Instant Extended is enabled. Returns an empty string otherwise. | 56 // applies if Instant Extended is enabled. Returns an empty string otherwise. |
67 // Determining this requires accessing the Profile, so this can only ever be | 57 // Determining this requires accessing the Profile, so this can only ever be |
68 // non-empty for UIThreadSearchTermsData. | 58 // non-empty for UIThreadSearchTermsData. |
69 virtual std::string NTPIsThemedParam() const; | 59 virtual std::string NTPIsThemedParam() const; |
70 | 60 |
71 private: | 61 private: |
72 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); | 62 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); |
73 }; | 63 }; |
74 | 64 |
75 // Implementation of SearchTermsData that is only usable on the UI thread. | 65 // Implementation of SearchTermsData that is only usable on the UI thread. |
76 class UIThreadSearchTermsData : public SearchTermsData { | 66 class UIThreadSearchTermsData : public SearchTermsData { |
77 public: | 67 public: |
78 // If |profile_| is NULL, the Google base URL accessors will return default | 68 // If |profile_| is NULL, the Google base URL accessors will return default |
79 // values, and NTPIsThemedParam() will return an empty string. | 69 // values, and NTPIsThemedParam() will return an empty string. |
80 explicit UIThreadSearchTermsData(Profile* profile); | 70 explicit UIThreadSearchTermsData(Profile* profile); |
81 | 71 |
82 virtual std::string GoogleBaseURLValue() const OVERRIDE; | 72 virtual std::string GoogleBaseURLValue() const OVERRIDE; |
83 virtual std::string GetApplicationLocale() const OVERRIDE; | 73 virtual std::string GetApplicationLocale() const OVERRIDE; |
84 virtual base::string16 GetRlzParameterValue() const OVERRIDE; | 74 virtual base::string16 GetRlzParameterValue() const OVERRIDE; |
85 virtual std::string GetSearchClient() const OVERRIDE; | 75 virtual std::string GetSearchClient() const OVERRIDE; |
86 virtual std::string GetSuggestClient() const OVERRIDE; | 76 virtual std::string GetSuggestClient() const OVERRIDE; |
87 virtual std::string GetSuggestRequestIdentifier() const OVERRIDE; | 77 virtual std::string GetSuggestRequestIdentifier() const OVERRIDE; |
88 virtual std::string ForceInstantResultsParam( | |
89 bool for_prerender) const OVERRIDE; | |
90 virtual std::string NTPIsThemedParam() const OVERRIDE; | 78 virtual std::string NTPIsThemedParam() const OVERRIDE; |
91 | 79 |
92 // Used by tests to override the value for the Google base URL. Passing the | 80 // Used by tests to override the value for the Google base URL. Passing the |
93 // empty string cancels this override. | 81 // empty string cancels this override. |
94 static void SetGoogleBaseURL(const std::string& base_url); | 82 static void SetGoogleBaseURL(const std::string& base_url); |
95 | 83 |
96 private: | 84 private: |
97 static std::string* google_base_url_; | 85 static std::string* google_base_url_; |
98 Profile* profile_; | 86 Profile* profile_; |
99 | 87 |
100 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); | 88 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); |
101 }; | 89 }; |
102 | 90 |
103 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ | 91 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ |
OLD | NEW |