Commit 9a9c7d7f authored by Marc Treib's avatar Marc Treib Committed by Chromium LUCI CQ

Don't offer/use the password account storage if LocalSync is enabled

LocalSync means that Sync is not actually talking to the Sync server,
but instead to a local server. There might not even be a signed-in
account.
In this situation, it makes no sense to offer the account-scoped
storage - it's not going to work anyway.

Bug: 1147165
Change-Id: Ib2a50c493e03756b9ee3948907ffabf974491ce3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2637573Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844721}
parent 73492fd0
......@@ -40,6 +40,11 @@ bool CanAccountStorageBeEnabled(const syncer::SyncService* sync_service) {
if (!sync_service)
return false;
// The account-scoped password storage does not work with LocalSync aka
// roaming profiles.
if (sync_service->IsLocalSyncEnabled())
return false;
return true;
}
......
......@@ -475,6 +475,51 @@ TEST(PasswordFeatureManagerUtil, SyncDisablesAccountStorage) {
PasswordForm::Store::kProfileStore);
}
TEST(PasswordFeatureManagerUtil, LocalSyncDisablesAccountStorage) {
base::test::ScopedFeatureList features;
features.InitAndEnableFeature(features::kEnablePasswordsAccountStorage);
TestingPrefServiceSimple pref_service;
pref_service.registry()->RegisterDictionaryPref(
prefs::kAccountStoragePerAccountSettings);
CoreAccountInfo account;
account.email = "name@account.com";
account.gaia = "name";
account.account_id = CoreAccountId::FromGaiaId(account.gaia);
// The SyncService is running in local-sync mode.
syncer::TestSyncService sync_service;
// In local-sync mode, there might or might not be an account. Set one for
// this test, so that all other conditions for using the account-scoped
// storage are fulfilled.
sync_service.SetIsAuthenticatedAccountPrimary(false);
sync_service.SetAuthenticatedAccountInfo(account);
sync_service.SetLocalSyncEnabled(true);
ASSERT_EQ(sync_service.GetTransportState(),
syncer::SyncService::TransportState::ACTIVE);
ASSERT_FALSE(sync_service.IsSyncFeatureEnabled());
// The account-scoped storage should be unavailable.
ASSERT_FALSE(IsOptedInForAccountStorage(&pref_service, &sync_service));
EXPECT_FALSE(ShouldShowAccountStorageOptIn(&pref_service, &sync_service));
EXPECT_FALSE(ShouldShowAccountStorageBubbleUi(&pref_service, &sync_service));
EXPECT_EQ(GetDefaultPasswordStore(&pref_service, &sync_service),
PasswordForm::Store::kProfileStore);
// Even if the user is opted in (e.g. from a previous browser run, before
// local-sync was enabled), the account-scoped storage should remain
// unavailable.
OptInToAccountStorage(&pref_service, &sync_service);
// The user is *not* considered opted in (even though the corresponding pref
// is set) since the account storage is completely unavailable.
EXPECT_FALSE(IsOptedInForAccountStorage(&pref_service, &sync_service));
EXPECT_FALSE(ShouldShowAccountStorageOptIn(&pref_service, &sync_service));
EXPECT_FALSE(ShouldShowAccountStorageBubbleUi(&pref_service, &sync_service));
EXPECT_EQ(GetDefaultPasswordStore(&pref_service, &sync_service),
PasswordForm::Store::kProfileStore);
}
TEST(PasswordFeatureManagerUtil, OptOutClearsStorePreference) {
base::test::ScopedFeatureList features;
features.InitAndEnableFeature(features::kEnablePasswordsAccountStorage);
......
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