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

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 review. 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): Add support for ios phones and tablets.
Nicolas Zea 2013/08/10 00:49:20 nit: mention the bug tracking this work as well.
lipalani1 2013/08/13 22:42:37 Done.
73 return "android";
74 default:
75 return "unknown";
76 }
77 }
78
66 } // namespace 79 } // namespace
67 80
68 DeviceInfo::DeviceInfo(const std::string& guid, 81 DeviceInfo::DeviceInfo(const std::string& guid,
69 const std::string& client_name, 82 const std::string& client_name,
70 const std::string& chrome_version, 83 const std::string& chrome_version,
71 const std::string& sync_user_agent, 84 const std::string& sync_user_agent,
72 const sync_pb::SyncEnums::DeviceType device_type) 85 const sync_pb::SyncEnums::DeviceType device_type)
73 : guid_(guid), 86 : guid_(guid),
74 client_name_(client_name), 87 client_name_(client_name),
75 chrome_version_(chrome_version), 88 chrome_version_(chrome_version),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } else { 178 } else {
166 user_agent += " channel(" + 179 user_agent += " channel(" +
167 ChannelToString(version_info.GetChannel()) + ")"; 180 ChannelToString(version_info.GetChannel()) + ")";
168 } 181 }
169 182
170 return user_agent; 183 return user_agent;
171 } 184 }
172 185
173 base::DictionaryValue* DeviceInfo::ToValue() { 186 base::DictionaryValue* DeviceInfo::ToValue() {
174 base::DictionaryValue* value = new base::DictionaryValue(); 187 base::DictionaryValue* value = new base::DictionaryValue();
175 value->SetString("Id", public_id_); 188 value->SetString("id", public_id_);
176 value->SetString("Client Name", client_name_); 189 value->SetString("name", client_name_);
177 value->SetString("Chrome Version", chrome_version_); 190 value->SetString("chromeVersion", chrome_version_);
178 value->SetString("Sync User Agent", sync_user_agent_); 191 value->SetString("OS", GetOS(device_type_));
Matt Perry 2013/08/12 22:21:01 lowercase "os" (notice "id" is lowercase)
lipalani1 2013/08/13 22:42:37 Done.
179 value->SetString("Device Type", DeviceTypeToString(device_type_)); 192 value->SetString("Device Type", DeviceTypeToString(device_type_));
180 return value; 193 return value;
181 } 194 }
182 195
183 void DeviceInfo::set_public_id(std::string id) { 196 void DeviceInfo::set_public_id(std::string id) {
184 public_id_ = id; 197 public_id_ = id;
185 } 198 }
186 199
187 // static. 200 // static.
188 void DeviceInfo::CreateLocalDeviceInfo( 201 void DeviceInfo::CreateLocalDeviceInfo(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 guid, 233 guid,
221 session_name, 234 session_name,
222 version_info.CreateVersionString(), 235 version_info.CreateVersionString(),
223 MakeUserAgentForSyncApi(version_info), 236 MakeUserAgentForSyncApi(version_info),
224 GetLocalDeviceType()); 237 GetLocalDeviceType());
225 238
226 callback.Run(local_info); 239 callback.Run(local_info);
227 } 240 }
228 241
229 } // namespace browser_sync 242 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698