OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 virtual std::string GoogleBaseURLValue() const = 0; | 28 virtual std::string GoogleBaseURLValue() const = 0; |
29 | 29 |
30 // Returns the locale used by the application. | 30 // Returns the locale used by the application. |
31 virtual std::string GetApplicationLocale() const = 0; | 31 virtual std::string GetApplicationLocale() const = 0; |
32 | 32 |
33 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 33 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
34 // Returns the value for the Chrome Omnibox rlz. | 34 // Returns the value for the Chrome Omnibox rlz. |
35 virtual string16 GetRlzParameterValue() const = 0; | 35 virtual string16 GetRlzParameterValue() const = 0; |
36 #endif | 36 #endif |
37 | 37 |
| 38 // Returns a string indicating whether Instant (in the visible-preview mode) |
| 39 // is enabled, suitable for adding as a query string param to the homepage |
| 40 // (instant_url) request. Returns an empty string if Instant is disabled, |
| 41 // or if it's only active in a hidden field trial mode. Determining this |
| 42 // requires accessing the Profile, so this can only ever be non-empty for |
| 43 // UIThreadSearchTermsData. |
| 44 virtual std::string InstantEnabledParam() const; |
| 45 |
38 // Returns a string indicating the Instant field trial group, suitable for | 46 // Returns a string indicating the Instant field trial group, suitable for |
39 // adding as a query string param to suggest/search URLs, or an empty string | 47 // adding as a query string param to suggest/search URLs, or an empty string |
40 // if the field trial is not active. Checking the field trial group requires | 48 // if the field trial is not active. Checking the field trial group requires |
41 // accessing the Profile, which means this can only ever be non-empty for | 49 // accessing the Profile, which means this can only ever be non-empty for |
42 // UIThreadSearchTermsData. | 50 // UIThreadSearchTermsData. |
43 virtual std::string InstantFieldTrialUrlParam() const; | 51 virtual std::string InstantFieldTrialUrlParam() const; |
44 | 52 |
45 private: | 53 private: |
46 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); | 54 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); |
47 }; | 55 }; |
48 | 56 |
49 // Implementation of SearchTermsData that is only usable on the UI thread. | 57 // Implementation of SearchTermsData that is only usable on the UI thread. |
50 class UIThreadSearchTermsData : public SearchTermsData { | 58 class UIThreadSearchTermsData : public SearchTermsData { |
51 public: | 59 public: |
52 UIThreadSearchTermsData(); | 60 UIThreadSearchTermsData(); |
53 | 61 |
54 // Callers who need an accurate answer from InstantFieldTrialUrlParam() must | 62 // Callers who need an accurate answer from InstantFieldTrialUrlParam() or |
55 // set the profile here before calling that. | 63 // InstantEnabledParam() must set the profile here before calling them. |
56 void set_profile(Profile* profile) { profile_ = profile; } | 64 void set_profile(Profile* profile) { profile_ = profile; } |
57 | 65 |
58 // Implementation of SearchTermsData. | 66 // Implementation of SearchTermsData. |
59 virtual std::string GoogleBaseURLValue() const OVERRIDE; | 67 virtual std::string GoogleBaseURLValue() const OVERRIDE; |
60 virtual std::string GetApplicationLocale() const OVERRIDE; | 68 virtual std::string GetApplicationLocale() const OVERRIDE; |
61 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 69 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
62 virtual string16 GetRlzParameterValue() const OVERRIDE; | 70 virtual string16 GetRlzParameterValue() const OVERRIDE; |
63 #endif | 71 #endif |
64 | 72 |
65 // This returns the empty string unless set_profile() has been called with a | 73 // This returns the empty string unless set_profile() has been called with a |
66 // non-NULL Profile. | 74 // non-NULL Profile. |
| 75 virtual std::string InstantEnabledParam() const OVERRIDE; |
| 76 |
| 77 // This returns the empty string unless set_profile() has been called with a |
| 78 // non-NULL Profile. |
67 virtual std::string InstantFieldTrialUrlParam() const OVERRIDE; | 79 virtual std::string InstantFieldTrialUrlParam() const OVERRIDE; |
68 | 80 |
69 // Used by tests to set the value for the Google base url. This takes | 81 // Used by tests to set the value for the Google base url. This takes |
70 // ownership of the given std::string. | 82 // ownership of the given std::string. |
71 static void SetGoogleBaseURL(std::string* google_base_url); | 83 static void SetGoogleBaseURL(std::string* google_base_url); |
72 | 84 |
73 private: | 85 private: |
74 static std::string* google_base_url_; | 86 static std::string* google_base_url_; |
75 Profile* profile_; | 87 Profile* profile_; |
76 | 88 |
77 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); | 89 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); |
78 }; | 90 }; |
79 | 91 |
80 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ | 92 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ |
OLD | NEW |