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/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/search/instant_service.h" | 15 #include "chrome/browser/search/instant_service.h" |
16 #include "chrome/browser/search/instant_service_factory.h" | 16 #include "chrome/browser/search/instant_service_factory.h" |
17 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
18 #include "chrome/browser/sync/glue/device_info.h" | |
19 #include "chrome/browser/themes/theme_service.h" | 18 #include "chrome/browser/themes/theme_service.h" |
20 #include "chrome/browser/themes/theme_service_factory.h" | 19 #include "chrome/browser/themes/theme_service_factory.h" |
21 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
23 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
24 #include "components/google/core/browser/google_util.h" | 23 #include "components/google/core/browser/google_util.h" |
25 #include "components/omnibox/omnibox_field_trial.h" | 24 #include "components/omnibox/omnibox_field_trial.h" |
26 #include "components/search/search.h" | 25 #include "components/search/search.h" |
27 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
28 #include "sync/protocol/sync.pb.h" | 27 #include "ui/base/device_form_factor.h" |
29 #include "url/gurl.h" | 28 #include "url/gurl.h" |
30 | 29 |
31 #if defined(ENABLE_RLZ) | 30 #if defined(ENABLE_RLZ) |
32 #include "chrome/browser/rlz/rlz.h" | 31 #include "chrome/browser/rlz/rlz.h" |
33 #endif | 32 #endif |
34 | 33 |
35 using content::BrowserThread; | 34 using content::BrowserThread; |
36 | 35 |
37 // static | 36 // static |
38 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; | 37 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 95 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
97 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 96 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
98 return std::string(); | 97 return std::string(); |
99 } | 98 } |
100 #endif | 99 #endif |
101 | 100 |
102 std::string UIThreadSearchTermsData::GetSuggestClient() const { | 101 std::string UIThreadSearchTermsData::GetSuggestClient() const { |
103 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 102 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
104 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 103 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
105 #if defined(OS_ANDROID) | 104 #if defined(OS_ANDROID) |
106 sync_pb::SyncEnums::DeviceType device_type = | 105 return ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_PHONE ? |
107 browser_sync::DeviceInfo::GetLocalDeviceType(); | 106 "chrome" : "chrome-omni"; |
108 return device_type == sync_pb::SyncEnums_DeviceType_TYPE_PHONE ? | |
109 "chrome" : "chrome-omni"; | |
110 #else | 107 #else |
111 return chrome::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome"; | 108 return chrome::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome"; |
112 #endif | 109 #endif |
113 } | 110 } |
114 | 111 |
115 std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier() const { | 112 std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier() const { |
116 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 113 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
117 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 114 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
118 #if defined(OS_ANDROID) | 115 #if defined(OS_ANDROID) |
119 sync_pb::SyncEnums::DeviceType device_type = | 116 if (ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_PHONE) { |
120 browser_sync::DeviceInfo::GetLocalDeviceType(); | |
121 if (device_type == sync_pb::SyncEnums_DeviceType_TYPE_PHONE) { | |
122 return OmniboxFieldTrial::EnableAnswersInSuggest() ? | 117 return OmniboxFieldTrial::EnableAnswersInSuggest() ? |
123 "chrome-mobile-ext-ansg" : "chrome-mobile-ext"; | 118 "chrome-mobile-ext-ansg" : "chrome-mobile-ext"; |
124 } | 119 } |
125 return OmniboxFieldTrial::EnableAnswersInSuggest() ? | 120 return OmniboxFieldTrial::EnableAnswersInSuggest() ? |
126 "chrome-ext-ansg" : "chrome-ext"; | 121 "chrome-ext-ansg" : "chrome-ext"; |
127 #elif defined(OS_IOS) | 122 #elif defined(OS_IOS) |
128 return OmniboxFieldTrial::EnableAnswersInSuggest() ? | 123 return OmniboxFieldTrial::EnableAnswersInSuggest() ? |
129 "chrome-ext-ansg" : "chrome-ext"; | 124 "chrome-ext-ansg" : "chrome-ext"; |
130 #else | 125 #else |
131 return "chrome-ext"; | 126 return "chrome-ext"; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 return version; | 189 return version; |
195 } | 190 } |
196 return "unknown"; | 191 return "unknown"; |
197 } | 192 } |
198 | 193 |
199 // static | 194 // static |
200 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 195 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
201 delete google_base_url_; | 196 delete google_base_url_; |
202 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); |
203 } | 198 } |
OLD | NEW |