QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / components / sync_driver / device_info.h
blobd2a8f49a67b4e4669661d90c31063dceb1f218ab
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SYNC_DRIVER_DEVICE_INFO_H_
6 #define COMPONENTS_SYNC_DRIVER_DEVICE_INFO_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "sync/protocol/sync.pb.h"
14 namespace base {
15 class DictionaryValue;
18 namespace sync_driver {
20 // A class that holds information regarding the properties of a device.
21 class DeviceInfo {
22 public:
23 DeviceInfo(const std::string& guid,
24 const std::string& client_name,
25 const std::string& chrome_version,
26 const std::string& sync_user_agent,
27 const sync_pb::SyncEnums::DeviceType device_type,
28 const std::string& signin_scoped_device_id);
29 ~DeviceInfo();
31 // Sync specific unique identifier for the device. Note if a device
32 // is wiped and sync is set up again this id WILL be different.
33 // The same device might have more than 1 guid if the device has multiple
34 // accounts syncing.
35 const std::string& guid() const;
37 // The host name for the client.
38 const std::string& client_name() const;
40 // Chrome version string.
41 const std::string& chrome_version() const;
43 // The user agent is the combination of OS type, chrome version and which
44 // channel of chrome(stable or beta). For more information see
45 // |LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi|.
46 const std::string& sync_user_agent() const;
48 // Third party visible id for the device. See |public_id_| for more details.
49 const std::string& public_id() const;
51 // Device Type.
52 sync_pb::SyncEnums::DeviceType device_type() const;
54 // Device_id that is stable until user signs out. This device_id is used for
55 // annotating login scoped refresh token.
56 const std::string& signin_scoped_device_id() const;
58 // Gets the OS in string form.
59 std::string GetOSString() const;
61 // Gets the device type in string form.
62 std::string GetDeviceTypeString() const;
64 // Compares this object's fields with another's.
65 bool Equals(const DeviceInfo& other) const;
67 // Apps can set ids for a device that is meaningful to them but
68 // not unique enough so the user can be tracked. Exposing |guid|
69 // would lead to a stable unique id for a device which can potentially
70 // be used for tracking.
71 void set_public_id(std::string id);
73 // Converts the |DeviceInfo| values to a JS friendly DictionaryValue,
74 // which extension APIs can expose to third party apps.
75 base::DictionaryValue* ToValue();
77 private:
78 const std::string guid_;
80 const std::string client_name_;
82 const std::string chrome_version_;
84 const std::string sync_user_agent_;
86 const sync_pb::SyncEnums::DeviceType device_type_;
88 std::string signin_scoped_device_id_;
90 // Exposing |guid| would lead to a stable unique id for a device which
91 // can potentially be used for tracking. Public ids are privacy safe
92 // ids in that the same device will have different id for different apps
93 // and they are also reset when app/extension is uninstalled.
94 std::string public_id_;
96 DISALLOW_COPY_AND_ASSIGN(DeviceInfo);
99 } // namespace sync_driver
101 #endif // COMPONENTS_SYNC_DRIVER_DEVICE_INFO_H_