OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui_thread_search_terms_data.h" | 5 #include "chrome/browser/search_engines/ui_thread_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 "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/google/google_brand.h" | 12 #include "chrome/browser/google/google_brand.h" |
13 #include "chrome/browser/google/google_profile_helper.h" | 13 #include "chrome/browser/google/google_profile_helper.h" |
14 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 14 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/search/instant_service.h" |
| 17 #include "chrome/browser/search/instant_service_factory.h" |
16 #include "chrome/browser/search/search.h" | 18 #include "chrome/browser/search/search.h" |
17 #include "chrome/browser/sync/glue/device_info.h" | 19 #include "chrome/browser/sync/glue/device_info.h" |
18 #include "chrome/browser/themes/theme_service.h" | 20 #include "chrome/browser/themes/theme_service.h" |
19 #include "chrome/browser/themes/theme_service_factory.h" | 21 #include "chrome/browser/themes/theme_service_factory.h" |
20 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/chrome_version_info.h" | 23 #include "chrome/common/chrome_version_info.h" |
22 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
23 #include "components/google/core/browser/google_util.h" | 25 #include "components/google/core/browser/google_util.h" |
24 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
25 #include "sync/protocol/sync.pb.h" | 27 #include "sync/protocol/sync.pb.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 std::string UIThreadSearchTermsData::InstantExtendedEnabledParam( | 139 std::string UIThreadSearchTermsData::InstantExtendedEnabledParam( |
138 bool for_search) const { | 140 bool for_search) const { |
139 return chrome::InstantExtendedEnabledParam(for_search); | 141 return chrome::InstantExtendedEnabledParam(for_search); |
140 } | 142 } |
141 | 143 |
142 std::string UIThreadSearchTermsData::ForceInstantResultsParam( | 144 std::string UIThreadSearchTermsData::ForceInstantResultsParam( |
143 bool for_prerender) const { | 145 bool for_prerender) const { |
144 return chrome::ForceInstantResultsParam(for_prerender); | 146 return chrome::ForceInstantResultsParam(for_prerender); |
145 } | 147 } |
146 | 148 |
| 149 int UIThreadSearchTermsData::OmniboxStartMargin() const { |
| 150 InstantService* instant_service = |
| 151 InstantServiceFactory::GetForProfile(profile_); |
| 152 // Android and iOS have no InstantService. |
| 153 return instant_service ? |
| 154 instant_service->omnibox_start_margin() : chrome::kDisableStartMargin; |
| 155 } |
| 156 |
147 std::string UIThreadSearchTermsData::NTPIsThemedParam() const { | 157 std::string UIThreadSearchTermsData::NTPIsThemedParam() const { |
148 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 158 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
149 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 159 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
150 #if defined(ENABLE_THEMES) | 160 #if defined(ENABLE_THEMES) |
151 if (!chrome::IsInstantExtendedAPIEnabled()) | 161 if (!chrome::IsInstantExtendedAPIEnabled()) |
152 return std::string(); | 162 return std::string(); |
153 | 163 |
154 // TODO(dhollowa): Determine fraction of custom themes that don't affect the | 164 // TODO(dhollowa): Determine fraction of custom themes that don't affect the |
155 // NTP background and/or color. | 165 // NTP background and/or color. |
156 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_); | 166 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_); |
(...skipping 22 matching lines...) Expand all Loading... |
179 return version; | 189 return version; |
180 } | 190 } |
181 return "unknown"; | 191 return "unknown"; |
182 } | 192 } |
183 | 193 |
184 // static | 194 // static |
185 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 195 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
186 delete google_base_url_; | 196 delete google_base_url_; |
187 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 197 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
188 } | 198 } |
OLD | NEW |