#include "components/sync/test/test_sync_user_settings.h"
#include "build/chromeos_buildflags.h"
#include "components/sync/base/passphrase_enums.h"
#include "components/sync/base/user_selectable_type.h"
#include "components/sync/engine/nigori/nigori.h"
#include "components/sync/service/sync_prefs.h"
#include "components/sync/service/sync_service.h"
#include "components/sync/service/sync_user_settings_impl.h"
#include "components/sync/test/test_sync_service.h"
namespace syncer {
namespace {
const char kDefaultPassphrase[] = …;
}
DataTypeSet UserSelectableTypesToDataTypes(
UserSelectableTypeSet selected_types) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
DataTypeSet UserSelectableOsTypesToDataTypes(
UserSelectableOsTypeSet selected_types) {
DataTypeSet preferred_types;
for (UserSelectableOsType type : selected_types) {
preferred_types.PutAll(UserSelectableOsTypeToAllDataTypes(type));
}
return preferred_types;
}
#endif
TestSyncUserSettings::TestSyncUserSettings(TestSyncService* service)
: … { … }
TestSyncUserSettings::~TestSyncUserSettings() = default;
bool TestSyncUserSettings::IsInitialSyncFeatureSetupComplete() const { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
void TestSyncUserSettings::SetInitialSyncFeatureSetupComplete(
SyncFirstSetupCompleteSource source) { … }
#endif
bool TestSyncUserSettings::IsSyncEverythingEnabled() const { … }
void TestSyncUserSettings::SetSelectedTypes(bool sync_everything,
UserSelectableTypeSet types) { … }
void TestSyncUserSettings::SetSelectedType(UserSelectableType type,
bool is_type_on) { … }
void TestSyncUserSettings::KeepAccountSettingsPrefsOnlyForUsers(
const std::vector<signin::GaiaIdHash>& available_gaia_ids) { … }
UserSelectableTypeSet TestSyncUserSettings::GetSelectedTypes() const { … }
bool TestSyncUserSettings::IsTypeManagedByPolicy(
UserSelectableType type) const { … }
bool TestSyncUserSettings::IsTypeManagedByCustodian(
UserSelectableType type) const { … }
SyncUserSettings::UserSelectableTypePrefState
TestSyncUserSettings::GetTypePrefStateForAccount(
UserSelectableType type) const { … }
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
int TestSyncUserSettings::GetNumberOfAccountsWithPasswordsSelected() const { … }
#endif
DataTypeSet TestSyncUserSettings::GetPreferredDataTypes() const { … }
UserSelectableTypeSet TestSyncUserSettings::GetRegisteredSelectableTypes()
const { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
bool TestSyncUserSettings::IsSyncFeatureDisabledViaDashboard() const {
return sync_feature_disabled_via_dashboard_;
}
void TestSyncUserSettings::SetSyncFeatureDisabledViaDashboard(
bool disabled_via_dashboard) {
sync_feature_disabled_via_dashboard_ = disabled_via_dashboard;
}
bool TestSyncUserSettings::IsSyncAllOsTypesEnabled() const {
return sync_all_os_types_enabled_;
}
UserSelectableOsTypeSet TestSyncUserSettings::GetSelectedOsTypes() const {
return selected_os_types_;
}
bool TestSyncUserSettings::IsOsTypeManagedByPolicy(
UserSelectableOsType type) const {
return managed_os_types_.Has(type);
}
void TestSyncUserSettings::SetSelectedOsTypes(bool sync_all_os_types,
UserSelectableOsTypeSet types) {
sync_all_os_types_enabled_ = sync_all_os_types;
UserSelectableOsTypeSet selected_os_types;
if (sync_all_os_types_enabled_) {
for (UserSelectableOsType type : UserSelectableOsTypeSet::All()) {
selected_os_types.Put(type);
}
} else {
for (UserSelectableOsType type : types) {
selected_os_types.Put(type);
}
}
selected_os_types_ = selected_os_types;
}
UserSelectableOsTypeSet TestSyncUserSettings::GetRegisteredSelectableOsTypes()
const {
return UserSelectableOsTypeSet::All();
}
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
void TestSyncUserSettings::SetAppsSyncEnabledByOs(bool apps_sync_enabled) {
UserSelectableTypeSet selected_types = GetSelectedTypes();
if (apps_sync_enabled) {
selected_types.Put(UserSelectableType::kApps);
} else {
selected_types.Remove(UserSelectableType::kApps);
}
SetSelectedTypes(
false,
selected_types);
}
#endif
bool TestSyncUserSettings::IsCustomPassphraseAllowed() const { … }
void TestSyncUserSettings::SetCustomPassphraseAllowed(bool allowed) { … }
bool TestSyncUserSettings::IsEncryptEverythingEnabled() const { … }
DataTypeSet TestSyncUserSettings::GetAllEncryptedDataTypes() const { … }
bool TestSyncUserSettings::IsPassphraseRequired() const { … }
bool TestSyncUserSettings::IsPassphraseRequiredForPreferredDataTypes() const { … }
bool TestSyncUserSettings::IsPassphrasePromptMutedForCurrentProductVersion()
const { … }
void TestSyncUserSettings::MarkPassphrasePromptMutedForCurrentProductVersion() { … }
bool TestSyncUserSettings::IsTrustedVaultKeyRequired() const { … }
bool TestSyncUserSettings::IsTrustedVaultKeyRequiredForPreferredDataTypes()
const { … }
bool TestSyncUserSettings::IsTrustedVaultRecoverabilityDegraded() const { … }
bool TestSyncUserSettings::IsUsingExplicitPassphrase() const { … }
base::Time TestSyncUserSettings::GetExplicitPassphraseTime() const { … }
std::optional<PassphraseType> TestSyncUserSettings::GetPassphraseType() const { … }
void TestSyncUserSettings::SetEncryptionPassphrase(
const std::string& passphrase) { … }
bool TestSyncUserSettings::SetDecryptionPassphrase(
const std::string& passphrase) { … }
void TestSyncUserSettings::SetExplicitPassphraseDecryptionNigoriKey(
std::unique_ptr<Nigori> nigori) { … }
std::unique_ptr<Nigori>
TestSyncUserSettings::GetExplicitPassphraseDecryptionNigoriKey() const { … }
void TestSyncUserSettings::SetRegisteredSelectableTypes(
UserSelectableTypeSet types) { … }
void TestSyncUserSettings::SetInitialSyncFeatureSetupComplete() { … }
void TestSyncUserSettings::ClearInitialSyncFeatureSetupComplete() { … }
void TestSyncUserSettings::SetTypeIsManaged(UserSelectableType type,
bool managed) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
void TestSyncUserSettings::SetOsTypeIsManaged(UserSelectableOsType type,
bool managed) {
if (managed) {
managed_os_types_.Put(type);
} else {
managed_os_types_.Remove(type);
}
}
#endif
void TestSyncUserSettings::SetPassphraseRequired() { … }
void TestSyncUserSettings::SetPassphraseRequired(
const std::string& passphrase) { … }
void TestSyncUserSettings::SetTrustedVaultKeyRequired(bool required) { … }
void TestSyncUserSettings::SetTrustedVaultRecoverabilityDegraded(
bool degraded) { … }
void TestSyncUserSettings::SetIsUsingExplicitPassphrase(bool enabled) { … }
void TestSyncUserSettings::SetPassphraseType(PassphraseType type) { … }
void TestSyncUserSettings::SetExplicitPassphraseTime(base::Time t) { … }
const std::string& TestSyncUserSettings::GetEncryptionPassphrase() const { … }
bool TestSyncUserSettings::IsEncryptedDatatypePreferred() const { … }
}