1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync_device_info/device_info.h"
#include <optional>
#include <utility>
#include "components/sync/protocol/device_info_specifics.pb.h"
#include "components/sync/protocol/sync_enums.pb.h"
namespace syncer {
bool DeviceInfo::SharingTargetInfo::operator==(
const SharingTargetInfo& other) const {
return fcm_token == other.fcm_token && p256dh == other.p256dh &&
auth_secret == other.auth_secret;
}
DeviceInfo::SharingInfo::SharingInfo(
SharingTargetInfo sender_id_target_info,
std::string chime_representative_target_id,
std::set<sync_pb::SharingSpecificFields::EnabledFeatures> enabled_features)
: sender_id_target_info(std::move(sender_id_target_info)),
chime_representative_target_id(std::move(chime_representative_target_id)),
enabled_features(std::move(enabled_features)) {}
DeviceInfo::SharingInfo::SharingInfo(const SharingInfo& other) = default;
DeviceInfo::SharingInfo::SharingInfo(SharingInfo&& other) = default;
DeviceInfo::SharingInfo& DeviceInfo::SharingInfo::operator=(
const SharingInfo& other) = default;
DeviceInfo::SharingInfo::~SharingInfo() = default;
bool DeviceInfo::SharingInfo::operator==(const SharingInfo& other) const {
return sender_id_target_info == other.sender_id_target_info &&
chime_representative_target_id ==
other.chime_representative_target_id &&
enabled_features == other.enabled_features;
}
DeviceInfo::PhoneAsASecurityKeyInfo::PhoneAsASecurityKeyInfo() = default;
DeviceInfo::PhoneAsASecurityKeyInfo::PhoneAsASecurityKeyInfo(
const DeviceInfo::PhoneAsASecurityKeyInfo& other) = default;
DeviceInfo::PhoneAsASecurityKeyInfo::PhoneAsASecurityKeyInfo(
DeviceInfo::PhoneAsASecurityKeyInfo&& other) = default;
DeviceInfo::PhoneAsASecurityKeyInfo&
DeviceInfo::PhoneAsASecurityKeyInfo::operator=(
const DeviceInfo::PhoneAsASecurityKeyInfo& other) = default;
DeviceInfo::PhoneAsASecurityKeyInfo::~PhoneAsASecurityKeyInfo() = default;
bool DeviceInfo::PhoneAsASecurityKeyInfo::NonRotatingFieldsEqual(
const PhoneAsASecurityKeyInfo& other) const {
// secret and id are deliberately not tested. This is because their values are
// based on the current time, but they should not cause an upload of the
// local device's DeviceInfo.
return tunnel_server_domain == other.tunnel_server_domain &&
contact_id == other.contact_id &&
peer_public_key_x962 == other.peer_public_key_x962;
}
DeviceInfo::DeviceInfo(
const std::string& guid,
const std::string& client_name,
const std::string& chrome_version,
const std::string& sync_user_agent,
const sync_pb::SyncEnums::DeviceType device_type,
const OsType os_type,
const FormFactor form_factor,
const std::string& signin_scoped_device_id,
const std::string& manufacturer_name,
const std::string& model_name,
const std::string& full_hardware_class,
base::Time last_updated_timestamp,
base::TimeDelta pulse_interval,
bool send_tab_to_self_receiving_enabled,
sync_pb::SyncEnums_SendTabReceivingType send_tab_to_self_receiving_type,
const std::optional<SharingInfo>& sharing_info,
const std::optional<PhoneAsASecurityKeyInfo>& paask_info,
const std::string& fcm_registration_token,
const DataTypeSet& interested_data_types,
std::optional<base::Time> floating_workspace_last_signin_timestamp)
: guid_(guid),
client_name_(client_name),
chrome_version_(chrome_version),
sync_user_agent_(sync_user_agent),
device_type_(device_type),
os_type_(os_type),
form_factor_(form_factor),
signin_scoped_device_id_(signin_scoped_device_id),
manufacturer_name_(manufacturer_name),
model_name_(model_name),
full_hardware_class_(full_hardware_class),
last_updated_timestamp_(last_updated_timestamp),
pulse_interval_(pulse_interval),
send_tab_to_self_receiving_enabled_(send_tab_to_self_receiving_enabled),
send_tab_to_self_receiving_type_(send_tab_to_self_receiving_type),
sharing_info_(sharing_info),
paask_info_(paask_info),
fcm_registration_token_(fcm_registration_token),
interested_data_types_(interested_data_types),
floating_workspace_last_signin_timestamp_(
floating_workspace_last_signin_timestamp) {}
DeviceInfo::~DeviceInfo() = default;
const std::string& DeviceInfo::guid() const {
return guid_;
}
const std::string& DeviceInfo::client_name() const {
return client_name_;
}
const std::string& DeviceInfo::chrome_version() const {
return chrome_version_;
}
const std::string& DeviceInfo::sync_user_agent() const {
return sync_user_agent_;
}
const std::string& DeviceInfo::public_id() const {
return public_id_;
}
sync_pb::SyncEnums::DeviceType DeviceInfo::device_type() const {
return device_type_;
}
DeviceInfo::OsType DeviceInfo::os_type() const {
return os_type_;
}
DeviceInfo::FormFactor DeviceInfo::form_factor() const {
return form_factor_;
}
const std::string& DeviceInfo::signin_scoped_device_id() const {
return signin_scoped_device_id_;
}
const std::string& DeviceInfo::manufacturer_name() const {
return manufacturer_name_;
}
const std::string& DeviceInfo::model_name() const {
return model_name_;
}
const std::string& DeviceInfo::full_hardware_class() const {
return full_hardware_class_;
}
base::Time DeviceInfo::last_updated_timestamp() const {
return last_updated_timestamp_;
}
base::TimeDelta DeviceInfo::pulse_interval() const {
return pulse_interval_;
}
bool DeviceInfo::send_tab_to_self_receiving_enabled() const {
return send_tab_to_self_receiving_enabled_;
}
sync_pb::SyncEnums_SendTabReceivingType
DeviceInfo::send_tab_to_self_receiving_type() const {
return send_tab_to_self_receiving_type_;
}
const std::optional<DeviceInfo::SharingInfo>& DeviceInfo::sharing_info() const {
return sharing_info_;
}
const std::optional<DeviceInfo::PhoneAsASecurityKeyInfo>&
DeviceInfo::paask_info() const {
return paask_info_;
}
const std::string& DeviceInfo::fcm_registration_token() const {
return fcm_registration_token_;
}
const DataTypeSet& DeviceInfo::interested_data_types() const {
return interested_data_types_;
}
std::optional<base::Time> DeviceInfo::floating_workspace_last_signin_timestamp()
const {
return floating_workspace_last_signin_timestamp_;
}
void DeviceInfo::set_public_id(const std::string& id) {
public_id_ = id;
}
void DeviceInfo::set_full_hardware_class(
const std::string& full_hardware_class) {
full_hardware_class_ = full_hardware_class;
}
void DeviceInfo::set_send_tab_to_self_receiving_enabled(bool new_value) {
send_tab_to_self_receiving_enabled_ = new_value;
}
void DeviceInfo::set_send_tab_to_self_receiving_type(
sync_pb::SyncEnums_SendTabReceivingType new_value) {
send_tab_to_self_receiving_type_ = new_value;
}
void DeviceInfo::set_sharing_info(
const std::optional<SharingInfo>& sharing_info) {
sharing_info_ = sharing_info;
}
void DeviceInfo::set_paask_info(
std::optional<PhoneAsASecurityKeyInfo>&& paask_info) {
paask_info_ = std::move(paask_info);
}
void DeviceInfo::set_client_name(const std::string& client_name) {
client_name_ = client_name;
}
void DeviceInfo::set_fcm_registration_token(const std::string& fcm_token) {
fcm_registration_token_ = fcm_token;
}
void DeviceInfo::set_interested_data_types(const DataTypeSet& data_types) {
interested_data_types_ = data_types;
}
void DeviceInfo::set_floating_workspace_last_signin_timestamp(
std::optional<base::Time> time) {
floating_workspace_last_signin_timestamp_ = time;
}
} // namespace syncer
|