Commit 86b9c6a7 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

syncer::GetUploadToGoogleState: Check Sync-the-feature state

This makes sure we don't claim to have consent (or at least be
INITIALIZING) when we're running in standalone transport mode.
In practice, this probably wasn't a problem, since most data types
are disabled in transport mode anyway, but let's be cautious here.

Bug: 856081, 906609, 871221
Change-Id: Ie6d2d0ef4f81d0f51d66ddd9a2d55daba2c1093e
Reviewed-on: https://chromium-review.googlesource.com/c/1341916
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarFlorian Uunk <feuunk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609310}
parent 2e5437f5
......@@ -17,6 +17,7 @@ UploadState GetUploadToGoogleState(const SyncService* sync_service,
// "everything" (i.e. the default setting). If a data type is missing there,
// it must be because the user explicitly disabled it.
if (!sync_service || sync_service->IsLocalSyncEnabled() ||
!sync_service->CanSyncFeatureStart() ||
!sync_service->GetPreferredDataTypes().Has(type)) {
return UploadState::NOT_ACTIVE;
}
......
......@@ -195,4 +195,28 @@ TEST(SyncServiceUtilsTest, UploadToGoogleDisabledIfCustomPassphraseInUse) {
GetUploadToGoogleState(&service, syncer::DEVICE_INFO));
}
TEST(SyncServiceUtilsTest, UploadToGoogleDisabledForSecondaryAccount) {
TestSyncService service;
service.SetDisableReasons(syncer::SyncService::DISABLE_REASON_NONE);
service.SetPreferredDataTypes(ProtocolTypes());
service.SetActiveDataTypes(ProtocolTypes());
service.SetTransportState(syncer::SyncService::TransportState::ACTIVE);
service.SetNonEmptyLastCycleSnapshot();
// Sanity check: Everything's looking good, so upload is considered active.
ASSERT_EQ(UploadState::ACTIVE,
GetUploadToGoogleState(&service, syncer::BOOKMARKS));
// Mark the syncing account as non-primary. With this, only Sync-the-transport
// (not Sync-the-feature) can run.
service.SetIsAuthenticatedAccountPrimary(false);
ASSERT_FALSE(service.CanSyncFeatureStart());
// Upload should NOT be active now. Even though the data type is active, we're
// running in standalone transport mode, so we don't have consent for
// uploading.
EXPECT_EQ(UploadState::NOT_ACTIVE,
GetUploadToGoogleState(&service, syncer::BOOKMARKS));
}
} // namespace syncer
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