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