Commit ea8d660c authored by James Cook's avatar James Cook Committed by Commit Bot

cros: Migrate multidevice features to unconsented primary account

SplitSettingsSync will allow the user to opt-out of browser sync.
However, IdentityAccessor::GetPrimaryAccountInfo() assumes the user has
consented to browser sync. Multidevice features aren't tied to browser
sync consent.

Switch to using the "unconsented" primary account. On Chrome OS this
account always exists for the logged-in user account, whether or not
the user consented to browser sync.

See go/cros-sync-mock and go/cros-primary-account for details.

  no errors in chrome://proximity-auth
  SplitSettingsSync, no errors in chrome://proximity-auth

Bug: 1042400
Test: Multidevice setup works for new account with SplitSettingsSync,
Test: Multidevice settings work for existing account with
Test: updated chromeos_unittests
Change-Id: I53171f3ba6a308c1af0da7a1092254e06f679bec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036786Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738007}
parent 2695fca3
...@@ -390,7 +390,9 @@ DeviceSyncImpl::DeviceSyncImpl( ...@@ -390,7 +390,9 @@ DeviceSyncImpl::DeviceSyncImpl(
status_(Status::FETCHING_ACCOUNT_INFO) { status_(Status::FETCHING_ACCOUNT_INFO) {
DCHECK(profile_prefs_); DCHECK(profile_prefs_);
PA_LOG(VERBOSE) << "DeviceSyncImpl: Initializing."; PA_LOG(VERBOSE) << "DeviceSyncImpl: Initializing.";
CoreAccountInfo primary_account = identity_manager_->GetPrimaryAccountInfo(); // "Unconsented" because this feature is not tied to browser sync consent.
CoreAccountInfo primary_account =
identity_manager_->GetUnconsentedPrimaryAccountInfo();
if (primary_account.account_id.empty()) { if (primary_account.account_id.empty()) {
// Primary profile not loaded yet. This happens when adding a new account. // Primary profile not loaded yet. This happens when adding a new account.
PA_LOG(VERBOSE) << "DeviceSyncImpl: Waiting for primary account info"; PA_LOG(VERBOSE) << "DeviceSyncImpl: Waiting for primary account info";
...@@ -738,9 +740,12 @@ void DeviceSyncImpl::Shutdown() { ...@@ -738,9 +740,12 @@ void DeviceSyncImpl::Shutdown() {
clock_ = nullptr; clock_ = nullptr;
} }
void DeviceSyncImpl::OnPrimaryAccountSet( void DeviceSyncImpl::OnUnconsentedPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) { const CoreAccountInfo& primary_account_info) {
PA_LOG(VERBOSE) << "DeviceSyncImpl: OnPrimaryAccountSet"; PA_LOG(VERBOSE) << "DeviceSyncImpl: OnUnconsentedPrimaryAccountChanged";
// We're only interested when the account is set.
if (primary_account_info.account_id.empty())
return;
identity_manager_->RemoveObserver(this); identity_manager_->RemoveObserver(this);
ProcessPrimaryAccountInfo(primary_account_info); ProcessPrimaryAccountInfo(primary_account_info);
} }
......
...@@ -200,7 +200,7 @@ class DeviceSyncImpl : public DeviceSyncBase, ...@@ -200,7 +200,7 @@ class DeviceSyncImpl : public DeviceSyncBase,
void Shutdown() override; void Shutdown() override;
// signin::IdentityManager::Observer: // signin::IdentityManager::Observer:
void OnPrimaryAccountSet( void OnUnconsentedPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) override; const CoreAccountInfo& primary_account_info) override;
void ProcessPrimaryAccountInfo(const CoreAccountInfo& primary_account_info); void ProcessPrimaryAccountInfo(const CoreAccountInfo& primary_account_info);
......
...@@ -579,7 +579,8 @@ class FakeRemoteDeviceProviderFactory ...@@ -579,7 +579,8 @@ class FakeRemoteDeviceProviderFactory
device_manager); device_manager);
EXPECT_EQ(fake_cryptauth_v2_device_manager_factory_->instance(), EXPECT_EQ(fake_cryptauth_v2_device_manager_factory_->instance(),
v2_device_manager); v2_device_manager);
EXPECT_EQ(identity_manager_->GetPrimaryAccountInfo().email, user_email); EXPECT_EQ(identity_manager_->GetUnconsentedPrimaryAccountInfo().email,
user_email);
if (base::FeatureList::IsEnabled(features::kCryptAuthV2Enrollment)) { if (base::FeatureList::IsEnabled(features::kCryptAuthV2Enrollment)) {
EXPECT_EQ(fake_cryptauth_v2_enrollment_manager_factory_->instance() EXPECT_EQ(fake_cryptauth_v2_enrollment_manager_factory_->instance()
->GetUserPrivateKey(), ->GetUserPrivateKey(),
...@@ -893,7 +894,8 @@ class DeviceSyncServiceTest ...@@ -893,7 +894,8 @@ class DeviceSyncServiceTest
} }
void MakePrimaryAccountAvailable() { void MakePrimaryAccountAvailable() {
identity_test_environment_->MakePrimaryAccountAvailable(kTestEmail); identity_test_environment_->MakeUnconsentedPrimaryAccountAvailable(
kTestEmail);
} }
void FinishInitialization() { void FinishInitialization() {
......
...@@ -156,7 +156,9 @@ class DeviceSyncClientImplTest : public testing::Test { ...@@ -156,7 +156,9 @@ class DeviceSyncClientImplTest : public testing::Test {
identity_test_environment_ = identity_test_environment_ =
std::make_unique<signin::IdentityTestEnvironment>(); std::make_unique<signin::IdentityTestEnvironment>();
identity_test_environment_->MakePrimaryAccountAvailable(kTestEmail); // "Unconsented" because this feature is not tied to browser sync consent.
identity_test_environment_->MakeUnconsentedPrimaryAccountAvailable(
kTestEmail);
auto fake_device_sync = std::make_unique<FakeDeviceSync>(); auto fake_device_sync = std::make_unique<FakeDeviceSync>();
fake_device_sync_ = fake_device_sync.get(); fake_device_sync_ = fake_device_sync.get();
......
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