Commit 93083e2e authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

UnifiedConsentService: fix Sync feature state checks

This includes two fixes:
1) In OnStateChanged, check CanSyncFeatureStart instead of checking for
   absence of disable reasons. CanSyncFeatureStart also implies no
   disable reasons, but additionally checks that the syncing account is
   primary, meaning that Sync the *feature* can start, not just the
   transport layer.
2) In UpdateSettingsForMigration, when determining the UKM state, add a
   check for IsSyncFeatureEnabled. The reason is that
   GetChosenDataTypes returns "all types" by default, even if Sync is
   disabled, or only the transport layer is running. So the old code
   could result in some false positives.
   This change is analogous to https://crrev.com/c/1343369.

Bug: 907027
Change-Id: Ie5eaf261b17da072dcd2cb8a596a7342e2fc8192
Reviewed-on: https://chromium-review.googlesource.com/c/1346131Reviewed-by: default avatarThomas Tangl <tangltom@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610038}
parent d12b59b9
...@@ -217,8 +217,7 @@ void UnifiedConsentService::OnPrimaryAccountCleared( ...@@ -217,8 +217,7 @@ void UnifiedConsentService::OnPrimaryAccountCleared(
} }
void UnifiedConsentService::OnStateChanged(syncer::SyncService* sync) { void UnifiedConsentService::OnStateChanged(syncer::SyncService* sync) {
if (sync_service_->GetDisableReasons() != if (!sync_service_->CanSyncFeatureStart() ||
syncer::SyncService::DISABLE_REASON_NONE ||
!sync_service_->IsEngineInitialized()) { !sync_service_->IsEngineInitialized()) {
return; return;
} }
...@@ -339,6 +338,7 @@ void UnifiedConsentService::UpdateSettingsForMigration() { ...@@ -339,6 +338,7 @@ void UnifiedConsentService::UpdateSettingsForMigration() {
// Set URL-keyed anonymized metrics to the state it had before unified // Set URL-keyed anonymized metrics to the state it had before unified
// consent. // consent.
bool url_keyed_metrics_enabled = bool url_keyed_metrics_enabled =
sync_service_->IsSyncFeatureEnabled() &&
sync_service_->GetUserSettings()->GetChosenDataTypes().Has( sync_service_->GetUserSettings()->GetChosenDataTypes().Has(
syncer::TYPED_URLS) && syncer::TYPED_URLS) &&
!sync_service_->GetUserSettings()->IsUsingSecondaryPassphrase(); !sync_service_->GetUserSettings()->IsUsingSecondaryPassphrase();
......
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