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

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

Issue 22031003: Rename BrowserThread::IsWellKnownThread to IsThreadInitialized. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor comment reword. Created 7 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
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 std::string SearchTermsData::NTPIsThemedParam() const { 84 std::string SearchTermsData::NTPIsThemedParam() const {
85 return std::string(); 85 return std::string();
86 } 86 }
87 87
88 // static 88 // static
89 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; 89 std::string* UIThreadSearchTermsData::google_base_url_ = NULL;
90 90
91 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) 91 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile)
92 : profile_(profile) { 92 : profile_(profile) {
93 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 93 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
94 BrowserThread::CurrentlyOn(BrowserThread::UI)); 94 BrowserThread::CurrentlyOn(BrowserThread::UI));
95 } 95 }
96 96
97 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { 97 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const {
98 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 98 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
99 BrowserThread::CurrentlyOn(BrowserThread::UI)); 99 BrowserThread::CurrentlyOn(BrowserThread::UI));
100 if (google_base_url_) 100 if (google_base_url_)
101 return *google_base_url_; 101 return *google_base_url_;
102 std::string base_url = CommandLine::ForCurrentProcess()-> 102 std::string base_url = CommandLine::ForCurrentProcess()->
103 GetSwitchValueASCII(switches::kGoogleBaseURL); 103 GetSwitchValueASCII(switches::kGoogleBaseURL);
104 if (!base_url.empty()) 104 if (!base_url.empty())
105 return base_url; 105 return base_url;
106 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() : 106 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() :
107 SearchTermsData::GoogleBaseURLValue(); 107 SearchTermsData::GoogleBaseURLValue();
108 } 108 }
109 109
110 std::string UIThreadSearchTermsData::GetApplicationLocale() const { 110 std::string UIThreadSearchTermsData::GetApplicationLocale() const {
111 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 111 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
112 BrowserThread::CurrentlyOn(BrowserThread::UI)); 112 BrowserThread::CurrentlyOn(BrowserThread::UI));
113 return g_browser_process->GetApplicationLocale(); 113 return g_browser_process->GetApplicationLocale();
114 } 114 }
115 115
116 // Android implementations are located in search_terms_data_android.cc. 116 // Android implementations are located in search_terms_data_android.cc.
117 #if !defined(OS_ANDROID) 117 #if !defined(OS_ANDROID)
118 string16 UIThreadSearchTermsData::GetRlzParameterValue() const { 118 string16 UIThreadSearchTermsData::GetRlzParameterValue() const {
119 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 119 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
120 BrowserThread::CurrentlyOn(BrowserThread::UI)); 120 BrowserThread::CurrentlyOn(BrowserThread::UI));
121 string16 rlz_string; 121 string16 rlz_string;
122 #if defined(ENABLE_RLZ) 122 #if defined(ENABLE_RLZ)
123 // For organic brandcodes do not use rlz at all. Empty brandcode usually 123 // For organic brandcodes do not use rlz at all. Empty brandcode usually
124 // means a chromium install. This is ok. 124 // means a chromium install. This is ok.
125 std::string brand; 125 std::string brand;
126 if (google_util::GetBrand(&brand) && !brand.empty() && 126 if (google_util::GetBrand(&brand) && !brand.empty() &&
127 !google_util::IsOrganic(brand)) { 127 !google_util::IsOrganic(brand)) {
128 // This call will return false the first time(s) it is called until the 128 // This call will return false the first time(s) it is called until the
129 // value has been cached. This normally would mean that at most one omnibox 129 // value has been cached. This normally would mean that at most one omnibox
130 // search might not send the RLZ data but this is not really a problem. 130 // search might not send the RLZ data but this is not really a problem.
131 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string); 131 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string);
132 } 132 }
133 #endif 133 #endif
134 return rlz_string; 134 return rlz_string;
135 } 135 }
136 136
137 // We can enable this on non-Android if other platforms ever want a non-empty 137 // We can enable this on non-Android if other platforms ever want a non-empty
138 // search client string. There is already a unit test in place for Android 138 // search client string. There is already a unit test in place for Android
139 // called TemplateURLTest::SearchClient. 139 // called TemplateURLTest::SearchClient.
140 std::string UIThreadSearchTermsData::GetSearchClient() const { 140 std::string UIThreadSearchTermsData::GetSearchClient() const {
141 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 141 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
142 BrowserThread::CurrentlyOn(BrowserThread::UI)); 142 BrowserThread::CurrentlyOn(BrowserThread::UI));
143 return std::string(); 143 return std::string();
144 } 144 }
145 #endif 145 #endif
146 146
147 std::string UIThreadSearchTermsData::GetSuggestClient() const { 147 std::string UIThreadSearchTermsData::GetSuggestClient() const {
148 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 148 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
149 BrowserThread::CurrentlyOn(BrowserThread::UI)); 149 BrowserThread::CurrentlyOn(BrowserThread::UI));
150 return chrome::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome"; 150 return chrome::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome";
151 } 151 }
152 152
153 std::string UIThreadSearchTermsData::InstantEnabledParam() const { 153 std::string UIThreadSearchTermsData::InstantEnabledParam() const {
154 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 154 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
155 BrowserThread::CurrentlyOn(BrowserThread::UI)); 155 BrowserThread::CurrentlyOn(BrowserThread::UI));
156 return chrome::IsInstantExtendedAPIEnabled() ? std::string() : "ion=1&"; 156 return chrome::IsInstantExtendedAPIEnabled() ? std::string() : "ion=1&";
157 } 157 }
158 158
159 std::string UIThreadSearchTermsData::InstantExtendedEnabledParam() const { 159 std::string UIThreadSearchTermsData::InstantExtendedEnabledParam() const {
160 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 160 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
161 BrowserThread::CurrentlyOn(BrowserThread::UI)); 161 BrowserThread::CurrentlyOn(BrowserThread::UI));
162 uint64 instant_extended_api_version = chrome::EmbeddedSearchPageVersion(); 162 uint64 instant_extended_api_version = chrome::EmbeddedSearchPageVersion();
163 if (instant_extended_api_version) { 163 if (instant_extended_api_version) {
164 return std::string(google_util::kInstantExtendedAPIParam) + "=" + 164 return std::string(google_util::kInstantExtendedAPIParam) + "=" +
165 base::Uint64ToString(instant_extended_api_version) + "&"; 165 base::Uint64ToString(instant_extended_api_version) + "&";
166 } 166 }
167 return std::string(); 167 return std::string();
168 } 168 }
169 169
170 std::string UIThreadSearchTermsData::NTPIsThemedParam() const { 170 std::string UIThreadSearchTermsData::NTPIsThemedParam() const {
171 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 171 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
172 BrowserThread::CurrentlyOn(BrowserThread::UI)); 172 BrowserThread::CurrentlyOn(BrowserThread::UI));
173 #if defined(ENABLE_THEMES) 173 #if defined(ENABLE_THEMES)
174 if (!chrome::IsInstantExtendedAPIEnabled()) 174 if (!chrome::IsInstantExtendedAPIEnabled())
175 return std::string(); 175 return std::string();
176 176
177 // TODO(dhollowa): Determine fraction of custom themes that don't affect the 177 // TODO(dhollowa): Determine fraction of custom themes that don't affect the
178 // NTP background and/or color. 178 // NTP background and/or color.
179 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_); 179 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_);
180 if (theme_service && !theme_service->UsingDefaultTheme()) 180 if (theme_service && !theme_service->UsingDefaultTheme())
181 return "es_th=1&"; 181 return "es_th=1&";
182 #endif // defined(ENABLE_THEMES) 182 #endif // defined(ENABLE_THEMES)
183 183
184 return std::string(); 184 return std::string();
185 } 185 }
186 186
187 // static 187 // static
188 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { 188 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) {
189 delete google_base_url_; 189 delete google_base_url_;
190 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); 190 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url);
191 } 191 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_shortcut_manager_win.cc ('k') | chrome/browser/search_engines/search_terms_data_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698