Commit 345c368a authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Chromium LUCI CQ

Rename SignOutAndRemoveAllAccounts() and SignOutAndKeepAllAccounts()

This CL also renames method SignOutAndRemoveAllAccounts() and
SignOutAndKeepAllAccounts() to ClearPrimaryAccount() and
RevokeSyncConsent() to better match the PrimaryAccountMutator APIs.

Bug: 1155505

Change-Id: I395af84c98f32383f072eb3662d4ebde7e545534
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580338
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836110}
parent d3492ce6
...@@ -58,17 +58,22 @@ AccountInfo GetValidAccountInfo(std::string email, ...@@ -58,17 +58,22 @@ AccountInfo GetValidAccountInfo(std::string email,
return account_info; return account_info;
} }
#if !defined(ANDROID) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
const char kChromiumOrgDomain[] = "chromium.org"; const char kChromiumOrgDomain[] = "chromium.org";
#endif // !defined(ANDROID) #endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
#endif // !BUILDFLAG(IS_CHROMEOS_ASH) #endif // !BUILDFLAG(IS_CHROMEOS_ASH)
class GAIAInfoUpdateServiceTest : public testing::Test { class GAIAInfoUpdateServiceTestBase : public testing::Test {
protected: protected:
GAIAInfoUpdateServiceTest() explicit GAIAInfoUpdateServiceTestBase(
: testing_profile_manager_(TestingBrowserProcess::GetGlobal()) {} signin::AccountConsistencyMethod account_consistency)
~GAIAInfoUpdateServiceTest() override = default; : testing_profile_manager_(TestingBrowserProcess::GetGlobal()),
identity_test_env_(/*test_url_loader_factory=*/nullptr,
/*pref_service=*/nullptr,
account_consistency,
/*test_signin_client=*/nullptr) {}
~GAIAInfoUpdateServiceTestBase() override = default;
void SetUp() override { void SetUp() override {
testing::Test::SetUp(); testing::Test::SetUp();
...@@ -122,20 +127,29 @@ class GAIAInfoUpdateServiceTest : public testing::Test { ...@@ -122,20 +127,29 @@ class GAIAInfoUpdateServiceTest : public testing::Test {
signin::IdentityTestEnvironment identity_test_env_; signin::IdentityTestEnvironment identity_test_env_;
std::unique_ptr<GAIAInfoUpdateService> service_; std::unique_ptr<GAIAInfoUpdateService> service_;
private:
DISALLOW_COPY_AND_ASSIGN(GAIAInfoUpdateServiceTestBase);
};
class GAIAInfoUpdateServiceTest : public GAIAInfoUpdateServiceTestBase {
protected:
GAIAInfoUpdateServiceTest()
: GAIAInfoUpdateServiceTestBase(
signin::AccountConsistencyMethod::kDisabled) {}
~GAIAInfoUpdateServiceTest() override = default;
private: private:
DISALLOW_COPY_AND_ASSIGN(GAIAInfoUpdateServiceTest); DISALLOW_COPY_AND_ASSIGN(GAIAInfoUpdateServiceTest);
}; };
} // namespace } // namespace
TEST_F(GAIAInfoUpdateServiceTest, ShouldUseGAIAProfileInfo) {
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
// This feature should never be enabled on ChromeOS. // This feature should never be enabled on ChromeOS.
TEST_F(GAIAInfoUpdateServiceTest, ShouldUseGAIAProfileInfo) {
EXPECT_FALSE(GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(profile())); EXPECT_FALSE(GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(profile()));
#endif
} }
#else // BUILDFLAG(IS_CHROMEOS_ASH)
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(GAIAInfoUpdateServiceTest, SyncOnSyncOff) { TEST_F(GAIAInfoUpdateServiceTest, SyncOnSyncOff) {
AccountInfo info = AccountInfo info =
identity_test_env()->MakeAccountAvailable("pat@example.com"); identity_test_env()->MakeAccountAvailable("pat@example.com");
...@@ -175,8 +189,21 @@ TEST_F(GAIAInfoUpdateServiceTest, SyncOnSyncOff) { ...@@ -175,8 +189,21 @@ TEST_F(GAIAInfoUpdateServiceTest, SyncOnSyncOff) {
.empty()); .empty());
} }
#if !defined(ANDROID) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
TEST_F(GAIAInfoUpdateServiceTest, SyncOnSyncOffKeepAllAccounts) { namespace {
class GAIAInfoUpdateServiceDiceTest : public GAIAInfoUpdateServiceTestBase {
protected:
GAIAInfoUpdateServiceDiceTest()
: GAIAInfoUpdateServiceTestBase(signin::AccountConsistencyMethod::kDice) {
}
~GAIAInfoUpdateServiceDiceTest() override = default;
private:
DISALLOW_COPY_AND_ASSIGN(GAIAInfoUpdateServiceDiceTest);
};
} // namespace
TEST_F(GAIAInfoUpdateServiceDiceTest, RevokeSyncConsent) {
AccountInfo info = AccountInfo info =
identity_test_env()->MakeAccountAvailable("pat@example.com"); identity_test_env()->MakeAccountAvailable("pat@example.com");
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
...@@ -193,7 +220,7 @@ TEST_F(GAIAInfoUpdateServiceTest, SyncOnSyncOffKeepAllAccounts) { ...@@ -193,7 +220,7 @@ TEST_F(GAIAInfoUpdateServiceTest, SyncOnSyncOffKeepAllAccounts) {
signin::SimulateAccountImageFetch(identity_test_env()->identity_manager(), signin::SimulateAccountImageFetch(identity_test_env()->identity_manager(),
info.account_id, "GAIA_IMAGE_URL_WITH_SIZE", info.account_id, "GAIA_IMAGE_URL_WITH_SIZE",
gaia_picture); gaia_picture);
// Turn off sync but stay logged in. // Revoke sync consent (stay signed in with the primary account).
identity_test_env()->RevokeSyncConsent(); identity_test_env()->RevokeSyncConsent();
ASSERT_TRUE(identity_test_env()->identity_manager()->HasPrimaryAccount( ASSERT_TRUE(identity_test_env()->identity_manager()->HasPrimaryAccount(
signin::ConsentLevel::kNotRequired)); signin::ConsentLevel::kNotRequired));
...@@ -370,7 +397,7 @@ TEST_F(GAIAInfoUpdateServiceTest, MultiLoginAndLogOut) { ...@@ -370,7 +397,7 @@ TEST_F(GAIAInfoUpdateServiceTest, MultiLoginAndLogOut) {
tester.ExpectTotalCount("Profile.AllAccounts.Categories", tester.ExpectTotalCount("Profile.AllAccounts.Categories",
/*expected_count=*/2); /*expected_count=*/2);
} }
#endif // !defined(ANDROID) #endif // !BUILDFLAG(ENABLE_DICE_SUPPORT)
TEST_F(GAIAInfoUpdateServiceTest, ClearGaiaInfoOnStartup) { TEST_F(GAIAInfoUpdateServiceTest, ClearGaiaInfoOnStartup) {
// Simulate a state where the profile entry has GAIA related information // Simulate a state where the profile entry has GAIA related information
...@@ -397,4 +424,4 @@ TEST_F(GAIAInfoUpdateServiceTest, ClearGaiaInfoOnStartup) { ...@@ -397,4 +424,4 @@ TEST_F(GAIAInfoUpdateServiceTest, ClearGaiaInfoOnStartup) {
EXPECT_TRUE(entry->GetHostedDomain().empty()); EXPECT_TRUE(entry->GetHostedDomain().empty());
} }
#endif // !BUILDFLAG(IS_CHROMEOS_ASH) #endif // BUILDFLAG(IS_CHROMEOS_ASH)
...@@ -30,7 +30,11 @@ class IdentityManagerObserver : public IdentityManager::Observer { ...@@ -30,7 +30,11 @@ class IdentityManagerObserver : public IdentityManager::Observer {
class SigninManagerTest : public testing::Test { class SigninManagerTest : public testing::Test {
public: public:
SigninManagerTest() = default; SigninManagerTest()
: identity_test_env_(/*test_url_loader_factory=*/nullptr,
/*pref_service=*/nullptr,
signin::AccountConsistencyMethod::kDice,
/*test_signin_client=*/nullptr) {}
void SetUp() override { void SetUp() override {
testing::Test::SetUp(); testing::Test::SetUp();
......
...@@ -270,7 +270,7 @@ void PrimaryAccountManager::RemoveObserver(Observer* observer) { ...@@ -270,7 +270,7 @@ void PrimaryAccountManager::RemoveObserver(Observer* observer) {
} }
#if !BUILDFLAG(IS_CHROMEOS_ASH) #if !BUILDFLAG(IS_CHROMEOS_ASH)
void PrimaryAccountManager::SignOutAndRemoveAllAccounts( void PrimaryAccountManager::ClearPrimaryAccount(
signin_metrics::ProfileSignout signout_source_metric, signin_metrics::ProfileSignout signout_source_metric,
signin_metrics::SignoutDelete signout_delete_metric) { signin_metrics::SignoutDelete signout_delete_metric) {
StartSignOut(signout_source_metric, signout_delete_metric, StartSignOut(signout_source_metric, signout_delete_metric,
...@@ -279,7 +279,7 @@ void PrimaryAccountManager::SignOutAndRemoveAllAccounts( ...@@ -279,7 +279,7 @@ void PrimaryAccountManager::SignOutAndRemoveAllAccounts(
#endif // !BUILDFLAG(IS_CHROMEOS_ASH) #endif // !BUILDFLAG(IS_CHROMEOS_ASH)
void PrimaryAccountManager::SignOutAndKeepAllAccounts( void PrimaryAccountManager::RevokeSyncConsent(
signin_metrics::ProfileSignout signout_source_metric, signin_metrics::ProfileSignout signout_source_metric,
signin_metrics::SignoutDelete signout_delete_metric) { signin_metrics::SignoutDelete signout_delete_metric) {
StartSignOut(signout_source_metric, signout_delete_metric, StartSignOut(signout_source_metric, signout_delete_metric,
......
...@@ -118,18 +118,16 @@ class PrimaryAccountManager : public ProfileOAuth2TokenServiceObserver { ...@@ -118,18 +118,16 @@ class PrimaryAccountManager : public ProfileOAuth2TokenServiceObserver {
// Signs a user out, removing the preference, erasing all keys // Signs a user out, removing the preference, erasing all keys
// associated with the authenticated user, and canceling all auth in progress. // associated with the authenticated user, and canceling all auth in progress.
// It removes all accounts from Chrome by revoking all refresh tokens. // It removes all accounts from Chrome by revoking all refresh tokens.
void SignOutAndRemoveAllAccounts( void ClearPrimaryAccount(signin_metrics::ProfileSignout signout_source_metric,
signin_metrics::ProfileSignout signout_source_metric, signin_metrics::SignoutDelete signout_delete_metric);
signin_metrics::SignoutDelete signout_delete_metric);
#endif // !BUILDFLAG(IS_CHROMEOS_ASH) #endif // !BUILDFLAG(IS_CHROMEOS_ASH)
// Signs a user out, removing the preference, erasing all keys // Signs a user out, removing the preference, erasing all keys
// associated with the authenticated user, and canceling all auth in progress. // associated with the authenticated user, and canceling all auth in progress.
// Does not remove the accounts from the token service. // Does not remove the accounts from the token service.
void SignOutAndKeepAllAccounts( void RevokeSyncConsent(signin_metrics::ProfileSignout signout_source_metric,
signin_metrics::ProfileSignout signout_source_metric, signin_metrics::SignoutDelete signout_delete_metric);
signin_metrics::SignoutDelete signout_delete_metric);
// Adds and removes observers. // Adds and removes observers.
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
......
...@@ -152,9 +152,8 @@ TEST_F(PrimaryAccountManagerTest, SignOut) { ...@@ -152,9 +152,8 @@ TEST_F(PrimaryAccountManagerTest, SignOut) {
CoreAccountId main_account_id = CoreAccountId main_account_id =
AddToAccountTracker("account_id", "user@gmail.com"); AddToAccountTracker("account_id", "user@gmail.com");
manager_->SignIn("user@gmail.com"); manager_->SignIn("user@gmail.com");
manager_->SignOutAndRemoveAllAccounts( manager_->ClearPrimaryAccount(signin_metrics::SIGNOUT_TEST,
signin_metrics::SIGNOUT_TEST, signin_metrics::SignoutDelete::IGNORE_METRIC);
signin_metrics::SignoutDelete::IGNORE_METRIC);
EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
EXPECT_TRUE(manager_->GetAuthenticatedAccountInfo().email.empty()); EXPECT_TRUE(manager_->GetAuthenticatedAccountInfo().email.empty());
EXPECT_TRUE(manager_->GetAuthenticatedAccountId().empty()); EXPECT_TRUE(manager_->GetAuthenticatedAccountId().empty());
...@@ -180,9 +179,8 @@ TEST_F(PrimaryAccountManagerTest, SignOutRevoke) { ...@@ -180,9 +179,8 @@ TEST_F(PrimaryAccountManagerTest, SignOutRevoke) {
EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
EXPECT_EQ(main_account_id, manager_->GetAuthenticatedAccountId()); EXPECT_EQ(main_account_id, manager_->GetAuthenticatedAccountId());
manager_->SignOutAndRemoveAllAccounts( manager_->ClearPrimaryAccount(signin_metrics::SIGNOUT_TEST,
signin_metrics::SIGNOUT_TEST, signin_metrics::SignoutDelete::IGNORE_METRIC);
signin_metrics::SignoutDelete::IGNORE_METRIC);
// Tokens are revoked. // Tokens are revoked.
EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
...@@ -198,14 +196,12 @@ TEST_F(PrimaryAccountManagerTest, SignOutWhileProhibited) { ...@@ -198,14 +196,12 @@ TEST_F(PrimaryAccountManagerTest, SignOutWhileProhibited) {
AddToAccountTracker("gaia_id", "user@gmail.com"); AddToAccountTracker("gaia_id", "user@gmail.com");
manager_->SignIn("user@gmail.com"); manager_->SignIn("user@gmail.com");
signin_client()->set_is_signout_allowed(false); signin_client()->set_is_signout_allowed(false);
manager_->SignOutAndRemoveAllAccounts( manager_->ClearPrimaryAccount(signin_metrics::SIGNOUT_TEST,
signin_metrics::SIGNOUT_TEST, signin_metrics::SignoutDelete::IGNORE_METRIC);
signin_metrics::SignoutDelete::IGNORE_METRIC);
EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
signin_client()->set_is_signout_allowed(true); signin_client()->set_is_signout_allowed(true);
manager_->SignOutAndRemoveAllAccounts( manager_->ClearPrimaryAccount(signin_metrics::SIGNOUT_TEST,
signin_metrics::SIGNOUT_TEST, signin_metrics::SignoutDelete::IGNORE_METRIC);
signin_metrics::SignoutDelete::IGNORE_METRIC);
EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
} }
...@@ -221,9 +217,8 @@ TEST_F(PrimaryAccountManagerTest, UnconsentedSignOutWhileProhibited) { ...@@ -221,9 +217,8 @@ TEST_F(PrimaryAccountManagerTest, UnconsentedSignOutWhileProhibited) {
EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kNotRequired)); EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kNotRequired));
EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
signin_client()->set_is_signout_allowed(false); signin_client()->set_is_signout_allowed(false);
manager_->SignOutAndRemoveAllAccounts( manager_->ClearPrimaryAccount(signin_metrics::SIGNOUT_TEST,
signin_metrics::SIGNOUT_TEST, signin_metrics::SignoutDelete::IGNORE_METRIC);
signin_metrics::SignoutDelete::IGNORE_METRIC);
EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kNotRequired)); EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kNotRequired));
} }
...@@ -456,15 +451,14 @@ TEST_F(PrimaryAccountManagerTest, SetUnconsentedPrimaryAccountInfo) { ...@@ -456,15 +451,14 @@ TEST_F(PrimaryAccountManagerTest, SetUnconsentedPrimaryAccountInfo) {
EXPECT_EQ(CoreAccountInfo(), manager_->GetAuthenticatedAccountInfo()); EXPECT_EQ(CoreAccountInfo(), manager_->GetAuthenticatedAccountInfo());
} }
TEST_F(PrimaryAccountManagerTest, SignOutAndKeepAllAccounts) { TEST_F(PrimaryAccountManagerTest, RevokeSyncConsent) {
CreatePrimaryAccountManager(); CreatePrimaryAccountManager();
CoreAccountId account_id = AddToAccountTracker("gaia_id", "user@gmail.com"); CoreAccountId account_id = AddToAccountTracker("gaia_id", "user@gmail.com");
manager_->SignIn("user@gmail.com"); manager_->SignIn("user@gmail.com");
EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
manager_->SignOutAndKeepAllAccounts( manager_->RevokeSyncConsent(signin_metrics::ProfileSignout::SIGNOUT_TEST,
signin_metrics::ProfileSignout::SIGNOUT_TEST, signin_metrics::SignoutDelete::IGNORE_METRIC);
signin_metrics::SignoutDelete::IGNORE_METRIC);
EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kNotRequired)); EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kNotRequired));
EXPECT_EQ(account_id, EXPECT_EQ(account_id,
...@@ -472,15 +466,14 @@ TEST_F(PrimaryAccountManagerTest, SignOutAndKeepAllAccounts) { ...@@ -472,15 +466,14 @@ TEST_F(PrimaryAccountManagerTest, SignOutAndKeepAllAccounts) {
} }
#if !BUILDFLAG(IS_CHROMEOS_ASH) #if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(PrimaryAccountManagerTest, SignOutAndRemoveAllAccounts) { TEST_F(PrimaryAccountManagerTest, ClearPrimaryAccount) {
CreatePrimaryAccountManager(); CreatePrimaryAccountManager();
CoreAccountId account_id = AddToAccountTracker("gaia_id", "user@gmail.com"); CoreAccountId account_id = AddToAccountTracker("gaia_id", "user@gmail.com");
manager_->SignIn("user@gmail.com"); manager_->SignIn("user@gmail.com");
EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_TRUE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
manager_->SignOutAndRemoveAllAccounts( manager_->ClearPrimaryAccount(signin_metrics::ProfileSignout::SIGNOUT_TEST,
signin_metrics::ProfileSignout::SIGNOUT_TEST, signin_metrics::SignoutDelete::IGNORE_METRIC);
signin_metrics::SignoutDelete::IGNORE_METRIC);
EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync)); EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kSync));
EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kNotRequired)); EXPECT_FALSE(manager_->HasPrimaryAccount(ConsentLevel::kNotRequired));
} }
......
...@@ -119,8 +119,7 @@ void PrimaryAccountMutatorImpl::RevokeSyncConsent( ...@@ -119,8 +119,7 @@ void PrimaryAccountMutatorImpl::RevokeSyncConsent(
return; return;
} }
#endif #endif
primary_account_manager_->SignOutAndKeepAllAccounts(source_metric, primary_account_manager_->RevokeSyncConsent(source_metric, delete_metric);
delete_metric);
} }
#if !BUILDFLAG(IS_CHROMEOS_ASH) #if !BUILDFLAG(IS_CHROMEOS_ASH)
...@@ -130,8 +129,7 @@ bool PrimaryAccountMutatorImpl::ClearPrimaryAccount( ...@@ -130,8 +129,7 @@ bool PrimaryAccountMutatorImpl::ClearPrimaryAccount(
if (!primary_account_manager_->HasPrimaryAccount(ConsentLevel::kNotRequired)) if (!primary_account_manager_->HasPrimaryAccount(ConsentLevel::kNotRequired))
return false; return false;
primary_account_manager_->SignOutAndRemoveAllAccounts(source_metric, primary_account_manager_->ClearPrimaryAccount(source_metric, delete_metric);
delete_metric);
return true; return true;
} }
#endif #endif
......
...@@ -56,12 +56,14 @@ void PrimaryAccountPolicyManagerImpl::InitializePolicy( ...@@ -56,12 +56,14 @@ void PrimaryAccountPolicyManagerImpl::InitializePolicy(
// //
// On desktop, when PrimaryAccountManager is initializing, the profile was // On desktop, when PrimaryAccountManager is initializing, the profile was
// not yet marked with sign out allowed. Therefore sign out is not allowed // not yet marked with sign out allowed. Therefore sign out is not allowed
// and all calls to SignOut methods are no-op. // and all calls to RevokeSyncConsent() and ClearPrimaryAccount() methods
// are no-op.
// //
// TODO(msarda): SignOut methods do not guarantee that sign out can actually // TODO(msarda): RevokeSyncConsent() method do not guarantee that the sync
// be done (this depends on whether sign out is allowed). Add a check here // consent can really be revoked (this depends on whether sign out is
// on desktop to make it clear that SignOut does not do anything. // allowed). Add a check here on desktop to make it clear that
primary_account_manager->SignOutAndKeepAllAccounts( // RevokeSyncConsent() does not do anything.
primary_account_manager->RevokeSyncConsent(
signin_metrics::SIGNIN_PREF_CHANGED_DURING_SIGNIN, signin_metrics::SIGNIN_PREF_CHANGED_DURING_SIGNIN,
signin_metrics::SignoutDelete::IGNORE_METRIC); signin_metrics::SignoutDelete::IGNORE_METRIC);
} }
...@@ -74,7 +76,7 @@ void PrimaryAccountPolicyManagerImpl::OnGoogleServicesUsernamePatternChanged( ...@@ -74,7 +76,7 @@ void PrimaryAccountPolicyManagerImpl::OnGoogleServicesUsernamePatternChanged(
primary_account_manager->GetAuthenticatedAccountInfo().email)) { primary_account_manager->GetAuthenticatedAccountInfo().email)) {
// Signed in user is invalid according to the current policy so sign // Signed in user is invalid according to the current policy so sign
// the user out. // the user out.
primary_account_manager->SignOutAndRemoveAllAccounts( primary_account_manager->ClearPrimaryAccount(
signin_metrics::GOOGLE_SERVICE_NAME_PATTERN_CHANGED, signin_metrics::GOOGLE_SERVICE_NAME_PATTERN_CHANGED,
signin_metrics::SignoutDelete::IGNORE_METRIC); signin_metrics::SignoutDelete::IGNORE_METRIC);
} }
...@@ -89,7 +91,7 @@ void PrimaryAccountPolicyManagerImpl::OnSigninAllowedPrefChanged( ...@@ -89,7 +91,7 @@ void PrimaryAccountPolicyManagerImpl::OnSigninAllowedPrefChanged(
if (!IsSigninAllowed() && if (!IsSigninAllowed() &&
primary_account_manager->HasPrimaryAccount(signin::ConsentLevel::kSync)) { primary_account_manager->HasPrimaryAccount(signin::ConsentLevel::kSync)) {
VLOG(0) << "IsSigninAllowed() set to false, signing out the user"; VLOG(0) << "IsSigninAllowed() set to false, signing out the user";
primary_account_manager->SignOutAndRemoveAllAccounts( primary_account_manager->ClearPrimaryAccount(
signin_metrics::SIGNOUT_PREF_CHANGED, signin_metrics::SIGNOUT_PREF_CHANGED,
signin_metrics::SignoutDelete::IGNORE_METRIC); signin_metrics::SignoutDelete::IGNORE_METRIC);
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "components/signin/public/base/list_accounts_test_utils.h" #include "components/signin/public/base/list_accounts_test_utils.h"
#include "components/signin/public/identity_manager/consent_level.h" #include "components/signin/public/identity_manager/consent_level.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/primary_account_mutator.h"
#include "components/signin/public/identity_manager/test_identity_manager_observer.h" #include "components/signin/public/identity_manager/test_identity_manager_observer.h"
#include "google_apis/gaia/gaia_auth_util.h" #include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_constants.h"
...@@ -194,10 +195,11 @@ void RevokeSyncConsent(IdentityManager* identity_manager) { ...@@ -194,10 +195,11 @@ void RevokeSyncConsent(IdentityManager* identity_manager) {
if (!identity_manager->HasPrimaryAccount(ConsentLevel::kSync)) if (!identity_manager->HasPrimaryAccount(ConsentLevel::kSync))
return; return;
DCHECK(identity_manager->GetPrimaryAccountMutator());
base::RunLoop run_loop; base::RunLoop run_loop;
TestIdentityManagerObserver signout_observer(identity_manager); TestIdentityManagerObserver signout_observer(identity_manager);
signout_observer.SetOnPrimaryAccountClearedCallback(run_loop.QuitClosure()); signout_observer.SetOnPrimaryAccountClearedCallback(run_loop.QuitClosure());
identity_manager->GetPrimaryAccountManager()->SignOutAndKeepAllAccounts( identity_manager->GetPrimaryAccountMutator()->RevokeSyncConsent(
signin_metrics::SIGNOUT_TEST, signin_metrics::SIGNOUT_TEST,
signin_metrics::SignoutDelete::IGNORE_METRIC); signin_metrics::SignoutDelete::IGNORE_METRIC);
run_loop.Run(); run_loop.Run();
...@@ -213,12 +215,13 @@ void ClearPrimaryAccount(IdentityManager* identity_manager) { ...@@ -213,12 +215,13 @@ void ClearPrimaryAccount(IdentityManager* identity_manager) {
if (!identity_manager->HasPrimaryAccount(ConsentLevel::kNotRequired)) if (!identity_manager->HasPrimaryAccount(ConsentLevel::kNotRequired))
return; return;
DCHECK(identity_manager->GetPrimaryAccountMutator());
bool wait_for_primary_acount_cleared_notification = bool wait_for_primary_acount_cleared_notification =
identity_manager->HasPrimaryAccount(ConsentLevel::kSync); identity_manager->HasPrimaryAccount(ConsentLevel::kSync);
base::RunLoop run_loop; base::RunLoop run_loop;
TestIdentityManagerObserver signout_observer(identity_manager); TestIdentityManagerObserver signout_observer(identity_manager);
signout_observer.SetOnPrimaryAccountClearedCallback(run_loop.QuitClosure()); signout_observer.SetOnPrimaryAccountClearedCallback(run_loop.QuitClosure());
identity_manager->GetPrimaryAccountManager()->SignOutAndRemoveAllAccounts( identity_manager->GetPrimaryAccountMutator()->ClearPrimaryAccount(
signin_metrics::SIGNOUT_TEST, signin_metrics::SIGNOUT_TEST,
signin_metrics::SignoutDelete::IGNORE_METRIC); signin_metrics::SignoutDelete::IGNORE_METRIC);
......
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