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

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

Issue 7558014: Add a URL param to indicate group selection in Instant field trial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed @pkasting's comments Created 9 years, 4 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) 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. Checking the field trial group requires
40 // accessing the Profile, which means this can only ever be non-empty for
41 // UIThreadSearchTermsData.
42 virtual std::string InstantFieldTrialUrlParam() const;
43
35 private: 44 private:
36 DISALLOW_COPY_AND_ASSIGN(SearchTermsData); 45 DISALLOW_COPY_AND_ASSIGN(SearchTermsData);
37 }; 46 };
38 47
39 // Implementation of SearchTermsData that is only usable on the UI thread. 48 // Implementation of SearchTermsData that is only usable on the UI thread.
40 class UIThreadSearchTermsData : public SearchTermsData { 49 class UIThreadSearchTermsData : public SearchTermsData {
41 public: 50 public:
42 UIThreadSearchTermsData(); 51 UIThreadSearchTermsData();
43 52
53 // Callers who need an accurate answer from InstantFieldTrialUrlParam() must
54 // set the profile here before calling that.
55 void set_profile(Profile* profile) { profile_ = profile; }
56
44 // Implementation of SearchTermsData. 57 // Implementation of SearchTermsData.
45 virtual std::string GoogleBaseURLValue() const; 58 virtual std::string GoogleBaseURLValue() const;
46 virtual std::string GetApplicationLocale() const; 59 virtual std::string GetApplicationLocale() const;
47 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) 60 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
48 virtual string16 GetRlzParameterValue() const; 61 virtual string16 GetRlzParameterValue() const;
49 #endif 62 #endif
50 63
64 // This returns the empty string unless set_profile() has been called with a
65 // non-NULL Profile.
66 virtual std::string InstantFieldTrialUrlParam() const;
67
51 // Used by tests to set the value for the Google base url. This takes 68 // Used by tests to set the value for the Google base url. This takes
52 // ownership of the given std::string. 69 // ownership of the given std::string.
53 static void SetGoogleBaseURL(std::string* google_base_url); 70 static void SetGoogleBaseURL(std::string* google_base_url);
54 71
55 private: 72 private:
56 static std::string* google_base_url_; 73 static std::string* google_base_url_;
74 Profile* profile_;
57 75
58 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData); 76 DISALLOW_COPY_AND_ASSIGN(UIThreadSearchTermsData);
59 }; 77 };
60 78
61 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_ 79 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_loader.cc ('k') | chrome/browser/search_engines/search_terms_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698