Commit 28beda6b authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

[DeviceSync v2] Move ShouldUseV2DeviceSync to chromeos_features

We also add the function ShouldDeprecateV1DeviceSync for future use.

We adjust the DeviceSync service unit tests to check the Chrome OS
feature flags.

Bug: 951969, 1019206
Change-Id: I5cd8de6521131cf1cca672f4dc7b6115f93cd06a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1907834Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714490}
parent 1f5e1d17
......@@ -316,9 +316,22 @@ bool IsSplitSettingsSyncEnabled() {
return base::FeatureList::IsEnabled(kSplitSettingsSync);
}
bool ShouldDeprecateV1DeviceSync() {
return ShouldUseV2DeviceSync() &&
base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV1DeviceSyncDeprecate);
}
bool ShouldShowPlayStoreInDemoMode() {
return base::FeatureList::IsEnabled(kShowPlayInDemoMode);
}
bool ShouldUseV2DeviceSync() {
return base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV2Enrollment) &&
base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV2DeviceSync);
}
} // namespace features
} // namespace chromeos
......@@ -141,10 +141,13 @@ bool IsInstantTetheringBackgroundAdvertisingSupported();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsParentalControlsSettingsEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsSplitSettingsEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsSplitSettingsSyncEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldDeprecateV1DeviceSync();
// TODO(michaelpg): Remove after M71 branch to re-enable Play Store by default.
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldShowPlayStoreInDemoMode();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool ShouldUseV2DeviceSync();
// Keep alphabetized.
} // namespace features
......
......@@ -89,13 +89,6 @@ enum class DeviceSyncSetSoftwareFeature {
kMaxValue = kUnexpectedClientFeature
};
bool ShouldUseV2DeviceSync() {
return base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV2Enrollment) &&
base::FeatureList::IsEnabled(
chromeos::features::kCryptAuthV2DeviceSync);
}
DeviceSyncRequestFailureReason GetDeviceSyncRequestFailureReason(
mojom::NetworkRequestResult failure_reason) {
switch (failure_reason) {
......@@ -292,7 +285,7 @@ void DeviceSyncImpl::RegisterProfilePrefs(PrefRegistrySimple* registry) {
CryptAuthEnrollmentManagerImpl::RegisterPrefs(registry);
}
if (ShouldUseV2DeviceSync()) {
if (features::ShouldUseV2DeviceSync()) {
CryptAuthDeviceRegistryImpl::RegisterPrefs(registry);
}
}
......@@ -370,7 +363,7 @@ void DeviceSyncImpl::ForceSyncNow(ForceSyncNowCallback callback) {
cryptauth_device_manager_->ForceSyncNow(cryptauth::INVOCATION_REASON_MANUAL);
if (ShouldUseV2DeviceSync()) {
if (features::ShouldUseV2DeviceSync()) {
cryptauth_v2_device_manager_->ForceDeviceSyncNow(
cryptauthv2::ClientMetadata::MANUAL, base::nullopt /* session_id */);
}
......@@ -674,7 +667,7 @@ void DeviceSyncImpl::InitializeCryptAuthManagementObjects() {
clock_, cryptauth_client_factory_.get(), cryptauth_gcm_manager_.get(),
profile_prefs_);
if (ShouldUseV2DeviceSync()) {
if (features::ShouldUseV2DeviceSync()) {
cryptauth_device_registry_ =
CryptAuthDeviceRegistryImpl::Factory::Get()->BuildInstance(
profile_prefs_);
......@@ -697,7 +690,7 @@ void DeviceSyncImpl::CompleteInitializationAfterSuccessfulEnrollment() {
// Now that enrollment has completed, the current device has been registered
// with the CryptAuth back-end and can begin monitoring synced devices.
cryptauth_device_manager_->Start();
if (ShouldUseV2DeviceSync()) {
if (features::ShouldUseV2DeviceSync()) {
cryptauth_v2_device_manager_->Start();
}
......@@ -740,7 +733,7 @@ void DeviceSyncImpl::OnSetSoftwareFeatureStateSuccess() {
cryptauth_device_manager_->ForceSyncNow(
cryptauth::INVOCATION_REASON_FEATURE_TOGGLED);
if (ShouldUseV2DeviceSync()) {
if (features::ShouldUseV2DeviceSync()) {
cryptauth_v2_device_manager_->ForceDeviceSyncNow(
cryptauthv2::ClientMetadata::FEATURE_TOGGLED,
base::nullopt /* session_id */);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment