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

cros: Migrate ARC Play Store settings to unconsented primary account

SplitSettingsSync will allow the user to opt-out of browser sync.
However, IdentityManager::GetPrimaryAccount() assumes the user has
consented to browser sync. Switch to using the "unconsented" primary
account, which exists whether or not the user has consented to
browser sync.

See go/cros-primary-account for details.

Bug: 1042400
Test: updated existing unit_tests
Test: cancelling ARC setup in OS settings still works
Change-Id: I39ecf4f800071e79624bd624bcdf5272e6ad448b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2023988
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarJosh Horwich <jhorwich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736473}
parent 40806411
......@@ -128,10 +128,11 @@ void ArcPlayStoreEnabledPreferenceHandler::OnPreferenceChanged() {
// TODO(crbug.com/850297): Fix unrelated tests that are not properly
// setting up the state of identity_manager and enable the DCHECK instead
// of the conditional below.
// DCHECK(identity_manager->HasPrimaryAccount());
if (identity_manager->HasPrimaryAccount()) {
// DCHECK(identity_manager->HasUnconsentedPrimaryAccount());
if (identity_manager->HasUnconsentedPrimaryAccount()) {
// This class doesn't care about browser sync consent.
const CoreAccountId account_id =
identity_manager->GetPrimaryAccountId();
identity_manager->GetUnconsentedPrimaryAccountId();
UserConsentTypes::ArcPlayTermsOfServiceConsent play_consent;
play_consent.set_status(UserConsentTypes::NOT_GIVEN);
......
......@@ -82,8 +82,8 @@ class ArcPlayStoreEnabledPreferenceHandlerTest : public testing::Test {
GetFakeUserManager()->AddUser(account_id);
GetFakeUserManager()->LoginUser(account_id);
identity_test_env_profile_adaptor_->identity_test_env()->SetPrimaryAccount(
kTestEmail);
identity_test_env_profile_adaptor_->identity_test_env()
->MakeUnconsentedPrimaryAccountAvailable(kTestEmail);
}
void TearDown() override {
......@@ -112,11 +112,11 @@ class ArcPlayStoreEnabledPreferenceHandlerTest : public testing::Test {
ConsentAuditorFactory::GetForProfile(profile()));
}
CoreAccountId GetAuthenticatedAccountId() const {
CoreAccountId GetAccountId() const {
auto* identity_manager =
identity_test_env_profile_adaptor_->identity_test_env()
->identity_manager();
return identity_manager->GetPrimaryAccountInfo().account_id;
return identity_manager->GetUnconsentedPrimaryAccountInfo().account_id;
}
private:
......@@ -193,7 +193,7 @@ TEST_F(ArcPlayStoreEnabledPreferenceHandlerTest, PrefChangeRevokesConsent) {
play_consent.set_consent_flow(
UserConsentTypes::ArcPlayTermsOfServiceConsent::SETTING_CHANGE);
EXPECT_CALL(*auditor, RecordArcPlayConsent(
GetAuthenticatedAccountId(),
GetAccountId(),
consent_auditor::ArcPlayConsentEq(play_consent)));
ASSERT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
......
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