#include "components/sharing_message/sharing_sync_preference.h"
#include "base/base64.h"
#include "base/feature_list.h"
#include "base/json/values_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/sharing_message/features.h"
#include "components/sharing_message/pref_names.h"
#include "components/sharing_message/proto/sharing_message.pb.h"
#include "components/sharing_message/sharing_metrics.h"
#include "components/sync/protocol/device_info_specifics.pb.h"
#include "components/sync_device_info/device_info_sync_service.h"
#include "components/sync_device_info/local_device_info_provider.h"
#include "components/sync_preferences/pref_service_syncable.h"
namespace {
const char kVapidECPrivateKey[] = …;
const char kVapidCreationTimestamp[] = …;
const char kDeviceFcmToken[] = …;
const char kDeviceP256dh[] = …;
const char kDeviceAuthSecret[] = …;
const char kRegistrationAuthorizedEntity[] = …;
const char kRegistrationTimestamp[] = …;
const char kSharingInfoVapidTargetInfo[] = …;
const char kSharingInfoSenderIdTargetInfo[] = …;
const char kSharingInfoEnabledFeatures[] = …;
base::Value::Dict TargetInfoToValue(
const syncer::DeviceInfo::SharingTargetInfo& target_info) { … }
std::optional<syncer::DeviceInfo::SharingTargetInfo> ValueToTargetInfo(
const base::Value::Dict& dict) { … }
}
SharingSpecificFields;
SharingSyncPreference::FCMRegistration::FCMRegistration(
std::optional<std::string> authorized_entity,
base::Time timestamp)
: … { … }
SharingSyncPreference::FCMRegistration::FCMRegistration(
FCMRegistration&& other) = default;
SharingSyncPreference::FCMRegistration&
SharingSyncPreference::FCMRegistration::operator=(FCMRegistration&& other) =
default;
SharingSyncPreference::FCMRegistration::~FCMRegistration() = default;
SharingSyncPreference::SharingSyncPreference(
PrefService* prefs,
syncer::DeviceInfoSyncService* device_info_sync_service)
: … { … }
SharingSyncPreference::~SharingSyncPreference() = default;
void SharingSyncPreference::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
std::optional<std::vector<uint8_t>> SharingSyncPreference::GetVapidKey() const { … }
void SharingSyncPreference::SetVapidKey(
const std::vector<uint8_t>& vapid_key) const { … }
void SharingSyncPreference::SetVapidKeyChangeObserver(
const base::RepeatingClosure& obs) { … }
void SharingSyncPreference::ClearVapidKeyChangeObserver() { … }
std::optional<SharingSyncPreference::FCMRegistration>
SharingSyncPreference::GetFCMRegistration() const { … }
void SharingSyncPreference::SetFCMRegistration(FCMRegistration registration) { … }
void SharingSyncPreference::ClearFCMRegistration() { … }
void SharingSyncPreference::SetLocalSharingInfo(
syncer::DeviceInfo::SharingInfo sharing_info) { … }
void SharingSyncPreference::ClearLocalSharingInfo() { … }
std::optional<syncer::DeviceInfo::SharingInfo>
SharingSyncPreference::GetLocalSharingInfoForSync(PrefService* prefs) { … }