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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 | 13 |
| 14 class Profile; |
| 15 |
14 // All data needed by TemplateURLRef::ReplaceSearchTerms which typically may | 16 // All data needed by TemplateURLRef::ReplaceSearchTerms which typically may |
15 // only be accessed on the UI thread. | 17 // only be accessed on the UI thread. |
16 class SearchTermsData { | 18 class SearchTermsData { |
17 public: | 19 public: |
18 SearchTermsData(); | 20 SearchTermsData(); |
19 virtual ~SearchTermsData(); | 21 virtual ~SearchTermsData(); |
20 | 22 |
21 // Returns the value for the GOOGLE_BASE_SUGGEST_URL term. | 23 // Returns the value for the GOOGLE_BASE_SUGGEST_URL term. |
22 std::string GoogleBaseSuggestURLValue() const; | 24 std::string GoogleBaseSuggestURLValue() const; |
23 | 25 |
24 // Returns the value to use for replacements of type GOOGLE_BASE_URL. | 26 // Returns the value to use for replacements of type GOOGLE_BASE_URL. |
25 virtual std::string GoogleBaseURLValue() const = 0; | 27 virtual std::string GoogleBaseURLValue() const = 0; |
26 | 28 |
27 // Returns the locale used by the application. | 29 // Returns the locale used by the application. |
28 virtual std::string GetApplicationLocale() const = 0; | 30 virtual std::string GetApplicationLocale() const = 0; |
29 | 31 |
30 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 32 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
31 // Returns the value for the Chrome Omnibox rlz. | 33 // Returns the value for the Chrome Omnibox rlz. |
32 virtual string16 GetRlzParameterValue() const = 0; | 34 virtual string16 GetRlzParameterValue() const = 0; |
33 #endif | 35 #endif |
34 | 36 |
| 37 // Returns a string indicating the Instant field trial group, suitable for |
| 38 // adding as a query string param to suggest/search URLs, or an empty string |
| 39 // if the field trial is not active. |
| 40 virtual std::string InstantFieldTrialUrlParam() const; |
| 41 |
35 private: | 42 private: |
36 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); | 43 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); |
37 }; | 44 }; |
38 | 45 |
39 // Implementation of SearchTermsData that is only usable on the UI thread. | 46 // Implementation of SearchTermsData that is only usable on the UI thread. |
40 class UIThreadSearchTermsData : public SearchTermsData { | 47 class UIThreadSearchTermsData : public SearchTermsData { |
41 public: | 48 public: |
42 UIThreadSearchTermsData(); | 49 explicit UIThreadSearchTermsData(Profile* profile); |
43 | 50 |
44 // Implementation of SearchTermsData. | 51 // Implementation of SearchTermsData. |
45 virtual std::string GoogleBaseURLValue() const; | 52 virtual std::string GoogleBaseURLValue() const; |
46 virtual std::string GetApplicationLocale() const; | 53 virtual std::string GetApplicationLocale() const; |
47 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 54 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
48 virtual string16 GetRlzParameterValue() const; | 55 virtual string16 GetRlzParameterValue() const; |
49 #endif | 56 #endif |
| 57 virtual std::string InstantFieldTrialUrlParam() const; |
50 | 58 |
51 // Used by tests to set the value for the Google base url. This takes | 59 // Used by tests to set the value for the Google base url. This takes |
52 // ownership of the given std::string. | 60 // ownership of the given std::string. |
53 static void SetGoogleBaseURL(std::string* google_base_url); | 61 static void SetGoogleBaseURL(std::string* google_base_url); |
54 | 62 |
55 private: | 63 private: |
56 static std::string* google_base_url_; | 64 static std::string* google_base_url_; |
57 | 65 |
| 66 Profile* const profile_; |
| 67 |
58 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); | 68 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); |
59 }; | 69 }; |
60 | 70 |
61 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ | 71 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ |
OLD | NEW |