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 // |profile| is needed only to create URL params related to the Instant field |
50 // trial. Most users don't care about those params, so it's okay to pass in a | |
51 // NULL profile. | |
52 explicit UIThreadSearchTermsData(Profile* profile); | |
Peter Kasting
2011/08/11 00:35:17
I wonder if it would be even simpler to leave this
| |
43 | 53 |
44 // Implementation of SearchTermsData. | 54 // Implementation of SearchTermsData. |
45 virtual std::string GoogleBaseURLValue() const; | 55 virtual std::string GoogleBaseURLValue() const; |
46 virtual std::string GetApplicationLocale() const; | 56 virtual std::string GetApplicationLocale() const; |
47 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 57 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
48 virtual string16 GetRlzParameterValue() const; | 58 virtual string16 GetRlzParameterValue() const; |
49 #endif | 59 #endif |
60 virtual std::string InstantFieldTrialUrlParam() const; | |
50 | 61 |
51 // Used by tests to set the value for the Google base url. This takes | 62 // Used by tests to set the value for the Google base url. This takes |
52 // ownership of the given std::string. | 63 // ownership of the given std::string. |
53 static void SetGoogleBaseURL(std::string* google_base_url); | 64 static void SetGoogleBaseURL(std::string* google_base_url); |
54 | 65 |
55 private: | 66 private: |
56 static std::string* google_base_url_; | 67 static std::string* google_base_url_; |
57 | 68 |
69 Profile* const profile_; | |
70 | |
58 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); | 71 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); |
59 }; | 72 }; |
60 | 73 |
61 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ | 74 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ |
OLD | NEW |