OLD | NEW |
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 #ifndef CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 namespace browser_sync { | 22 namespace browser_sync { |
23 | 23 |
24 // A class that holds information regarding the properties of a device. | 24 // A class that holds information regarding the properties of a device. |
25 class DeviceInfo { | 25 class DeviceInfo { |
26 public: | 26 public: |
27 DeviceInfo(const std::string& guid, | 27 DeviceInfo(const std::string& guid, |
28 const std::string& client_name, | 28 const std::string& client_name, |
29 const std::string& chrome_version, | 29 const std::string& chrome_version, |
30 const std::string& sync_user_agent, | 30 const std::string& sync_user_agent, |
31 const sync_pb::SyncEnums::DeviceType device_type); | 31 const sync_pb::SyncEnums::DeviceType device_type, |
| 32 const std::string& signin_scoped_device_id); |
32 ~DeviceInfo(); | 33 ~DeviceInfo(); |
33 | 34 |
34 // Sync specific unique identifier for the device. Note if a device | 35 // Sync specific unique identifier for the device. Note if a device |
35 // is wiped and sync is set up again this id WILL be different. | 36 // is wiped and sync is set up again this id WILL be different. |
36 // The same device might have more than 1 guid if the device has multiple | 37 // The same device might have more than 1 guid if the device has multiple |
37 // accounts syncing. | 38 // accounts syncing. |
38 const std::string& guid() const; | 39 const std::string& guid() const; |
39 | 40 |
40 // The host name for the client. | 41 // The host name for the client. |
41 const std::string& client_name() const; | 42 const std::string& client_name() const; |
42 | 43 |
43 // Chrome version string. | 44 // Chrome version string. |
44 const std::string& chrome_version() const; | 45 const std::string& chrome_version() const; |
45 | 46 |
46 // The user agent is the combination of OS type, chrome version and which | 47 // The user agent is the combination of OS type, chrome version and which |
47 // channel of chrome(stable or beta). For more information see | 48 // channel of chrome(stable or beta). For more information see |
48 // |DeviceInfo::MakeUserAgentForSyncApi|. | 49 // |DeviceInfo::MakeUserAgentForSyncApi|. |
49 const std::string& sync_user_agent() const; | 50 const std::string& sync_user_agent() const; |
50 | 51 |
51 // Third party visible id for the device. See |public_id_| for more details. | 52 // Third party visible id for the device. See |public_id_| for more details. |
52 const std::string& public_id() const; | 53 const std::string& public_id() const; |
53 | 54 |
54 // Device Type. | 55 // Device Type. |
55 sync_pb::SyncEnums::DeviceType device_type() const; | 56 sync_pb::SyncEnums::DeviceType device_type() const; |
56 | 57 |
| 58 // Device_id that is stable until user signs out. This device_id is used for |
| 59 // annotating login scoped refresh token. |
| 60 const std::string& signin_scoped_device_id() const; |
| 61 |
57 // Gets the OS in string form. | 62 // Gets the OS in string form. |
58 std::string GetOSString() const; | 63 std::string GetOSString() const; |
59 | 64 |
60 // Gets the device type in string form. | 65 // Gets the device type in string form. |
61 std::string GetDeviceTypeString() const; | 66 std::string GetDeviceTypeString() const; |
62 | 67 |
63 // Compares this object's fields with another's. | 68 // Compares this object's fields with another's. |
64 bool Equals(const DeviceInfo& other) const; | 69 bool Equals(const DeviceInfo& other) const; |
65 | 70 |
66 // Apps can set ids for a device that is meaningful to them but | 71 // Apps can set ids for a device that is meaningful to them but |
67 // not unique enough so the user can be tracked. Exposing |guid| | 72 // not unique enough so the user can be tracked. Exposing |guid| |
68 // would lead to a stable unique id for a device which can potentially | 73 // would lead to a stable unique id for a device which can potentially |
69 // be used for tracking. | 74 // be used for tracking. |
70 void set_public_id(std::string id); | 75 void set_public_id(std::string id); |
71 | 76 |
72 // Converts the |DeviceInfo| values to a JS friendly DictionaryValue, | 77 // Converts the |DeviceInfo| values to a JS friendly DictionaryValue, |
73 // which extension APIs can expose to third party apps. | 78 // which extension APIs can expose to third party apps. |
74 base::DictionaryValue* ToValue(); | 79 base::DictionaryValue* ToValue(); |
75 | 80 |
76 static sync_pb::SyncEnums::DeviceType GetLocalDeviceType(); | 81 static sync_pb::SyncEnums::DeviceType GetLocalDeviceType(); |
77 | 82 |
78 // Creates a |DeviceInfo| object representing the local device and passes | 83 // Creates a |DeviceInfo| object representing the local device and passes |
79 // it as parameter to the callback. | 84 // it as parameter to the callback. |
80 static void CreateLocalDeviceInfo( | 85 static void CreateLocalDeviceInfo( |
81 const std::string& guid, | 86 const std::string& guid, |
| 87 const std::string& signin_scoped_device_id, |
82 base::Callback<void(const DeviceInfo& local_info)> callback); | 88 base::Callback<void(const DeviceInfo& local_info)> callback); |
83 | 89 |
84 // Gets the local device name and passes it as a parameter to callback. | 90 // Gets the local device name and passes it as a parameter to callback. |
85 static void GetClientName( | 91 static void GetClientName( |
86 base::Callback<void(const std::string& local_info)> callback); | 92 base::Callback<void(const std::string& local_info)> callback); |
87 | 93 |
88 // Helper to construct a user agent string (ASCII) suitable for use by | 94 // Helper to construct a user agent string (ASCII) suitable for use by |
89 // the syncapi for any HTTP communication. This string is used by the sync | 95 // the syncapi for any HTTP communication. This string is used by the sync |
90 // backend for classifying client types when calculating statistics. | 96 // backend for classifying client types when calculating statistics. |
91 static std::string MakeUserAgentForSyncApi( | 97 static std::string MakeUserAgentForSyncApi( |
92 const chrome::VersionInfo& version_info); | 98 const chrome::VersionInfo& version_info); |
93 | 99 |
94 private: | 100 private: |
95 static void GetClientNameContinuation( | 101 static void GetClientNameContinuation( |
96 base::Callback<void(const std::string& local_info)> callback, | 102 base::Callback<void(const std::string& local_info)> callback, |
97 const std::string& session_name); | 103 const std::string& session_name); |
98 | 104 |
99 static void CreateLocalDeviceInfoContinuation( | 105 static void CreateLocalDeviceInfoContinuation( |
100 const std::string& guid, | 106 const std::string& guid, |
| 107 const std::string& signin_scoped_device_id, |
101 base::Callback<void(const DeviceInfo& local_info)> callback, | 108 base::Callback<void(const DeviceInfo& local_info)> callback, |
102 const std::string& session_name); | 109 const std::string& session_name); |
103 | 110 |
104 const std::string guid_; | 111 const std::string guid_; |
105 | 112 |
106 const std::string client_name_; | 113 const std::string client_name_; |
107 | 114 |
108 const std::string chrome_version_; | 115 const std::string chrome_version_; |
109 | 116 |
110 const std::string sync_user_agent_; | 117 const std::string sync_user_agent_; |
111 | 118 |
112 const sync_pb::SyncEnums::DeviceType device_type_; | 119 const sync_pb::SyncEnums::DeviceType device_type_; |
113 | 120 |
| 121 std::string signin_scoped_device_id_; |
| 122 |
114 // Exposing |guid| would lead to a stable unique id for a device which | 123 // Exposing |guid| would lead to a stable unique id for a device which |
115 // can potentially be used for tracking. Public ids are privacy safe | 124 // can potentially be used for tracking. Public ids are privacy safe |
116 // ids in that the same device will have different id for different apps | 125 // ids in that the same device will have different id for different apps |
117 // and they are also reset when app/extension is uninstalled. | 126 // and they are also reset when app/extension is uninstalled. |
118 std::string public_id_; | 127 std::string public_id_; |
119 | 128 |
120 DISALLOW_COPY_AND_ASSIGN(DeviceInfo); | 129 DISALLOW_COPY_AND_ASSIGN(DeviceInfo); |
121 }; | 130 }; |
122 | 131 |
123 } // namespace browser_sync | 132 } // namespace browser_sync |
124 | 133 |
125 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ | 134 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ |
OLD | NEW |