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

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

Issue 11448005: Add Android-specific parameters to search_engines/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits Created 8 years 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/browser/search_engines/search_terms_data.h" 5 #include "chrome/browser/search_engines/search_terms_data.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/google/google_url_tracker.h" 11 #include "chrome/browser/google/google_url_tracker.h"
12 #include "chrome/browser/google/google_util.h" 12 #include "chrome/browser/google/google_util.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser_instant_controller.h" 14 #include "chrome/browser/ui/browser_instant_controller.h"
15 #include "chrome/browser/ui/search/search.h" 15 #include "chrome/browser/ui/search/search.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 18
19 #if defined(ENABLE_RLZ) 19 #if defined(ENABLE_RLZ)
20 #include "chrome/browser/google/google_util.h"
21 #include "chrome/browser/rlz/rlz.h" 20 #include "chrome/browser/rlz/rlz.h"
22 #endif 21 #endif
23 22
24 using content::BrowserThread; 23 using content::BrowserThread;
25 24
26 SearchTermsData::SearchTermsData() { 25 SearchTermsData::SearchTermsData() {
27 } 26 }
28 27
29 SearchTermsData::~SearchTermsData() { 28 SearchTermsData::~SearchTermsData() {
30 } 29 }
(...skipping 19 matching lines...) Expand all
50 // Clear the query and ref. 49 // Clear the query and ref.
51 repl.ClearQuery(); 50 repl.ClearQuery();
52 repl.ClearRef(); 51 repl.ClearRef();
53 return base_url.ReplaceComponents(repl).spec(); 52 return base_url.ReplaceComponents(repl).spec();
54 } 53 }
55 54
56 std::string SearchTermsData::GetApplicationLocale() const { 55 std::string SearchTermsData::GetApplicationLocale() const {
57 return "en"; 56 return "en";
58 } 57 }
59 58
60 #if defined(ENABLE_RLZ)
61 string16 SearchTermsData::GetRlzParameterValue() const { 59 string16 SearchTermsData::GetRlzParameterValue() const {
62 return string16(); 60 return string16();
63 } 61 }
64 #endif 62
63 std::string SearchTermsData::GetSearchClient() const {
64 return std::string();
65 }
65 66
66 std::string SearchTermsData::InstantEnabledParam() const { 67 std::string SearchTermsData::InstantEnabledParam() const {
67 return std::string(); 68 return std::string();
68 } 69 }
69 70
70 // static 71 // static
71 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; 72 std::string* UIThreadSearchTermsData::google_base_url_ = NULL;
72 73
73 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) 74 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile)
74 : profile_(profile) { 75 : profile_(profile) {
75 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 76 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
76 BrowserThread::CurrentlyOn(BrowserThread::UI)); 77 BrowserThread::CurrentlyOn(BrowserThread::UI));
77 } 78 }
78 79
79 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { 80 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const {
80 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 81 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
81 BrowserThread::CurrentlyOn(BrowserThread::UI)); 82 BrowserThread::CurrentlyOn(BrowserThread::UI));
82 if (google_base_url_) 83 if (google_base_url_)
83 return *google_base_url_; 84 return *google_base_url_;
84 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() : 85 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() :
85 SearchTermsData::GoogleBaseURLValue(); 86 SearchTermsData::GoogleBaseURLValue();
86 } 87 }
87 88
88 std::string UIThreadSearchTermsData::GetApplicationLocale() const { 89 std::string UIThreadSearchTermsData::GetApplicationLocale() const {
89 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 90 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
90 BrowserThread::CurrentlyOn(BrowserThread::UI)); 91 BrowserThread::CurrentlyOn(BrowserThread::UI));
91 return g_browser_process->GetApplicationLocale(); 92 return g_browser_process->GetApplicationLocale();
92 } 93 }
93 94
94 #if defined(ENABLE_RLZ) 95 // Android implementations are located in search_terms_data_android.cc.
96 #if !defined(OS_ANDROID)
95 string16 UIThreadSearchTermsData::GetRlzParameterValue() const { 97 string16 UIThreadSearchTermsData::GetRlzParameterValue() const {
96 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 98 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
97 BrowserThread::CurrentlyOn(BrowserThread::UI)); 99 BrowserThread::CurrentlyOn(BrowserThread::UI));
98 string16 rlz_string; 100 string16 rlz_string;
101 #if defined(ENABLE_RLZ)
99 // For organic brandcodes do not use rlz at all. Empty brandcode usually 102 // For organic brandcodes do not use rlz at all. Empty brandcode usually
100 // means a chromium install. This is ok. 103 // means a chromium install. This is ok.
101 std::string brand; 104 std::string brand;
102 if (google_util::GetBrand(&brand) && !brand.empty() && 105 if (google_util::GetBrand(&brand) && !brand.empty() &&
103 !google_util::IsOrganic(brand)) { 106 !google_util::IsOrganic(brand)) {
104 // This call will return false the first time(s) it is called until the 107 // This call will return false the first time(s) it is called until the
105 // value has been cached. This normally would mean that at most one omnibox 108 // value has been cached. This normally would mean that at most one omnibox
106 // search might not send the RLZ data but this is not really a problem. 109 // search might not send the RLZ data but this is not really a problem.
107 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string); 110 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string);
108 } 111 }
112 #endif
109 return rlz_string; 113 return rlz_string;
110 } 114 }
115
116 // We can enable this on non-Android if other platforms ever want a non-empty
117 // search client string. There is already a unit test in place for Android
118 // called TemplateURLTest::SearchClient.
119 std::string UIThreadSearchTermsData::GetSearchClient() const {
120 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
121 BrowserThread::CurrentlyOn(BrowserThread::UI));
122 return std::string();
123 }
111 #endif 124 #endif
112 125
113 std::string UIThreadSearchTermsData::InstantEnabledParam() const { 126 std::string UIThreadSearchTermsData::InstantEnabledParam() const {
114 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 127 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
115 BrowserThread::CurrentlyOn(BrowserThread::UI)); 128 BrowserThread::CurrentlyOn(BrowserThread::UI));
116 uint32 instant_extended_api_version = 129 uint32 instant_extended_api_version =
117 chrome::search::EmbeddedSearchPageVersion(profile_); 130 chrome::search::EmbeddedSearchPageVersion(profile_);
118 if (instant_extended_api_version != 0) 131 if (instant_extended_api_version != 0)
119 return std::string(google_util::kInstantExtendedAPIParam) + "=" + 132 return std::string(google_util::kInstantExtendedAPIParam) + "=" +
120 base::Uint64ToString(instant_extended_api_version) + "&"; 133 base::Uint64ToString(instant_extended_api_version) + "&";
121 if (chrome::BrowserInstantController::IsInstantEnabled(profile_)) 134 if (chrome::BrowserInstantController::IsInstantEnabled(profile_))
122 return "ion=1&"; 135 return "ion=1&";
123 return std::string(); 136 return std::string();
124 } 137 }
125 138
126 // static 139 // static
127 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { 140 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) {
128 delete google_base_url_; 141 delete google_base_url_;
129 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); 142 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url);
130 } 143 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/search_terms_data.h ('k') | chrome/browser/search_engines/search_terms_data_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698