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

Side by Side Diff: chrome/browser/sync/glue/device_info.cc

Issue 22706006: Implementation of the DeviceInfo get API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For try runs 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/sync/glue/device_info.h" 5 #include "chrome/browser/sync/glue/device_info.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/chrome_version_info.h" 10 #include "chrome/common/chrome_version_info.h"
(...skipping 26 matching lines...) Expand all
37 return "stable"; 37 return "stable";
38 default: 38 default:
39 NOTREACHED(); 39 NOTREACHED();
40 return "unknown"; 40 return "unknown";
41 }; 41 };
42 } 42 }
43 43
44 std::string DeviceTypeToString(sync_pb::SyncEnums::DeviceType device_type) { 44 std::string DeviceTypeToString(sync_pb::SyncEnums::DeviceType device_type) {
45 switch (device_type) { 45 switch (device_type) {
46 case sync_pb::SyncEnums_DeviceType_TYPE_WIN: 46 case sync_pb::SyncEnums_DeviceType_TYPE_WIN:
47 return "WIN";
48 case sync_pb::SyncEnums_DeviceType_TYPE_MAC: 47 case sync_pb::SyncEnums_DeviceType_TYPE_MAC:
49 return "MAC";
50 case sync_pb::SyncEnums_DeviceType_TYPE_LINUX: 48 case sync_pb::SyncEnums_DeviceType_TYPE_LINUX:
51 return "LINUX";
52 case sync_pb::SyncEnums_DeviceType_TYPE_CROS: 49 case sync_pb::SyncEnums_DeviceType_TYPE_CROS:
53 return "CHROME OS"; 50 return "desktop_or_laptop";
54 case sync_pb::SyncEnums_DeviceType_TYPE_OTHER:
55 return "OTHER";
56 case sync_pb::SyncEnums_DeviceType_TYPE_PHONE: 51 case sync_pb::SyncEnums_DeviceType_TYPE_PHONE:
57 return "PHONE"; 52 return "phone";
58 case sync_pb::SyncEnums_DeviceType_TYPE_TABLET: 53 case sync_pb::SyncEnums_DeviceType_TYPE_TABLET:
59 return "TABLET"; 54 return "tablet";
60 default: 55 default:
61 NOTREACHED(); 56 return "unknown";
62 return "UNKNOWN";
63 } 57 }
64 } 58 }
65 59
60 std::string GetOS(sync_pb::SyncEnums::DeviceType device_type) {
61 switch (device_type) {
62 case sync_pb::SyncEnums_DeviceType_TYPE_WIN:
63 return "win";
64 case sync_pb::SyncEnums_DeviceType_TYPE_MAC:
65 return "mac";
66 case sync_pb::SyncEnums_DeviceType_TYPE_LINUX:
67 return "linux";
68 case sync_pb::SyncEnums_DeviceType_TYPE_CROS:
69 return "chrome_os";
70 case sync_pb::SyncEnums_DeviceType_TYPE_PHONE:
71 case sync_pb::SyncEnums_DeviceType_TYPE_TABLET:
72 // TODO(lipalani): crbug.com/170375. Add support for ios
73 // phones and tablets.
74 return "android";
75 default:
76 return "unknown";
77 }
78 }
79
66 } // namespace 80 } // namespace
67 81
68 DeviceInfo::DeviceInfo(const std::string& guid, 82 DeviceInfo::DeviceInfo(const std::string& guid,
69 const std::string& client_name, 83 const std::string& client_name,
70 const std::string& chrome_version, 84 const std::string& chrome_version,
71 const std::string& sync_user_agent, 85 const std::string& sync_user_agent,
72 const sync_pb::SyncEnums::DeviceType device_type) 86 const sync_pb::SyncEnums::DeviceType device_type)
73 : guid_(guid), 87 : guid_(guid),
74 client_name_(client_name), 88 client_name_(client_name),
75 chrome_version_(chrome_version), 89 chrome_version_(chrome_version),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } else { 179 } else {
166 user_agent += " channel(" + 180 user_agent += " channel(" +
167 ChannelToString(version_info.GetChannel()) + ")"; 181 ChannelToString(version_info.GetChannel()) + ")";
168 } 182 }
169 183
170 return user_agent; 184 return user_agent;
171 } 185 }
172 186
173 base::DictionaryValue* DeviceInfo::ToValue() { 187 base::DictionaryValue* DeviceInfo::ToValue() {
174 base::DictionaryValue* value = new base::DictionaryValue(); 188 base::DictionaryValue* value = new base::DictionaryValue();
175 value->SetString("Id", public_id_); 189 value->SetString("id", public_id_);
176 value->SetString("Client Name", client_name_); 190 value->SetString("name", client_name_);
177 value->SetString("Chrome Version", chrome_version_); 191 value->SetString("chromeVersion", chrome_version_);
178 value->SetString("Sync User Agent", sync_user_agent_); 192 value->SetString("os", GetOS(device_type_));
179 value->SetString("Device Type", DeviceTypeToString(device_type_)); 193 value->SetString("Device Type", DeviceTypeToString(device_type_));
180 return value; 194 return value;
181 } 195 }
182 196
183 void DeviceInfo::set_public_id(std::string id) { 197 void DeviceInfo::set_public_id(std::string id) {
184 public_id_ = id; 198 public_id_ = id;
185 } 199 }
186 200
187 // static. 201 // static.
188 void DeviceInfo::CreateLocalDeviceInfo( 202 void DeviceInfo::CreateLocalDeviceInfo(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 guid, 234 guid,
221 session_name, 235 session_name,
222 version_info.CreateVersionString(), 236 version_info.CreateVersionString(),
223 MakeUserAgentForSyncApi(version_info), 237 MakeUserAgentForSyncApi(version_info),
224 GetLocalDeviceType()); 238 GetLocalDeviceType());
225 239
226 callback.Run(local_info); 240 callback.Run(local_info);
227 } 241 }
228 242
229 } // namespace browser_sync 243 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698