| OLD | NEW |
| 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" |
| 11 #include "base/strings/string_number_conversions.h" | |
| 12 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/google/google_url_tracker.h" | 12 #include "chrome/browser/google/google_url_tracker.h" |
| 14 #include "chrome/browser/google/google_util.h" | 13 #include "chrome/browser/google/google_util.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/search/search.h" | 15 #include "chrome/browser/search/search.h" |
| 17 #include "chrome/browser/sync/glue/device_info.h" | 16 #include "chrome/browser/sync/glue/device_info.h" |
| 18 #include "chrome/browser/themes/theme_service.h" | 17 #include "chrome/browser/themes/theme_service.h" |
| 19 #include "chrome/browser/themes/theme_service_factory.h" | 18 #include "chrome/browser/themes/theme_service_factory.h" |
| 20 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 76 |
| 78 std::string SearchTermsData::GetSuggestRequestIdentifier() const { | 77 std::string SearchTermsData::GetSuggestRequestIdentifier() const { |
| 79 return std::string(); | 78 return std::string(); |
| 80 } | 79 } |
| 81 | 80 |
| 82 std::string SearchTermsData::ForceInstantResultsParam( | 81 std::string SearchTermsData::ForceInstantResultsParam( |
| 83 bool for_prerender) const { | 82 bool for_prerender) const { |
| 84 return std::string(); | 83 return std::string(); |
| 85 } | 84 } |
| 86 | 85 |
| 87 std::string SearchTermsData::InstantExtendedEnabledParam() const { | |
| 88 return std::string(); | |
| 89 } | |
| 90 | |
| 91 std::string SearchTermsData::NTPIsThemedParam() const { | 86 std::string SearchTermsData::NTPIsThemedParam() const { |
| 92 return std::string(); | 87 return std::string(); |
| 93 } | 88 } |
| 94 | 89 |
| 95 // static | 90 // static |
| 96 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; | 91 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; |
| 97 | 92 |
| 98 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) | 93 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) |
| 99 : profile_(profile) { | 94 : profile_(profile) { |
| 100 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 95 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 173 } |
| 179 | 174 |
| 180 std::string UIThreadSearchTermsData::ForceInstantResultsParam( | 175 std::string UIThreadSearchTermsData::ForceInstantResultsParam( |
| 181 bool for_prerender) const { | 176 bool for_prerender) const { |
| 182 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 177 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
| 183 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 178 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 184 return (for_prerender || !chrome::IsInstantExtendedAPIEnabled()) ? "ion=1&" : | 179 return (for_prerender || !chrome::IsInstantExtendedAPIEnabled()) ? "ion=1&" : |
| 185 std::string(); | 180 std::string(); |
| 186 } | 181 } |
| 187 | 182 |
| 188 std::string UIThreadSearchTermsData::InstantExtendedEnabledParam() const { | |
| 189 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | |
| 190 BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 191 uint64 instant_extended_api_version = chrome::EmbeddedSearchPageVersion(); | |
| 192 if (instant_extended_api_version) { | |
| 193 return std::string(google_util::kInstantExtendedAPIParam) + "=" + | |
| 194 base::Uint64ToString(instant_extended_api_version) + "&"; | |
| 195 } | |
| 196 return std::string(); | |
| 197 } | |
| 198 | |
| 199 std::string UIThreadSearchTermsData::NTPIsThemedParam() const { | 183 std::string UIThreadSearchTermsData::NTPIsThemedParam() const { |
| 200 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 184 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
| 201 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 185 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 202 #if defined(ENABLE_THEMES) | 186 #if defined(ENABLE_THEMES) |
| 203 if (!chrome::IsInstantExtendedAPIEnabled()) | 187 if (!chrome::IsInstantExtendedAPIEnabled()) |
| 204 return std::string(); | 188 return std::string(); |
| 205 | 189 |
| 206 // TODO(dhollowa): Determine fraction of custom themes that don't affect the | 190 // TODO(dhollowa): Determine fraction of custom themes that don't affect the |
| 207 // NTP background and/or color. | 191 // NTP background and/or color. |
| 208 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_); | 192 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_); |
| 209 // NTP is considered themed if the theme is not default and not native (GTK+). | 193 // NTP is considered themed if the theme is not default and not native (GTK+). |
| 210 if (theme_service && !theme_service->UsingDefaultTheme() && | 194 if (theme_service && !theme_service->UsingDefaultTheme() && |
| 211 !theme_service->UsingNativeTheme()) | 195 !theme_service->UsingNativeTheme()) |
| 212 return "es_th=1&"; | 196 return "es_th=1&"; |
| 213 #endif // defined(ENABLE_THEMES) | 197 #endif // defined(ENABLE_THEMES) |
| 214 | 198 |
| 215 return std::string(); | 199 return std::string(); |
| 216 } | 200 } |
| 217 | 201 |
| 218 // static | 202 // static |
| 219 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 203 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
| 220 delete google_base_url_; | 204 delete google_base_url_; |
| 221 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 205 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
| 222 } | 206 } |
| OLD | NEW |