| 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 COMPONENTS_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ |
| 6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ | 6 #define COMPONENTS_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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 | 13 |
| 14 class Profile; | |
| 15 | |
| 16 // All data needed by TemplateURLRef::ReplaceSearchTerms which typically may | 14 // All data needed by TemplateURLRef::ReplaceSearchTerms which typically may |
| 17 // only be accessed on the UI thread. | 15 // only be accessed on the UI thread. |
| 18 class SearchTermsData { | 16 class SearchTermsData { |
| 19 public: | 17 public: |
| 20 SearchTermsData(); | 18 SearchTermsData(); |
| 21 virtual ~SearchTermsData(); | 19 virtual ~SearchTermsData(); |
| 22 | 20 |
| 23 // Returns the value to use for replacements of type GOOGLE_BASE_URL. This | 21 // Returns the value to use for replacements of type GOOGLE_BASE_URL. This |
| 24 // implementation simply returns the default value. | 22 // implementation simply returns the default value. |
| 25 virtual std::string GoogleBaseURLValue() const; | 23 virtual std::string GoogleBaseURLValue() const; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 55 // suitable for adding as a query string param to the homepage. This only | 53 // suitable for adding as a query string param to the homepage. This only |
| 56 // applies if Instant Extended is enabled. Returns an empty string otherwise. | 54 // applies if Instant Extended is enabled. Returns an empty string otherwise. |
| 57 // Determining this requires accessing the Profile, so this can only ever be | 55 // Determining this requires accessing the Profile, so this can only ever be |
| 58 // non-empty for UIThreadSearchTermsData. | 56 // non-empty for UIThreadSearchTermsData. |
| 59 virtual std::string NTPIsThemedParam() const; | 57 virtual std::string NTPIsThemedParam() const; |
| 60 | 58 |
| 61 private: | 59 private: |
| 62 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); | 60 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); |
| 63 }; | 61 }; |
| 64 | 62 |
| 65 // Implementation of SearchTermsData that is only usable on the UI thread. | 63 #endif // COMPONENTS_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ |
| 66 class UIThreadSearchTermsData : public SearchTermsData { | |
| 67 public: | |
| 68 // If |profile_| is NULL, the Google base URL accessors will return default | |
| 69 // values, and NTPIsThemedParam() will return an empty string. | |
| 70 explicit UIThreadSearchTermsData(Profile* profile); | |
| 71 | |
| 72 virtual std::string GoogleBaseURLValue() const OVERRIDE; | |
| 73 virtual std::string GetApplicationLocale() const OVERRIDE; | |
| 74 virtual base::string16 GetRlzParameterValue(bool from_app_list) const | |
| 75 OVERRIDE; | |
| 76 virtual std::string GetSearchClient() const OVERRIDE; | |
| 77 virtual std::string GetSuggestClient() const OVERRIDE; | |
| 78 virtual std::string GetSuggestRequestIdentifier() const OVERRIDE; | |
| 79 virtual std::string NTPIsThemedParam() const OVERRIDE; | |
| 80 | |
| 81 // Used by tests to override the value for the Google base URL. Passing the | |
| 82 // empty string cancels this override. | |
| 83 static void SetGoogleBaseURL(const std::string& base_url); | |
| 84 | |
| 85 private: | |
| 86 static std::string* google_base_url_; | |
| 87 Profile* profile_; | |
| 88 | |
| 89 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); | |
| 90 }; | |
| 91 | |
| 92 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ | |
| OLD | NEW |