blob: c16d57e97fbb4315ef03a9efd2091680ae056d18 [file] [log] [blame]
[email protected]34e98172012-10-12 04:01:391// 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.
4
maxboguef1885f7d2016-08-16 19:13:205#ifndef COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_H_
6#define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_H_
[email protected]34e98172012-10-12 04:01:397
Adam Langley1b4e4a62021-03-25 23:07:398#include <array>
skym6d5ecf82016-10-04 17:43:459#include <memory>
Alex Chau4e13d9b62019-09-30 17:09:5910#include <set>
[email protected]34e98172012-10-12 04:01:3911#include <string>
12
stanisc10528752014-09-23 21:52:1913#include "base/callback.h"
avi5dd91f82015-12-25 22:30:4614#include "base/macros.h"
Alex Chau4e13d9b62019-09-30 17:09:5915#include "base/optional.h"
Sébastien Séguin-Gagnonb7cc9252019-05-09 22:00:3916#include "base/time/time.h"
Paula Vidasd3c720e62020-09-03 07:20:0617#include "components/sync/base/model_type.h"
Max Boguefef332d2016-07-28 22:09:0918#include "components/sync/protocol/sync.pb.h"
[email protected]34e98172012-10-12 04:01:3919
[email protected]648a5662013-07-18 20:45:4520namespace base {
21class DictionaryValue;
22}
23
maxbogue7e006db2016-10-03 19:48:2824namespace syncer {
[email protected]34e98172012-10-12 04:01:3925
26// A class that holds information regarding the properties of a device.
[email protected]34e98172012-10-12 04:01:3927class DeviceInfo {
28 public:
Alex Chau965a5a22019-11-18 16:51:5829 // A struct that holds information regarding to FCM web push.
30 struct SharingTargetInfo {
31 // FCM registration token of device.
32 std::string fcm_token;
33
34 // Public key for Sharing message encryption[RFC8291].
35 std::string p256dh;
36
37 // Auth secret for Sharing message encryption[RFC8291].
38 std::string auth_secret;
39
40 bool operator==(const SharingTargetInfo& other) const;
41 };
42
43 // A struct that holds information regarding to Sharing features.
Alex Chau4e13d9b62019-09-30 17:09:5944 struct SharingInfo {
Alex Chau965a5a22019-11-18 16:51:5845 SharingInfo(SharingTargetInfo vapid_target_info,
46 SharingTargetInfo sharing_target_info,
Alex Chau4e13d9b62019-09-30 17:09:5947 std::set<sync_pb::SharingSpecificFields::EnabledFeatures>
48 enabled_features);
49 SharingInfo(const SharingInfo& other);
50 SharingInfo(SharingInfo&& other);
51 SharingInfo& operator=(const SharingInfo& other);
52 ~SharingInfo();
53
Alex Chau965a5a22019-11-18 16:51:5854 // Target info using VAPID key.
55 // TODO(crbug.com/1012226): Deprecate when VAPID migration is over.
56 SharingTargetInfo vapid_target_info;
Alex Chauf1de5182019-11-14 14:19:1657
Alex Chau965a5a22019-11-18 16:51:5858 // Target info using Sharing sender ID.
59 SharingTargetInfo sender_id_target_info;
Alex Chau4e13d9b62019-09-30 17:09:5960
61 // Set of Sharing features enabled on the device.
62 std::set<sync_pb::SharingSpecificFields::EnabledFeatures> enabled_features;
63
64 bool operator==(const SharingInfo& other) const;
65 };
66
Adam Langley1b4e4a62021-03-25 23:07:3967 struct PhoneAsASecurityKeyInfo {
68 PhoneAsASecurityKeyInfo();
69 PhoneAsASecurityKeyInfo(const PhoneAsASecurityKeyInfo& other);
70 PhoneAsASecurityKeyInfo(PhoneAsASecurityKeyInfo&& other);
71 PhoneAsASecurityKeyInfo& operator=(const PhoneAsASecurityKeyInfo& other);
72 ~PhoneAsASecurityKeyInfo();
73
74 bool operator==(const PhoneAsASecurityKeyInfo& other) const;
75
76 // The domain of the tunnel service. See
77 // |device::cablev2::tunnelserver::DecodeDomain| to decode this value.
78 uint16_t tunnel_server_domain;
79 // contact_id is an opaque value that is sent to the tunnel service in order
80 // to identify the caBLEv2 authenticator.
81 std::vector<uint8_t> contact_id;
82 // secret is the shared secret that authenticates the desktop to the
83 // authenticator.
84 std::array<uint8_t, 32> secret;
85 // id identifies the secret so that the phone knows which secret to use
86 // for a given connection.
87 uint32_t id;
88 // peer_public_key_x962 is the authenticator's public key.
89 std::array<uint8_t, 65> peer_public_key_x962;
90 };
91
[email protected]1e281a42013-07-16 23:04:0892 DeviceInfo(const std::string& guid,
93 const std::string& client_name,
[email protected]34e98172012-10-12 04:01:3994 const std::string& chrome_version,
95 const std::string& sync_user_agent,
[email protected]e0ec8ba2014-07-18 23:38:0496 const sync_pb::SyncEnums::DeviceType device_type,
Tanya Guptac1dec1c2019-04-18 22:56:0597 const std::string& signin_scoped_device_id,
Richard Knoll5b608be2020-07-10 08:39:4098 const std::string& manufacturer_name,
99 const std::string& model_name,
Hirthanan Subenderane6657f72021-04-16 10:43:12100 const std::string& full_hardware_class,
Sébastien Séguin-Gagnonb7cc9252019-05-09 22:00:39101 base::Time last_updated_timestamp,
Michael van Ouwerkerka91ab6e2020-02-03 12:55:38102 base::TimeDelta pulse_interval,
Alex Chau4e13d9b62019-09-30 17:09:59103 bool send_tab_to_self_receiving_enabled,
Rushan Suleymanov74e7ee2592020-08-02 19:30:40104 const base::Optional<SharingInfo>& sharing_info,
Adam Langley1b4e4a62021-03-25 23:07:39105 const base::Optional<PhoneAsASecurityKeyInfo>& paask_info,
Paula Vidasd3c720e62020-09-03 07:20:06106 const std::string& fcm_registration_token,
107 const ModelTypeSet& interested_data_types);
[email protected]34e98172012-10-12 04:01:39108 ~DeviceInfo();
109
[email protected]1e281a42013-07-16 23:04:08110 // Sync specific unique identifier for the device. Note if a device
111 // is wiped and sync is set up again this id WILL be different.
112 // The same device might have more than 1 guid if the device has multiple
113 // accounts syncing.
114 const std::string& guid() const;
115
116 // The host name for the client.
[email protected]34e98172012-10-12 04:01:39117 const std::string& client_name() const;
[email protected]1e281a42013-07-16 23:04:08118
119 // Chrome version string.
[email protected]34e98172012-10-12 04:01:39120 const std::string& chrome_version() const;
[email protected]1e281a42013-07-16 23:04:08121
122 // The user agent is the combination of OS type, chrome version and which
123 // channel of chrome(stable or beta). For more information see
stanisc10528752014-09-23 21:52:19124 // |LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi|.
[email protected]34e98172012-10-12 04:01:39125 const std::string& sync_user_agent() const;
[email protected]1e281a42013-07-16 23:04:08126
[email protected]790daf5c2013-07-31 18:42:57127 // Third party visible id for the device. See |public_id_| for more details.
128 const std::string& public_id() const;
129
[email protected]1e281a42013-07-16 23:04:08130 // Device Type.
[email protected]34e98172012-10-12 04:01:39131 sync_pb::SyncEnums::DeviceType device_type() const;
132
[email protected]e0ec8ba2014-07-18 23:38:04133 // Device_id that is stable until user signs out. This device_id is used for
134 // annotating login scoped refresh token.
135 const std::string& signin_scoped_device_id() const;
136
Richard Knoll5b608be2020-07-10 08:39:40137 // The device manufacturer name.
138 const std::string& manufacturer_name() const;
139
140 // The device model name.
141 const std::string& model_name() const;
Himanshu Jaju0ddf2c132019-10-10 16:22:28142
Hirthanan Subenderane6657f72021-04-16 10:43:12143 // Returns unique hardware class string which details the
144 // HW combination of a ChromeOS device. Returns empty on other OS devices or
145 // when UMA is disabled.
146 const std::string& full_hardware_class() const;
147
Sébastien Séguin-Gagnonb7cc9252019-05-09 22:00:39148 // Returns the time at which this device was last updated to the sync servers.
149 base::Time last_updated_timestamp() const;
150
Michael van Ouwerkerka91ab6e2020-02-03 12:55:38151 // Returns the interval with which this device is updated to the sync servers
152 // if online and while sync is actively running (e.g. excludes backgrounded
153 // apps on Android).
154 base::TimeDelta pulse_interval() const;
155
Tanya Guptac1dec1c2019-04-18 22:56:05156 // Whether the receiving side of the SendTabToSelf feature is enabled.
157 bool send_tab_to_self_receiving_enabled() const;
158
Alex Chau4e13d9b62019-09-30 17:09:59159 // Returns Sharing related info of the device.
160 const base::Optional<SharingInfo>& sharing_info() const;
161
Adam Langley1b4e4a62021-03-25 23:07:39162 const base::Optional<PhoneAsASecurityKeyInfo>& paask_info() const;
163
Rushan Suleymanov74e7ee2592020-08-02 19:30:40164 // Returns the FCM registration token for sync invalidations.
165 const std::string& fcm_registration_token() const;
166
Paula Vidasd3c720e62020-09-03 07:20:06167 // Returns the data types for which this device receives invalidations.
168 const ModelTypeSet& interested_data_types() const;
169
[email protected]f32d8ce2013-09-24 04:38:40170 // Gets the OS in string form.
171 std::string GetOSString() const;
172
173 // Gets the device type in string form.
174 std::string GetDeviceTypeString() const;
175
[email protected]34e98172012-10-12 04:01:39176 // Compares this object's fields with another's.
177 bool Equals(const DeviceInfo& other) const;
178
[email protected]648a5662013-07-18 20:45:45179 // Apps can set ids for a device that is meaningful to them but
180 // not unique enough so the user can be tracked. Exposing |guid|
181 // would lead to a stable unique id for a device which can potentially
182 // be used for tracking.
ki.stfu939799a42015-09-28 04:41:20183 void set_public_id(const std::string& id);
[email protected]648a5662013-07-18 20:45:45184
Hirthanan Subenderane6657f72021-04-16 10:43:12185 void set_full_hardware_class(const std::string& full_hardware_class);
186
Tanya Guptac1dec1c2019-04-18 22:56:05187 void set_send_tab_to_self_receiving_enabled(bool new_value);
188
Alex Chau4e13d9b62019-09-30 17:09:59189 void set_sharing_info(const base::Optional<SharingInfo>& sharing_info);
190
Adam Langley1b4e4a62021-03-25 23:07:39191 void set_paask_info(PhoneAsASecurityKeyInfo&& paask_info);
192
Himanshu Jajuf2c5d732019-10-21 14:52:33193 void set_client_name(const std::string& client_name);
194
Rushan Suleymanov74e7ee2592020-08-02 19:30:40195 void set_fcm_registration_token(const std::string& fcm_token);
196
Paula Vidasd3c720e62020-09-03 07:20:06197 void set_interested_data_types(const ModelTypeSet& data_types);
198
[email protected]648a5662013-07-18 20:45:45199 // Converts the |DeviceInfo| values to a JS friendly DictionaryValue,
200 // which extension APIs can expose to third party apps.
Richard Knoll5b608be2020-07-10 08:39:40201 std::unique_ptr<base::DictionaryValue> ToValue() const;
[email protected]648a5662013-07-18 20:45:45202
[email protected]34e98172012-10-12 04:01:39203 private:
[email protected]1e281a42013-07-16 23:04:08204 const std::string guid_;
205
Himanshu Jajuf2c5d732019-10-21 14:52:33206 std::string client_name_;
[email protected]1e281a42013-07-16 23:04:08207
[email protected]34e98172012-10-12 04:01:39208 const std::string chrome_version_;
[email protected]1e281a42013-07-16 23:04:08209
[email protected]34e98172012-10-12 04:01:39210 const std::string sync_user_agent_;
[email protected]1e281a42013-07-16 23:04:08211
[email protected]34e98172012-10-12 04:01:39212 const sync_pb::SyncEnums::DeviceType device_type_;
[email protected]16b85e82012-11-21 04:16:33213
Richard Knoll5b608be2020-07-10 08:39:40214 const std::string signin_scoped_device_id_;
[email protected]e0ec8ba2014-07-18 23:38:04215
[email protected]790daf5c2013-07-31 18:42:57216 // Exposing |guid| would lead to a stable unique id for a device which
217 // can potentially be used for tracking. Public ids are privacy safe
218 // ids in that the same device will have different id for different apps
219 // and they are also reset when app/extension is uninstalled.
[email protected]648a5662013-07-18 20:45:45220 std::string public_id_;
221
Richard Knoll5b608be2020-07-10 08:39:40222 const std::string manufacturer_name_;
223
224 const std::string model_name_;
Himanshu Jaju0ddf2c132019-10-10 16:22:28225
Hirthanan Subenderane6657f72021-04-16 10:43:12226 std::string full_hardware_class_;
227
Sébastien Séguin-Gagnonb7cc9252019-05-09 22:00:39228 const base::Time last_updated_timestamp_;
229
Michael van Ouwerkerka91ab6e2020-02-03 12:55:38230 const base::TimeDelta pulse_interval_;
231
Tanya Guptac1dec1c2019-04-18 22:56:05232 bool send_tab_to_self_receiving_enabled_;
233
Alex Chau4e13d9b62019-09-30 17:09:59234 base::Optional<SharingInfo> sharing_info_;
235
Adam Langley1b4e4a62021-03-25 23:07:39236 base::Optional<PhoneAsASecurityKeyInfo> paask_info_;
237
Rushan Suleymanov74e7ee2592020-08-02 19:30:40238 // An FCM registration token obtained by sync invalidations service.
239 std::string fcm_registration_token_;
240
Paula Vidasd3c720e62020-09-03 07:20:06241 // Data types for which this device receives invalidations.
242 ModelTypeSet interested_data_types_;
243
[email protected]16b85e82012-11-21 04:16:33244 DISALLOW_COPY_AND_ASSIGN(DeviceInfo);
[email protected]34e98172012-10-12 04:01:39245};
246
maxbogue7e006db2016-10-03 19:48:28247} // namespace syncer
[email protected]34e98172012-10-12 04:01:39248
maxboguef1885f7d2016-08-16 19:13:20249#endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_H_