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

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

Issue 594643003: Device info datatype should be moved to components/sync_driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed dependencies in ui_thread_search_terms_data.cc Created 6 years, 3 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 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
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"
108 return device_type == sync_pb::SyncEnums_DeviceType_TYPE_PHONE ? 107 : "chrome-omni";
Peter Kasting 2014/09/23 04:06:31 Nit: Please wrap the ?: like the old code did
stanisc 2014/09/23 21:30:32 Done. By the way this formatting was done by runni
109 "chrome" : "chrome-omni";
110 #else 108 #else
111 return chrome::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome"; 109 return chrome::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome";
112 #endif 110 #endif
113 } 111 }
114 112
115 std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier() const { 113 std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier() const {
116 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || 114 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
117 BrowserThread::CurrentlyOn(BrowserThread::UI)); 115 BrowserThread::CurrentlyOn(BrowserThread::UI));
118 #if defined(OS_ANDROID) 116 #if defined(OS_ANDROID)
119 sync_pb::SyncEnums::DeviceType device_type = 117 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() ? 118 return OmniboxFieldTrial::EnableAnswersInSuggest() ?
123 "chrome-mobile-ext-ansg" : "chrome-mobile-ext"; 119 "chrome-mobile-ext-ansg" : "chrome-mobile-ext";
124 } 120 }
125 return OmniboxFieldTrial::EnableAnswersInSuggest() ? 121 return OmniboxFieldTrial::EnableAnswersInSuggest() ?
126 "chrome-ext-ansg" : "chrome-ext"; 122 "chrome-ext-ansg" : "chrome-ext";
127 #elif defined(OS_IOS) 123 #elif defined(OS_IOS)
128 return OmniboxFieldTrial::EnableAnswersInSuggest() ? 124 return OmniboxFieldTrial::EnableAnswersInSuggest() ?
129 "chrome-ext-ansg" : "chrome-ext"; 125 "chrome-ext-ansg" : "chrome-ext";
130 #else 126 #else
131 return "chrome-ext"; 127 return "chrome-ext";
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return version; 190 return version;
195 } 191 }
196 return "unknown"; 192 return "unknown";
197 } 193 }
198 194
199 // static 195 // static
200 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { 196 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) {
201 delete google_base_url_; 197 delete google_base_url_;
202 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); 198 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url);
203 } 199 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/glue/device_info.h » ('j') | chrome/browser/sync/glue/device_info.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698