Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: chrome/browser/search_engines/ui_thread_search_terms_data.h

Issue 324283003: Move search_terms_data to components/search_engines (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_UI_THREAD_SEARCH_TERMS_DATA_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_UI_THREAD_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 #include "components/search_engines/search_terms_data.h"
13 14
14 class Profile; 15 class Profile;
15 16
16 // All data needed by TemplateURLRef::ReplaceSearchTerms which typically may
17 // only be accessed on the UI thread.
18 class SearchTermsData {
19 public:
20 SearchTermsData();
21 virtual ~SearchTermsData();
22
23 // Returns the value to use for replacements of type GOOGLE_BASE_URL. This
24 // implementation simply returns the default value.
25 virtual std::string GoogleBaseURLValue() const;
26
27 // Returns the value for the GOOGLE_BASE_SUGGEST_URL term. This
28 // implementation simply returns the default value.
29 std::string GoogleBaseSuggestURLValue() const;
30
31 // Returns the locale used by the application. This implementation returns
32 // "en" and thus should be overridden where the result is actually meaningful.
33 virtual std::string GetApplicationLocale() const;
34
35 // Returns the value for the Chrome Omnibox rlz. This implementation returns
36 // the empty string.
37 virtual base::string16 GetRlzParameterValue(bool from_app_list) const;
38
39 // The optional client parameter passed with Google search requests. This
40 // implementation returns the empty string.
41 virtual std::string GetSearchClient() const;
42
43 // The suggest client parameter ("client") passed with Google suggest
44 // requests. See GetSuggestRequestIdentifier() for more details.
45 // This implementation returns the empty string.
46 virtual std::string GetSuggestClient() const;
47
48 // The suggest request identifier parameter ("gs_ri") passed with Google
49 // suggest requests. Along with suggestclient (See GetSuggestClient()),
50 // this parameter controls what suggestion results are returned.
51 // This implementation returns the empty string.
52 virtual std::string GetSuggestRequestIdentifier() const;
53
54 // Returns a string indicating whether a non-default theme is active,
55 // 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.
57 // Determining this requires accessing the Profile, so this can only ever be
58 // non-empty for UIThreadSearchTermsData.
59 virtual std::string NTPIsThemedParam() const;
60
61 private:
62 DISALLOW_COPY_AND_ASSIGN(SearchTermsData);
63 };
64
65 // Implementation of SearchTermsData that is only usable on the UI thread. 17 // Implementation of SearchTermsData that is only usable on the UI thread.
66 class UIThreadSearchTermsData : public SearchTermsData { 18 class UIThreadSearchTermsData : public SearchTermsData {
67 public: 19 public:
68 // If |profile_| is NULL, the Google base URL accessors will return default 20 // If |profile_| is NULL, the Google base URL accessors will return default
69 // values, and NTPIsThemedParam() will return an empty string. 21 // values, and NTPIsThemedParam() will return an empty string.
70 explicit UIThreadSearchTermsData(Profile* profile); 22 explicit UIThreadSearchTermsData(Profile* profile);
71 23
72 virtual std::string GoogleBaseURLValue() const OVERRIDE; 24 virtual std::string GoogleBaseURLValue() const OVERRIDE;
73 virtual std::string GetApplicationLocale() const OVERRIDE; 25 virtual std::string GetApplicationLocale() const OVERRIDE;
74 virtual base::string16 GetRlzParameterValue(bool from_app_list) const 26 virtual base::string16 GetRlzParameterValue(bool from_app_list) const
75 OVERRIDE; 27 OVERRIDE;
76 virtual std::string GetSearchClient() const OVERRIDE; 28 virtual std::string GetSearchClient() const OVERRIDE;
77 virtual std::string GetSuggestClient() const OVERRIDE; 29 virtual std::string GetSuggestClient() const OVERRIDE;
78 virtual std::string GetSuggestRequestIdentifier() const OVERRIDE; 30 virtual std::string GetSuggestRequestIdentifier() const OVERRIDE;
79 virtual std::string NTPIsThemedParam() const OVERRIDE; 31 virtual std::string NTPIsThemedParam() const OVERRIDE;
80 32
81 // Used by tests to override the value for the Google base URL. Passing the 33 // Used by tests to override the value for the Google base URL. Passing the
82 // empty string cancels this override. 34 // empty string cancels this override.
83 static void SetGoogleBaseURL(const std::string& base_url); 35 static void SetGoogleBaseURL(const std::string& base_url);
84 36
85 private: 37 private:
86 static std::string* google_base_url_; 38 static std::string* google_base_url_;
87 Profile* profile_; 39 Profile* profile_;
88 40
89 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); 41 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData);
90 }; 42 };
91 43
92 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ 44 #endif // CHROME_BROWSER_SEARCH_ENGINES_UI_THREAD_SEARCH_TERMS_DATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_unittest.cc ('k') | chrome/browser/search_engines/ui_thread_search_terms_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698