blob: 3e41001b4a90c184e92a02607e2deb7dd92c637c [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
skym6d5ecf82016-10-04 17:43:458#include <memory>
Alex Chau4e13d9b62019-09-30 17:09:599#include <set>
[email protected]34e98172012-10-12 04:01:3910#include <string>
11
stanisc10528752014-09-23 21:52:1912#include "base/callback.h"
avi5dd91f82015-12-25 22:30:4613#include "base/macros.h"
Alex Chau4e13d9b62019-09-30 17:09:5914#include "base/optional.h"
Sébastien Séguin-Gagnonb7cc9252019-05-09 22:00:3915#include "base/time/time.h"
Max Boguefef332d2016-07-28 22:09:0916#include "components/sync/protocol/sync.pb.h"
[email protected]34e98172012-10-12 04:01:3917
[email protected]648a5662013-07-18 20:45:4518namespace base {
19class DictionaryValue;
20}
21
maxbogue7e006db2016-10-03 19:48:2822namespace syncer {
[email protected]34e98172012-10-12 04:01:3923
24// A class that holds information regarding the properties of a device.
[email protected]34e98172012-10-12 04:01:3925class DeviceInfo {
26 public:
Alex Chau965a5a22019-11-18 16:51:5827 // A struct that holds information regarding to FCM web push.
28 struct SharingTargetInfo {
29 // FCM registration token of device.
30 std::string fcm_token;
31
32 // Public key for Sharing message encryption[RFC8291].
33 std::string p256dh;
34
35 // Auth secret for Sharing message encryption[RFC8291].
36 std::string auth_secret;
37
38 bool operator==(const SharingTargetInfo& other) const;
39 };
40
41 // A struct that holds information regarding to Sharing features.
Alex Chau4e13d9b62019-09-30 17:09:5942 struct SharingInfo {
Alex Chau965a5a22019-11-18 16:51:5843 SharingInfo(SharingTargetInfo vapid_target_info,
44 SharingTargetInfo sharing_target_info,
Alex Chau4e13d9b62019-09-30 17:09:5945 std::set<sync_pb::SharingSpecificFields::EnabledFeatures>
46 enabled_features);
47 SharingInfo(const SharingInfo& other);
48 SharingInfo(SharingInfo&& other);
49 SharingInfo& operator=(const SharingInfo& other);
50 ~SharingInfo();
51
Alex Chau965a5a22019-11-18 16:51:5852 // Target info using VAPID key.
53 // TODO(crbug.com/1012226): Deprecate when VAPID migration is over.
54 SharingTargetInfo vapid_target_info;
Alex Chauf1de5182019-11-14 14:19:1655
Alex Chau965a5a22019-11-18 16:51:5856 // Target info using Sharing sender ID.
57 SharingTargetInfo sender_id_target_info;
Alex Chau4e13d9b62019-09-30 17:09:5958
59 // Set of Sharing features enabled on the device.
60 std::set<sync_pb::SharingSpecificFields::EnabledFeatures> enabled_features;
61
62 bool operator==(const SharingInfo& other) const;
63 };
64
[email protected]1e281a42013-07-16 23:04:0865 DeviceInfo(const std::string& guid,
66 const std::string& client_name,
[email protected]34e98172012-10-12 04:01:3967 const std::string& chrome_version,
68 const std::string& sync_user_agent,
[email protected]e0ec8ba2014-07-18 23:38:0469 const sync_pb::SyncEnums::DeviceType device_type,
Tanya Guptac1dec1c2019-04-18 22:56:0570 const std::string& signin_scoped_device_id,
Richard Knoll5b608be2020-07-10 08:39:4071 const std::string& manufacturer_name,
72 const std::string& model_name,
Sébastien Séguin-Gagnonb7cc9252019-05-09 22:00:3973 base::Time last_updated_timestamp,
Michael van Ouwerkerka91ab6e2020-02-03 12:55:3874 base::TimeDelta pulse_interval,
Alex Chau4e13d9b62019-09-30 17:09:5975 bool send_tab_to_self_receiving_enabled,
76 const base::Optional<SharingInfo>& sharing_info);
[email protected]34e98172012-10-12 04:01:3977 ~DeviceInfo();
78
[email protected]1e281a42013-07-16 23:04:0879 // Sync specific unique identifier for the device. Note if a device
80 // is wiped and sync is set up again this id WILL be different.
81 // The same device might have more than 1 guid if the device has multiple
82 // accounts syncing.
83 const std::string& guid() const;
84
85 // The host name for the client.
[email protected]34e98172012-10-12 04:01:3986 const std::string& client_name() const;
[email protected]1e281a42013-07-16 23:04:0887
88 // Chrome version string.
[email protected]34e98172012-10-12 04:01:3989 const std::string& chrome_version() const;
[email protected]1e281a42013-07-16 23:04:0890
91 // The user agent is the combination of OS type, chrome version and which
92 // channel of chrome(stable or beta). For more information see
stanisc10528752014-09-23 21:52:1993 // |LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi|.
[email protected]34e98172012-10-12 04:01:3994 const std::string& sync_user_agent() const;
[email protected]1e281a42013-07-16 23:04:0895
[email protected]790daf5c2013-07-31 18:42:5796 // Third party visible id for the device. See |public_id_| for more details.
97 const std::string& public_id() const;
98
[email protected]1e281a42013-07-16 23:04:0899 // Device Type.
[email protected]34e98172012-10-12 04:01:39100 sync_pb::SyncEnums::DeviceType device_type() const;
101
[email protected]e0ec8ba2014-07-18 23:38:04102 // Device_id that is stable until user signs out. This device_id is used for
103 // annotating login scoped refresh token.
104 const std::string& signin_scoped_device_id() const;
105
Richard Knoll5b608be2020-07-10 08:39:40106 // The device manufacturer name.
107 const std::string& manufacturer_name() const;
108
109 // The device model name.
110 const std::string& model_name() const;
Himanshu Jaju0ddf2c132019-10-10 16:22:28111
Sébastien Séguin-Gagnonb7cc9252019-05-09 22:00:39112 // Returns the time at which this device was last updated to the sync servers.
113 base::Time last_updated_timestamp() const;
114
Michael van Ouwerkerka91ab6e2020-02-03 12:55:38115 // Returns the interval with which this device is updated to the sync servers
116 // if online and while sync is actively running (e.g. excludes backgrounded
117 // apps on Android).
118 base::TimeDelta pulse_interval() const;
119
Tanya Guptac1dec1c2019-04-18 22:56:05120 // Whether the receiving side of the SendTabToSelf feature is enabled.
121 bool send_tab_to_self_receiving_enabled() const;
122
Alex Chau4e13d9b62019-09-30 17:09:59123 // Returns Sharing related info of the device.
124 const base::Optional<SharingInfo>& sharing_info() const;
125
[email protected]f32d8ce2013-09-24 04:38:40126 // Gets the OS in string form.
127 std::string GetOSString() const;
128
129 // Gets the device type in string form.
130 std::string GetDeviceTypeString() const;
131
[email protected]34e98172012-10-12 04:01:39132 // Compares this object's fields with another's.
133 bool Equals(const DeviceInfo& other) const;
134
[email protected]648a5662013-07-18 20:45:45135 // Apps can set ids for a device that is meaningful to them but
136 // not unique enough so the user can be tracked. Exposing |guid|
137 // would lead to a stable unique id for a device which can potentially
138 // be used for tracking.
ki.stfu939799a42015-09-28 04:41:20139 void set_public_id(const std::string& id);
[email protected]648a5662013-07-18 20:45:45140
Tanya Guptac1dec1c2019-04-18 22:56:05141 void set_send_tab_to_self_receiving_enabled(bool new_value);
142
Alex Chau4e13d9b62019-09-30 17:09:59143 void set_sharing_info(const base::Optional<SharingInfo>& sharing_info);
144
Himanshu Jajuf2c5d732019-10-21 14:52:33145 void set_client_name(const std::string& client_name);
146
[email protected]648a5662013-07-18 20:45:45147 // Converts the |DeviceInfo| values to a JS friendly DictionaryValue,
148 // which extension APIs can expose to third party apps.
Richard Knoll5b608be2020-07-10 08:39:40149 std::unique_ptr<base::DictionaryValue> ToValue() const;
[email protected]648a5662013-07-18 20:45:45150
[email protected]34e98172012-10-12 04:01:39151 private:
[email protected]1e281a42013-07-16 23:04:08152 const std::string guid_;
153
Himanshu Jajuf2c5d732019-10-21 14:52:33154 std::string client_name_;
[email protected]1e281a42013-07-16 23:04:08155
[email protected]34e98172012-10-12 04:01:39156 const std::string chrome_version_;
[email protected]1e281a42013-07-16 23:04:08157
[email protected]34e98172012-10-12 04:01:39158 const std::string sync_user_agent_;
[email protected]1e281a42013-07-16 23:04:08159
[email protected]34e98172012-10-12 04:01:39160 const sync_pb::SyncEnums::DeviceType device_type_;
[email protected]16b85e82012-11-21 04:16:33161
Richard Knoll5b608be2020-07-10 08:39:40162 const std::string signin_scoped_device_id_;
[email protected]e0ec8ba2014-07-18 23:38:04163
[email protected]790daf5c2013-07-31 18:42:57164 // Exposing |guid| would lead to a stable unique id for a device which
165 // can potentially be used for tracking. Public ids are privacy safe
166 // ids in that the same device will have different id for different apps
167 // and they are also reset when app/extension is uninstalled.
[email protected]648a5662013-07-18 20:45:45168 std::string public_id_;
169
Richard Knoll5b608be2020-07-10 08:39:40170 const std::string manufacturer_name_;
171
172 const std::string model_name_;
Himanshu Jaju0ddf2c132019-10-10 16:22:28173
Sébastien Séguin-Gagnonb7cc9252019-05-09 22:00:39174 const base::Time last_updated_timestamp_;
175
Michael van Ouwerkerka91ab6e2020-02-03 12:55:38176 const base::TimeDelta pulse_interval_;
177
Tanya Guptac1dec1c2019-04-18 22:56:05178 bool send_tab_to_self_receiving_enabled_;
179
Alex Chau4e13d9b62019-09-30 17:09:59180 base::Optional<SharingInfo> sharing_info_;
181
[email protected]16b85e82012-11-21 04:16:33182 DISALLOW_COPY_AND_ASSIGN(DeviceInfo);
[email protected]34e98172012-10-12 04:01:39183};
184
maxbogue7e006db2016-10-03 19:48:28185} // namespace syncer
[email protected]34e98172012-10-12 04:01:39186
maxboguef1885f7d2016-08-16 19:13:20187#endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_H_