Commit d3f0bde5 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Only require IdentityManager as main parameter for identity_test_utils.h APIs

This will remove the need to know about specific instances of SigninManager,
AccountTrackerService, ProfileOAuth2TokenService and GaiaCookieManagerService
from the calling places for those methods.

Also move the SigninManagerForTest definition in identity_test_environment.h
one level up, to allow sharing it among |IdentityManagerDependenciesOwner|
and |IdentityTestEnvironment| without relying on such definition being also
available from identity_test_utils.h (from where it's now being removed due
to no longer being required by those test utilities).

Bug: 904404
Change-Id: If96b0c7dea763030dc7372d58922f82a31eb5733
Reviewed-on: https://chromium-review.googlesource.com/c/1336127
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609216}
parent 8bbbc97c
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_function_test_utils.h" #include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.h" #include "chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
...@@ -37,7 +36,6 @@ ...@@ -37,7 +36,6 @@
#include "components/drive/drive_pref_names.h" #include "components/drive/drive_pref_names.h"
#include "components/drive/file_change.h" #include "components/drive/file_change.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/install_warning.h" #include "extensions/common/install_warning.h"
#include "google_apis/drive/test_util.h" #include "google_apis/drive/test_util.h"
...@@ -365,7 +363,6 @@ class FileManagerPrivateApiTest : public extensions::ExtensionApiTest { ...@@ -365,7 +363,6 @@ class FileManagerPrivateApiTest : public extensions::ExtensionApiTest {
{features::kCrostini, features::kExperimentalCrostiniUI}, {}); {features::kCrostini, features::kExperimentalCrostiniUI}, {});
// Profile must be signed in with email for crostini. // Profile must be signed in with email for crostini.
identity::SetPrimaryAccount( identity::SetPrimaryAccount(
SigninManagerFactory::GetForProfileIfExists(browser()->profile()),
IdentityManagerFactory::GetForProfileIfExists(browser()->profile()), IdentityManagerFactory::GetForProfileIfExists(browser()->profile()),
"testuser@gmail.com"); "testuser@gmail.com");
} }
......
...@@ -489,8 +489,7 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest { ...@@ -489,8 +489,7 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest {
std::string SignIn(const std::string& email) { std::string SignIn(const std::string& email) {
identity::IdentityManager* identity_manager = identity::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile()); IdentityManagerFactory::GetForProfile(profile());
identity::MakePrimaryAccountAvailable(signin_manager_, token_service_, identity::MakePrimaryAccountAvailable(identity_manager, email);
identity_manager, email);
return identity_manager->GetPrimaryAccountId(); return identity_manager->GetPrimaryAccountId();
} }
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/test/integration/quiesce_status_change_checker.h" #include "chrome/browser/sync/test/integration/quiesce_status_change_checker.h"
#include "chrome/browser/sync/test/integration/single_client_status_change_checker.h" #include "chrome/browser/sync/test/integration/single_client_status_change_checker.h"
...@@ -25,7 +23,6 @@ ...@@ -25,7 +23,6 @@
#include "chrome/browser/ui/webui/signin/login_ui_test_utils.h" #include "chrome/browser/ui/webui/signin/login_ui_test_utils.h"
#include "chrome/browser/unified_consent/unified_consent_service_factory.h" #include "chrome/browser/unified_consent/unified_consent_service_factory.h"
#include "chrome/common/channel_info.h" #include "chrome/common/channel_info.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync/driver/about_sync_util.h" #include "components/sync/driver/about_sync_util.h"
#include "components/sync/engine/sync_string_conversions.h" #include "components/sync/engine/sync_string_conversions.h"
#include "components/unified_consent/feature.h" #include "components/unified_consent/feature.h"
...@@ -140,8 +137,6 @@ bool ProfileSyncServiceHarness::SignInPrimaryAccount() { ...@@ -140,8 +137,6 @@ bool ProfileSyncServiceHarness::SignInPrimaryAccount() {
case SigninType::FAKE_SIGNIN: { case SigninType::FAKE_SIGNIN: {
identity::IdentityManager* identity_manager = identity::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile_); IdentityManagerFactory::GetForProfile(profile_);
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
// Verify HasPrimaryAccount() separately because // Verify HasPrimaryAccount() separately because
// MakePrimaryAccountAvailable() below DCHECK fails if there is already // MakePrimaryAccountAvailable() below DCHECK fails if there is already
...@@ -154,13 +149,11 @@ bool ProfileSyncServiceHarness::SignInPrimaryAccount() { ...@@ -154,13 +149,11 @@ bool ProfileSyncServiceHarness::SignInPrimaryAccount() {
// always hand out the same access token string, any new access token // always hand out the same access token string, any new access token
// acquired later would also be considered invalid. // acquired later would also be considered invalid.
if (!identity_manager->HasPrimaryAccountWithRefreshToken()) { if (!identity_manager->HasPrimaryAccountWithRefreshToken()) {
identity::SetRefreshTokenForPrimaryAccount(token_service, identity::SetRefreshTokenForPrimaryAccount(identity_manager);
identity_manager);
} }
} else { } else {
// Authenticate sync client using GAIA credentials. // Authenticate sync client using GAIA credentials.
identity::MakePrimaryAccountAvailable( identity::MakePrimaryAccountAvailable(
SigninManagerFactory::GetForProfile(profile_), token_service,
identity_manager, username_); identity_manager, username_);
} }
return true; return true;
...@@ -175,7 +168,6 @@ bool ProfileSyncServiceHarness::SignInPrimaryAccount() { ...@@ -175,7 +168,6 @@ bool ProfileSyncServiceHarness::SignInPrimaryAccount() {
void ProfileSyncServiceHarness::SignOutPrimaryAccount() { void ProfileSyncServiceHarness::SignOutPrimaryAccount() {
DCHECK(!username_.empty()); DCHECK(!username_.empty());
identity::ClearPrimaryAccount( identity::ClearPrimaryAccount(
SigninManagerFactory::GetForProfile(profile_),
IdentityManagerFactory::GetForProfile(profile_), IdentityManagerFactory::GetForProfile(profile_),
identity::ClearPrimaryAccountPolicy::REMOVE_ALL_ACCOUNTS); identity::ClearPrimaryAccountPolicy::REMOVE_ALL_ACCOUNTS);
} }
......
...@@ -6,11 +6,9 @@ ...@@ -6,11 +6,9 @@
#include "base/bind.h" #include "base/bind.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_gaia_cookie_manager_service_builder.h" #include "chrome/browser/signin/fake_gaia_cookie_manager_service_builder.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/signin/core/browser/fake_gaia_cookie_manager_service.h" #include "components/signin/core/browser/fake_gaia_cookie_manager_service.h"
...@@ -69,8 +67,6 @@ void SignInSecondaryAccount(Profile* profile, const std::string& email) { ...@@ -69,8 +67,6 @@ void SignInSecondaryAccount(Profile* profile, const std::string& email) {
identity::IdentityManager* identity_manager = identity::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile); IdentityManagerFactory::GetForProfile(profile);
AccountInfo account_info = identity::MakeAccountAvailable( AccountInfo account_info = identity::MakeAccountAvailable(
AccountTrackerServiceFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
identity_manager, email); identity_manager, email);
FakeGaiaCookieManagerService* fake_cookie_service = FakeGaiaCookieManagerService* fake_cookie_service =
static_cast<FakeGaiaCookieManagerService*>( static_cast<FakeGaiaCookieManagerService*>(
......
...@@ -10,15 +10,12 @@ ...@@ -10,15 +10,12 @@
#include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/extensions/extension_installed_bubble.h" #include "chrome/browser/ui/extensions/extension_installed_bubble.h"
#include "chrome/browser/ui/test/test_browser_dialog.h" #include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "components/bubble/bubble_controller.h" #include "components/bubble/bubble_controller.h"
#include "components/bubble/bubble_ui.h" #include "components/bubble/bubble_ui.h"
#include "components/signin/core/browser/signin_manager.h"
#include "extensions/common/extension_builder.h" #include "extensions/common/extension_builder.h"
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "services/identity/public/cpp/identity_test_utils.h" #include "services/identity/public/cpp/identity_test_utils.h"
...@@ -142,8 +139,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest, ...@@ -142,8 +139,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstalledBubbleBrowserTest,
DISABLED_InvokeUi_NoAction) { DISABLED_InvokeUi_NoAction) {
// Sign in to supppress the signin promo. // Sign in to supppress the signin promo.
identity::MakePrimaryAccountAvailable( identity::MakePrimaryAccountAvailable(
SigninManagerFactory::GetForProfile(profile()),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile()),
IdentityManagerFactory::GetForProfile(profile()), "test@example.com"); IdentityManagerFactory::GetForProfile(profile()), "test@example.com");
ShowAndVerifyUi(); ShowAndVerifyUi();
} }
......
...@@ -366,8 +366,6 @@ class LocalDiscoveryUITest : public WebUIBrowserTest { ...@@ -366,8 +366,6 @@ class LocalDiscoveryUITest : public WebUIBrowserTest {
kResponseRegisterComplete); kResponseRegisterComplete);
identity::MakePrimaryAccountAvailable( identity::MakePrimaryAccountAvailable(
SigninManagerFactory::GetForProfile(browser()->profile()),
ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()),
IdentityManagerFactory::GetForProfile(browser()->profile()), IdentityManagerFactory::GetForProfile(browser()->profile()),
kSampleUser); kSampleUser);
......
...@@ -207,6 +207,18 @@ void IdentityManager::RemoveDiagnosticsObserver(DiagnosticsObserver* observer) { ...@@ -207,6 +207,18 @@ void IdentityManager::RemoveDiagnosticsObserver(DiagnosticsObserver* observer) {
diagnostics_observer_list_.RemoveObserver(observer); diagnostics_observer_list_.RemoveObserver(observer);
} }
SigninManagerBase* IdentityManager::GetSigninManager() {
return signin_manager_;
}
ProfileOAuth2TokenService* IdentityManager::GetTokenService() {
return token_service_;
}
AccountTrackerService* IdentityManager::GetAccountTrackerService() {
return account_tracker_service_;
}
void IdentityManager::SetPrimaryAccountSynchronouslyForTests( void IdentityManager::SetPrimaryAccountSynchronouslyForTests(
const std::string& gaia_id, const std::string& gaia_id,
const std::string& email_address, const std::string& email_address,
......
...@@ -46,6 +46,7 @@ class MultiProfileDownloadNotificationTest; ...@@ -46,6 +46,7 @@ class MultiProfileDownloadNotificationTest;
namespace identity { namespace identity {
class PrimaryAccountMutator; class PrimaryAccountMutator;
enum class ClearPrimaryAccountPolicy;
// Gives access to information about the user's Google identities. See // Gives access to information about the user's Google identities. See
// ./README.md for detailed documentation. // ./README.md for detailed documentation.
...@@ -265,10 +266,32 @@ class IdentityManager : public SigninManagerBase::Observer, ...@@ -265,10 +266,32 @@ class IdentityManager : public SigninManagerBase::Observer,
void RemoveDiagnosticsObserver(DiagnosticsObserver* observer); void RemoveDiagnosticsObserver(DiagnosticsObserver* observer);
private: private:
// These clients need to call SetPrimaryAccountSynchronouslyForTests(). // These test helpers need to use some of the private methods below.
friend AccountInfo SetPrimaryAccount(SigninManagerBase* signin_manager, friend AccountInfo SetPrimaryAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
const std::string& email); const std::string& email);
friend void SetRefreshTokenForPrimaryAccount(
IdentityManager* identity_manager);
friend void SetInvalidRefreshTokenForPrimaryAccount(
IdentityManager* identity_manager);
friend void RemoveRefreshTokenForPrimaryAccount(
IdentityManager* identity_manager);
friend AccountInfo MakePrimaryAccountAvailable(
IdentityManager* identity_manager,
const std::string& email);
friend void ClearPrimaryAccount(IdentityManager* identity_manager,
ClearPrimaryAccountPolicy policy);
friend AccountInfo MakeAccountAvailable(IdentityManager* identity_manager,
const std::string& email);
friend void SetRefreshTokenForAccount(IdentityManager* identity_manager,
const std::string& account_id);
friend void SetInvalidRefreshTokenForAccount(
IdentityManager* identity_manager,
const std::string& account_id);
friend void RemoveRefreshTokenForAccount(IdentityManager* identity_manager,
const std::string& account_id);
friend void UpdateAccountInfoForAccount(IdentityManager* identity_manager,
AccountInfo account_info);
friend MultiProfileDownloadNotificationTest; friend MultiProfileDownloadNotificationTest;
friend file_manager::MultiProfileFilesAppBrowserTest; friend file_manager::MultiProfileFilesAppBrowserTest;
...@@ -278,6 +301,11 @@ class IdentityManager : public SigninManagerBase::Observer, ...@@ -278,6 +301,11 @@ class IdentityManager : public SigninManagerBase::Observer,
friend chromeos::ChromeSessionManager; friend chromeos::ChromeSessionManager;
friend chromeos::UserSessionManager; friend chromeos::UserSessionManager;
// Private getters used for testing only (i.e. see identity_test_utils.h).
SigninManagerBase* GetSigninManager();
ProfileOAuth2TokenService* GetTokenService();
AccountTrackerService* GetAccountTrackerService();
// Sets the primary account info synchronously with both the IdentityManager // Sets the primary account info synchronously with both the IdentityManager
// and its backing SigninManager/ProfileOAuth2TokenService instances. // and its backing SigninManager/ProfileOAuth2TokenService instances.
// Prefer using the methods in identity_test_{environment, utils}.h to using // Prefer using the methods in identity_test_{environment, utils}.h to using
......
...@@ -514,10 +514,10 @@ class IdentityManagerTest : public testing::Test { ...@@ -514,10 +514,10 @@ class IdentityManagerTest : public testing::Test {
// Ensure primary and secondary emails are set up with refresh tokens. Some // Ensure primary and secondary emails are set up with refresh tokens. Some
// tests may do this externally for the primary account. // tests may do this externally for the primary account.
if (!identity_manager()->HasPrimaryAccountWithRefreshToken()) if (!identity_manager()->HasPrimaryAccountWithRefreshToken())
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_TRUE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_TRUE(identity_manager()->HasPrimaryAccountWithRefreshToken());
AccountInfo secondary_account_info = MakeAccountAvailable( AccountInfo secondary_account_info =
account_tracker(), token_service(), identity_manager(), kTestEmail2); MakeAccountAvailable(identity_manager(), kTestEmail2);
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken( EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(
secondary_account_info.account_id)); secondary_account_info.account_id));
...@@ -693,7 +693,7 @@ TEST_F(IdentityManagerTest, ...@@ -693,7 +693,7 @@ TEST_F(IdentityManagerTest,
SigninManagerSetup::kWithAuthenticatedAccout); SigninManagerSetup::kWithAuthenticatedAccout);
// Set primary account to have authentication error. // Set primary account to have authentication error.
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
token_service()->UpdateAuthErrorForTesting( token_service()->UpdateAuthErrorForTesting(
identity_manager()->GetPrimaryAccountId(), identity_manager()->GetPrimaryAccountId(),
GoogleServiceAuthError( GoogleServiceAuthError(
...@@ -719,8 +719,8 @@ TEST_F(IdentityManagerTest, ClearPrimaryAccount_AuthInProgress) { ...@@ -719,8 +719,8 @@ TEST_F(IdentityManagerTest, ClearPrimaryAccount_AuthInProgress) {
// Add a secondary account to verify that its refresh token survives the // Add a secondary account to verify that its refresh token survives the
// call to ClearPrimaryAccount(...) below. // call to ClearPrimaryAccount(...) below.
AccountInfo secondary_account_info = MakeAccountAvailable( AccountInfo secondary_account_info =
account_tracker(), token_service(), identity_manager(), kTestEmail2); MakeAccountAvailable(identity_manager(), kTestEmail2);
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken( EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(
secondary_account_info.account_id)); secondary_account_info.account_id));
...@@ -850,7 +850,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithPrimaryAccount) { ...@@ -850,7 +850,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithPrimaryAccount) {
// Add a refresh token for the primary account and check that it shows up in // Add a refresh token for the primary account and check that it shows up in
// GetAccountsWithRefreshTokens(). // GetAccountsWithRefreshTokens().
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
std::vector<AccountInfo> accounts_after_update = std::vector<AccountInfo> accounts_after_update =
identity_manager()->GetAccountsWithRefreshTokens(); identity_manager()->GetAccountsWithRefreshTokens();
...@@ -861,7 +861,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithPrimaryAccount) { ...@@ -861,7 +861,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithPrimaryAccount) {
EXPECT_EQ(accounts_after_update[0].email, kTestEmail); EXPECT_EQ(accounts_after_update[0].email, kTestEmail);
// Update the token and check that it doesn't change the state (or blow up). // Update the token and check that it doesn't change the state (or blow up).
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
std::vector<AccountInfo> accounts_after_second_update = std::vector<AccountInfo> accounts_after_second_update =
identity_manager()->GetAccountsWithRefreshTokens(); identity_manager()->GetAccountsWithRefreshTokens();
...@@ -873,7 +873,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithPrimaryAccount) { ...@@ -873,7 +873,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithPrimaryAccount) {
// Remove the token for the primary account and check that this is likewise // Remove the token for the primary account and check that this is likewise
// reflected. // reflected.
RemoveRefreshTokenForPrimaryAccount(token_service(), identity_manager()); RemoveRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_TRUE(identity_manager()->GetAccountsWithRefreshTokens().empty()); EXPECT_TRUE(identity_manager()->GetAccountsWithRefreshTokens().empty());
} }
...@@ -890,14 +890,14 @@ TEST_F(IdentityManagerTest, ...@@ -890,14 +890,14 @@ TEST_F(IdentityManagerTest,
// Add a refresh token for the primary account and check that it affects this // Add a refresh token for the primary account and check that it affects this
// state. // state.
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_TRUE( EXPECT_TRUE(
identity_manager()->HasAccountWithRefreshToken(account_info.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info.account_id));
EXPECT_TRUE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_TRUE(identity_manager()->HasPrimaryAccountWithRefreshToken());
// Update the token and check that it doesn't change the state (or blow up). // Update the token and check that it doesn't change the state (or blow up).
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_TRUE( EXPECT_TRUE(
identity_manager()->HasAccountWithRefreshToken(account_info.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info.account_id));
...@@ -905,7 +905,7 @@ TEST_F(IdentityManagerTest, ...@@ -905,7 +905,7 @@ TEST_F(IdentityManagerTest,
// Remove the token for the primary account and check that this is likewise // Remove the token for the primary account and check that this is likewise
// reflected. // reflected.
RemoveRefreshTokenForPrimaryAccount(token_service(), identity_manager()); RemoveRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_FALSE( EXPECT_FALSE(
identity_manager()->HasAccountWithRefreshToken(account_info.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info.account_id));
...@@ -919,7 +919,7 @@ TEST_F(IdentityManagerTest, GetAccountsReflectsNonemptyInitialState) { ...@@ -919,7 +919,7 @@ TEST_F(IdentityManagerTest, GetAccountsReflectsNonemptyInitialState) {
// Add a refresh token for the primary account and sanity-check that it shows // Add a refresh token for the primary account and sanity-check that it shows
// up in GetAccountsWithRefreshTokens(). // up in GetAccountsWithRefreshTokens().
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
std::vector<AccountInfo> accounts_after_update = std::vector<AccountInfo> accounts_after_update =
identity_manager()->GetAccountsWithRefreshTokens(); identity_manager()->GetAccountsWithRefreshTokens();
...@@ -950,7 +950,7 @@ TEST_F(IdentityManagerTest, ...@@ -950,7 +950,7 @@ TEST_F(IdentityManagerTest,
identity_manager()->HasAccountWithRefreshToken(account_info.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info.account_id));
EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken());
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_TRUE( EXPECT_TRUE(
identity_manager()->HasAccountWithRefreshToken(account_info.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info.account_id));
...@@ -974,7 +974,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithSecondaryAccounts) { ...@@ -974,7 +974,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithSecondaryAccounts) {
account_tracker()->SeedAccountInfo(kTestGaiaId2, kTestEmail2); account_tracker()->SeedAccountInfo(kTestGaiaId2, kTestEmail2);
std::string account_id2 = std::string account_id2 =
account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId2).account_id; account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId2).account_id;
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id2); SetRefreshTokenForAccount(identity_manager(), account_id2);
std::vector<AccountInfo> accounts_after_update = std::vector<AccountInfo> accounts_after_update =
identity_manager()->GetAccountsWithRefreshTokens(); identity_manager()->GetAccountsWithRefreshTokens();
...@@ -989,7 +989,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithSecondaryAccounts) { ...@@ -989,7 +989,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithSecondaryAccounts) {
account_tracker()->SeedAccountInfo(kTestGaiaId3, kTestEmail3); account_tracker()->SeedAccountInfo(kTestGaiaId3, kTestEmail3);
std::string account_id3 = std::string account_id3 =
account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId3).account_id; account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId3).account_id;
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id3); SetRefreshTokenForAccount(identity_manager(), account_id3);
std::vector<AccountInfo> accounts_after_second_update = std::vector<AccountInfo> accounts_after_second_update =
identity_manager()->GetAccountsWithRefreshTokens(); identity_manager()->GetAccountsWithRefreshTokens();
...@@ -1006,8 +1006,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithSecondaryAccounts) { ...@@ -1006,8 +1006,7 @@ TEST_F(IdentityManagerTest, GetAccountsInteractionWithSecondaryAccounts) {
} }
// Remove the token for account2 and check that account3 is still present. // Remove the token for account2 and check that account3 is still present.
RemoveRefreshTokenForAccount(token_service(), identity_manager(), RemoveRefreshTokenForAccount(identity_manager(), account_id2);
account_id2);
std::vector<AccountInfo> accounts_after_third_update = std::vector<AccountInfo> accounts_after_third_update =
identity_manager()->GetAccountsWithRefreshTokens(); identity_manager()->GetAccountsWithRefreshTokens();
...@@ -1027,7 +1026,7 @@ TEST_F(IdentityManagerTest, ...@@ -1027,7 +1026,7 @@ TEST_F(IdentityManagerTest,
account_tracker()->SeedAccountInfo(kTestGaiaId2, kTestEmail2); account_tracker()->SeedAccountInfo(kTestGaiaId2, kTestEmail2);
std::string account_id2 = std::string account_id2 =
account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId2).account_id; account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId2).account_id;
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id2); SetRefreshTokenForAccount(identity_manager(), account_id2);
EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken());
...@@ -1036,13 +1035,12 @@ TEST_F(IdentityManagerTest, ...@@ -1036,13 +1035,12 @@ TEST_F(IdentityManagerTest,
account_tracker()->SeedAccountInfo(kTestGaiaId3, kTestEmail3); account_tracker()->SeedAccountInfo(kTestGaiaId3, kTestEmail3);
std::string account_id3 = std::string account_id3 =
account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId3).account_id; account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId3).account_id;
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id3); SetRefreshTokenForAccount(identity_manager(), account_id3);
EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken());
// Removing the token for account2 should have no effect. // Removing the token for account2 should have no effect.
RemoveRefreshTokenForAccount(token_service(), identity_manager(), RemoveRefreshTokenForAccount(identity_manager(), account_id2);
account_id2);
EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken());
} }
...@@ -1059,7 +1057,7 @@ TEST_F(IdentityManagerTest, ...@@ -1059,7 +1057,7 @@ TEST_F(IdentityManagerTest,
// Add a refresh token for account_info2 and check that this is reflected by // Add a refresh token for account_info2 and check that this is reflected by
// HasAccountWithRefreshToken(.account_id). // HasAccountWithRefreshToken(.account_id).
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id2); SetRefreshTokenForAccount(identity_manager(), account_id2);
EXPECT_TRUE( EXPECT_TRUE(
identity_manager()->HasAccountWithRefreshToken(account_info2.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info2.account_id));
...@@ -1075,7 +1073,7 @@ TEST_F(IdentityManagerTest, ...@@ -1075,7 +1073,7 @@ TEST_F(IdentityManagerTest,
EXPECT_FALSE( EXPECT_FALSE(
identity_manager()->HasAccountWithRefreshToken(account_info3.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info3.account_id));
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id3); SetRefreshTokenForAccount(identity_manager(), account_id3);
EXPECT_TRUE( EXPECT_TRUE(
identity_manager()->HasAccountWithRefreshToken(account_info2.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info2.account_id));
...@@ -1083,8 +1081,7 @@ TEST_F(IdentityManagerTest, ...@@ -1083,8 +1081,7 @@ TEST_F(IdentityManagerTest,
identity_manager()->HasAccountWithRefreshToken(account_info3.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info3.account_id));
// Remove the token for account2. // Remove the token for account2.
RemoveRefreshTokenForAccount(token_service(), identity_manager(), RemoveRefreshTokenForAccount(identity_manager(), account_id2);
account_id2);
EXPECT_FALSE( EXPECT_FALSE(
identity_manager()->HasAccountWithRefreshToken(account_info2.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info2.account_id));
...@@ -1102,7 +1099,7 @@ TEST_F(IdentityManagerTest, ...@@ -1102,7 +1099,7 @@ TEST_F(IdentityManagerTest,
account_tracker()->SeedAccountInfo(kTestGaiaId2, kTestEmail2); account_tracker()->SeedAccountInfo(kTestGaiaId2, kTestEmail2);
std::string account_id2 = std::string account_id2 =
account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId2).account_id; account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId2).account_id;
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id2); SetRefreshTokenForAccount(identity_manager(), account_id2);
std::vector<AccountInfo> accounts_after_update = std::vector<AccountInfo> accounts_after_update =
identity_manager()->GetAccountsWithRefreshTokens(); identity_manager()->GetAccountsWithRefreshTokens();
...@@ -1118,7 +1115,7 @@ TEST_F(IdentityManagerTest, ...@@ -1118,7 +1115,7 @@ TEST_F(IdentityManagerTest,
// also shows up in GetAccountsWithRefreshTokens(). // also shows up in GetAccountsWithRefreshTokens().
std::string primary_account_id = std::string primary_account_id =
signin_manager()->GetAuthenticatedAccountId(); signin_manager()->GetAuthenticatedAccountId();
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
std::vector<AccountInfo> accounts_after_second_update = std::vector<AccountInfo> accounts_after_second_update =
identity_manager()->GetAccountsWithRefreshTokens(); identity_manager()->GetAccountsWithRefreshTokens();
...@@ -1138,7 +1135,7 @@ TEST_F(IdentityManagerTest, ...@@ -1138,7 +1135,7 @@ TEST_F(IdentityManagerTest,
// Remove the token for the primary account and check that account2 is still // Remove the token for the primary account and check that account2 is still
// present. // present.
RemoveRefreshTokenForPrimaryAccount(token_service(), identity_manager()); RemoveRefreshTokenForPrimaryAccount(identity_manager());
std::vector<AccountInfo> accounts_after_third_update = std::vector<AccountInfo> accounts_after_third_update =
identity_manager()->GetAccountsWithRefreshTokens(); identity_manager()->GetAccountsWithRefreshTokens();
...@@ -1161,7 +1158,7 @@ TEST_F( ...@@ -1161,7 +1158,7 @@ TEST_F(
account_tracker()->SeedAccountInfo(kTestGaiaId2, kTestEmail2); account_tracker()->SeedAccountInfo(kTestGaiaId2, kTestEmail2);
std::string account_id2 = std::string account_id2 =
account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId2).account_id; account_tracker()->FindAccountInfoByGaiaId(kTestGaiaId2).account_id;
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id2); SetRefreshTokenForAccount(identity_manager(), account_id2);
EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken());
...@@ -1169,20 +1166,19 @@ TEST_F( ...@@ -1169,20 +1166,19 @@ TEST_F(
// *does* impact the stsate of HasPrimaryAccountWithRefreshToken(). // *does* impact the stsate of HasPrimaryAccountWithRefreshToken().
std::string primary_account_id = std::string primary_account_id =
signin_manager()->GetAuthenticatedAccountId(); signin_manager()->GetAuthenticatedAccountId();
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_TRUE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_TRUE(identity_manager()->HasPrimaryAccountWithRefreshToken());
// Remove the token for the secondary account and check that this doesn't flip // Remove the token for the secondary account and check that this doesn't flip
// the state. // the state.
RemoveRefreshTokenForAccount(token_service(), identity_manager(), RemoveRefreshTokenForAccount(identity_manager(), account_id2);
account_id2);
EXPECT_TRUE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_TRUE(identity_manager()->HasPrimaryAccountWithRefreshToken());
// Remove the token for the primary account and check that this flips the // Remove the token for the primary account and check that this flips the
// state. // state.
RemoveRefreshTokenForPrimaryAccount(token_service(), identity_manager()); RemoveRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken()); EXPECT_FALSE(identity_manager()->HasPrimaryAccountWithRefreshToken());
} }
...@@ -1206,7 +1202,7 @@ TEST_F( ...@@ -1206,7 +1202,7 @@ TEST_F(
// Add a refresh token for account_info2 and check that this is reflected by // Add a refresh token for account_info2 and check that this is reflected by
// HasAccountWithRefreshToken(.account_id). // HasAccountWithRefreshToken(.account_id).
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id2); SetRefreshTokenForAccount(identity_manager(), account_id2);
EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken( EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(
primary_account_info.account_id)); primary_account_info.account_id));
...@@ -1214,7 +1210,7 @@ TEST_F( ...@@ -1214,7 +1210,7 @@ TEST_F(
identity_manager()->HasAccountWithRefreshToken(account_info2.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info2.account_id));
// Go through the same process for the primary account. // Go through the same process for the primary account.
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken( EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(
primary_account_info.account_id)); primary_account_info.account_id));
...@@ -1222,8 +1218,7 @@ TEST_F( ...@@ -1222,8 +1218,7 @@ TEST_F(
identity_manager()->HasAccountWithRefreshToken(account_info2.account_id)); identity_manager()->HasAccountWithRefreshToken(account_info2.account_id));
// Remove the token for account2. // Remove the token for account2.
RemoveRefreshTokenForAccount(token_service(), identity_manager(), RemoveRefreshTokenForAccount(identity_manager(), account_id2);
account_id2);
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken( EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(
primary_account_info.account_id)); primary_account_info.account_id));
...@@ -1245,7 +1240,7 @@ TEST_F(IdentityManagerTest, GetErrorStateOfRefreshTokenForAccount) { ...@@ -1245,7 +1240,7 @@ TEST_F(IdentityManagerTest, GetErrorStateOfRefreshTokenForAccount) {
identity_manager()->HasAccountWithRefreshTokenInPersistentErrorState( identity_manager()->HasAccountWithRefreshTokenInPersistentErrorState(
primary_account_id)); primary_account_id));
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(),
identity_manager()->GetErrorStateOfRefreshTokenForAccount( identity_manager()->GetErrorStateOfRefreshTokenForAccount(
primary_account_id)); primary_account_id));
...@@ -1266,7 +1261,7 @@ TEST_F(IdentityManagerTest, GetErrorStateOfRefreshTokenForAccount) { ...@@ -1266,7 +1261,7 @@ TEST_F(IdentityManagerTest, GetErrorStateOfRefreshTokenForAccount) {
identity_manager()->HasAccountWithRefreshTokenInPersistentErrorState( identity_manager()->HasAccountWithRefreshTokenInPersistentErrorState(
account_id2)); account_id2));
SetRefreshTokenForAccount(token_service(), identity_manager(), account_id2); SetRefreshTokenForAccount(identity_manager(), account_id2);
EXPECT_EQ( EXPECT_EQ(
GoogleServiceAuthError::AuthErrorNone(), GoogleServiceAuthError::AuthErrorNone(),
identity_manager()->GetErrorStateOfRefreshTokenForAccount(account_id2)); identity_manager()->GetErrorStateOfRefreshTokenForAccount(account_id2));
...@@ -1326,8 +1321,7 @@ TEST_F(IdentityManagerTest, GetErrorStateOfRefreshTokenForAccount) { ...@@ -1326,8 +1321,7 @@ TEST_F(IdentityManagerTest, GetErrorStateOfRefreshTokenForAccount) {
// Remove the token for account2 and check that it goes back to having no // Remove the token for account2 and check that it goes back to having no
// error. // error.
RemoveRefreshTokenForAccount(token_service(), identity_manager(), RemoveRefreshTokenForAccount(identity_manager(), account_id2);
account_id2);
EXPECT_EQ( EXPECT_EQ(
GoogleServiceAuthError::AuthErrorNone(), GoogleServiceAuthError::AuthErrorNone(),
identity_manager()->GetErrorStateOfRefreshTokenForAccount(account_id2)); identity_manager()->GetErrorStateOfRefreshTokenForAccount(account_id2));
...@@ -1576,7 +1570,7 @@ TEST_F(IdentityManagerTest, ...@@ -1576,7 +1570,7 @@ TEST_F(IdentityManagerTest,
CallbackSentOnPrimaryAccountRefreshTokenUpdateWithValidToken) { CallbackSentOnPrimaryAccountRefreshTokenUpdateWithValidToken) {
std::string account_id = signin_manager()->GetAuthenticatedAccountId(); std::string account_id = signin_manager()->GetAuthenticatedAccountId();
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
AccountInfo account_info = AccountInfo account_info =
identity_manager_observer() identity_manager_observer()
...@@ -1592,7 +1586,7 @@ TEST_F(IdentityManagerTest, ...@@ -1592,7 +1586,7 @@ TEST_F(IdentityManagerTest,
CallbackSentOnPrimaryAccountRefreshTokenUpdateWithInvalidToken) { CallbackSentOnPrimaryAccountRefreshTokenUpdateWithInvalidToken) {
std::string account_id = signin_manager()->GetAuthenticatedAccountId(); std::string account_id = signin_manager()->GetAuthenticatedAccountId();
SetInvalidRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetInvalidRefreshTokenForPrimaryAccount(identity_manager());
AccountInfo account_info = AccountInfo account_info =
identity_manager_observer() identity_manager_observer()
...@@ -1607,9 +1601,9 @@ TEST_F(IdentityManagerTest, ...@@ -1607,9 +1601,9 @@ TEST_F(IdentityManagerTest,
TEST_F(IdentityManagerTest, CallbackSentOnPrimaryAccountRefreshTokenRemoval) { TEST_F(IdentityManagerTest, CallbackSentOnPrimaryAccountRefreshTokenRemoval) {
std::string account_id = signin_manager()->GetAuthenticatedAccountId(); std::string account_id = signin_manager()->GetAuthenticatedAccountId();
SetRefreshTokenForPrimaryAccount(token_service(), identity_manager()); SetRefreshTokenForPrimaryAccount(identity_manager());
RemoveRefreshTokenForPrimaryAccount(token_service(), identity_manager()); RemoveRefreshTokenForPrimaryAccount(identity_manager());
EXPECT_EQ(account_id, identity_manager_observer() EXPECT_EQ(account_id, identity_manager_observer()
->account_from_refresh_token_removed_callback()); ->account_from_refresh_token_removed_callback());
...@@ -1617,8 +1611,8 @@ TEST_F(IdentityManagerTest, CallbackSentOnPrimaryAccountRefreshTokenRemoval) { ...@@ -1617,8 +1611,8 @@ TEST_F(IdentityManagerTest, CallbackSentOnPrimaryAccountRefreshTokenRemoval) {
TEST_F(IdentityManagerTest, TEST_F(IdentityManagerTest,
CallbackSentOnSecondaryAccountRefreshTokenUpdateWithValidToken) { CallbackSentOnSecondaryAccountRefreshTokenUpdateWithValidToken) {
AccountInfo expected_account_info = MakeAccountAvailable( AccountInfo expected_account_info =
account_tracker(), token_service(), identity_manager(), kTestEmail2); MakeAccountAvailable(identity_manager(), kTestEmail2);
EXPECT_EQ(kTestEmail2, expected_account_info.email); EXPECT_EQ(kTestEmail2, expected_account_info.email);
AccountInfo account_info = AccountInfo account_info =
...@@ -1634,11 +1628,11 @@ TEST_F(IdentityManagerTest, ...@@ -1634,11 +1628,11 @@ TEST_F(IdentityManagerTest,
TEST_F(IdentityManagerTest, TEST_F(IdentityManagerTest,
CallbackSentOnSecondaryAccountRefreshTokenUpdateWithInvalidToken) { CallbackSentOnSecondaryAccountRefreshTokenUpdateWithInvalidToken) {
AccountInfo expected_account_info = MakeAccountAvailable( AccountInfo expected_account_info =
account_tracker(), token_service(), identity_manager(), kTestEmail2); MakeAccountAvailable(identity_manager(), kTestEmail2);
EXPECT_EQ(kTestEmail2, expected_account_info.email); EXPECT_EQ(kTestEmail2, expected_account_info.email);
SetInvalidRefreshTokenForAccount(token_service(), identity_manager(), SetInvalidRefreshTokenForAccount(identity_manager(),
expected_account_info.account_id); expected_account_info.account_id);
AccountInfo account_info = AccountInfo account_info =
...@@ -1653,11 +1647,11 @@ TEST_F(IdentityManagerTest, ...@@ -1653,11 +1647,11 @@ TEST_F(IdentityManagerTest,
} }
TEST_F(IdentityManagerTest, CallbackSentOnSecondaryAccountRefreshTokenRemoval) { TEST_F(IdentityManagerTest, CallbackSentOnSecondaryAccountRefreshTokenRemoval) {
AccountInfo expected_account_info = MakeAccountAvailable( AccountInfo expected_account_info =
account_tracker(), token_service(), identity_manager(), kTestEmail2); MakeAccountAvailable(identity_manager(), kTestEmail2);
EXPECT_EQ(kTestEmail2, expected_account_info.email); EXPECT_EQ(kTestEmail2, expected_account_info.email);
RemoveRefreshTokenForAccount(token_service(), identity_manager(), RemoveRefreshTokenForAccount(identity_manager(),
expected_account_info.account_id); expected_account_info.account_id);
EXPECT_EQ(expected_account_info.account_id, EXPECT_EQ(expected_account_info.account_id,
...@@ -1675,8 +1669,8 @@ TEST_F( ...@@ -1675,8 +1669,8 @@ TEST_F(
signin_manager()->ForceSignOut(); signin_manager()->ForceSignOut();
run_loop.Run(); run_loop.Run();
AccountInfo expected_account_info = MakeAccountAvailable( AccountInfo expected_account_info =
account_tracker(), token_service(), identity_manager(), kTestEmail2); MakeAccountAvailable(identity_manager(), kTestEmail2);
EXPECT_EQ(kTestEmail2, expected_account_info.email); EXPECT_EQ(kTestEmail2, expected_account_info.email);
AccountInfo account_info = AccountInfo account_info =
...@@ -1699,11 +1693,11 @@ TEST_F( ...@@ -1699,11 +1693,11 @@ TEST_F(
signin_manager()->ForceSignOut(); signin_manager()->ForceSignOut();
run_loop.Run(); run_loop.Run();
AccountInfo expected_account_info = MakeAccountAvailable( AccountInfo expected_account_info =
account_tracker(), token_service(), identity_manager(), kTestEmail2); MakeAccountAvailable(identity_manager(), kTestEmail2);
EXPECT_EQ(kTestEmail2, expected_account_info.email); EXPECT_EQ(kTestEmail2, expected_account_info.email);
SetInvalidRefreshTokenForAccount(token_service(), identity_manager(), SetInvalidRefreshTokenForAccount(identity_manager(),
expected_account_info.account_id); expected_account_info.account_id);
AccountInfo account_info = AccountInfo account_info =
...@@ -1725,11 +1719,11 @@ TEST_F(IdentityManagerTest, ...@@ -1725,11 +1719,11 @@ TEST_F(IdentityManagerTest,
signin_manager()->ForceSignOut(); signin_manager()->ForceSignOut();
run_loop.Run(); run_loop.Run();
AccountInfo expected_account_info = MakeAccountAvailable( AccountInfo expected_account_info =
account_tracker(), token_service(), identity_manager(), kTestEmail2); MakeAccountAvailable(identity_manager(), kTestEmail2);
EXPECT_EQ(kTestEmail2, expected_account_info.email); EXPECT_EQ(kTestEmail2, expected_account_info.email);
RemoveRefreshTokenForAccount(token_service(), identity_manager(), RemoveRefreshTokenForAccount(identity_manager(),
expected_account_info.account_id); expected_account_info.account_id);
EXPECT_EQ(expected_account_info.account_id, EXPECT_EQ(expected_account_info.account_id,
......
...@@ -207,58 +207,50 @@ IdentityManager* IdentityTestEnvironment::identity_manager() { ...@@ -207,58 +207,50 @@ IdentityManager* IdentityTestEnvironment::identity_manager() {
AccountInfo IdentityTestEnvironment::SetPrimaryAccount( AccountInfo IdentityTestEnvironment::SetPrimaryAccount(
const std::string& email) { const std::string& email) {
return identity::SetPrimaryAccount(signin_manager_, identity_manager(), return identity::SetPrimaryAccount(identity_manager(), email);
email);
} }
void IdentityTestEnvironment::SetRefreshTokenForPrimaryAccount() { void IdentityTestEnvironment::SetRefreshTokenForPrimaryAccount() {
identity::SetRefreshTokenForPrimaryAccount(token_service_, identity::SetRefreshTokenForPrimaryAccount(identity_manager());
identity_manager());
} }
void IdentityTestEnvironment::SetInvalidRefreshTokenForPrimaryAccount() { void IdentityTestEnvironment::SetInvalidRefreshTokenForPrimaryAccount() {
identity::SetInvalidRefreshTokenForPrimaryAccount(token_service_, identity::SetInvalidRefreshTokenForPrimaryAccount(identity_manager());
identity_manager());
} }
void IdentityTestEnvironment::RemoveRefreshTokenForPrimaryAccount() { void IdentityTestEnvironment::RemoveRefreshTokenForPrimaryAccount() {
identity::RemoveRefreshTokenForPrimaryAccount(token_service_, identity::RemoveRefreshTokenForPrimaryAccount(identity_manager());
identity_manager());
} }
AccountInfo IdentityTestEnvironment::MakePrimaryAccountAvailable( AccountInfo IdentityTestEnvironment::MakePrimaryAccountAvailable(
const std::string& email) { const std::string& email) {
return identity::MakePrimaryAccountAvailable(signin_manager_, token_service_, return identity::MakePrimaryAccountAvailable(identity_manager(), email);
identity_manager(), email);
} }
void IdentityTestEnvironment::ClearPrimaryAccount( void IdentityTestEnvironment::ClearPrimaryAccount(
ClearPrimaryAccountPolicy policy) { ClearPrimaryAccountPolicy policy) {
identity::ClearPrimaryAccount(signin_manager_, identity_manager(), policy); identity::ClearPrimaryAccount(identity_manager(), policy);
} }
AccountInfo IdentityTestEnvironment::MakeAccountAvailable( AccountInfo IdentityTestEnvironment::MakeAccountAvailable(
const std::string& email) { const std::string& email) {
return identity::MakeAccountAvailable( return identity::MakeAccountAvailable(identity_manager(), email);
account_tracker_service_, token_service_, identity_manager(), email);
} }
void IdentityTestEnvironment::SetRefreshTokenForAccount( void IdentityTestEnvironment::SetRefreshTokenForAccount(
const std::string& account_id) { const std::string& account_id) {
return identity::SetRefreshTokenForAccount(token_service_, identity_manager(), return identity::SetRefreshTokenForAccount(identity_manager(), account_id);
account_id);
} }
void IdentityTestEnvironment::SetInvalidRefreshTokenForAccount( void IdentityTestEnvironment::SetInvalidRefreshTokenForAccount(
const std::string& account_id) { const std::string& account_id) {
return identity::SetInvalidRefreshTokenForAccount( return identity::SetInvalidRefreshTokenForAccount(identity_manager(),
token_service_, identity_manager(), account_id); account_id);
} }
void IdentityTestEnvironment::RemoveRefreshTokenForAccount( void IdentityTestEnvironment::RemoveRefreshTokenForAccount(
const std::string& account_id) { const std::string& account_id) {
return identity::RemoveRefreshTokenForAccount(token_service_, return identity::RemoveRefreshTokenForAccount(identity_manager(), account_id);
identity_manager(), account_id);
} }
void IdentityTestEnvironment::SetCookieAccounts( void IdentityTestEnvironment::SetCookieAccounts(
...@@ -407,7 +399,7 @@ void IdentityTestEnvironment::WaitForAccessTokenRequestIfNecessary( ...@@ -407,7 +399,7 @@ void IdentityTestEnvironment::WaitForAccessTokenRequestIfNecessary(
void IdentityTestEnvironment::UpdateAccountInfoForAccount( void IdentityTestEnvironment::UpdateAccountInfoForAccount(
AccountInfo account_info) { AccountInfo account_info) {
identity::UpdateAccountInfoForAccount(account_tracker_service_, account_info); identity::UpdateAccountInfoForAccount(identity_manager(), account_info);
} }
} // namespace identity } // namespace identity
...@@ -18,6 +18,14 @@ class IdentityTestEnvironmentProfileAdaptor; ...@@ -18,6 +18,14 @@ class IdentityTestEnvironmentProfileAdaptor;
namespace identity { namespace identity {
namespace {
#if defined(OS_CHROMEOS)
using SigninManagerForTest = FakeSigninManagerBase;
#else
using SigninManagerForTest = FakeSigninManager;
#endif // OS_CHROMEOS
}
// Internal class that creates and owns dependencies of IdentityManager // Internal class that creates and owns dependencies of IdentityManager
// when those dependencies are not passed in externally. // when those dependencies are not passed in externally.
class IdentityManagerDependenciesOwner; class IdentityManagerDependenciesOwner;
...@@ -31,12 +39,6 @@ class IdentityManagerDependenciesOwner; ...@@ -31,12 +39,6 @@ class IdentityManagerDependenciesOwner;
// base::test::ScopedTaskEnvironment instance variable to fulfill this // base::test::ScopedTaskEnvironment instance variable to fulfill this
// requirement. // requirement.
class IdentityTestEnvironment : public IdentityManager::DiagnosticsObserver { class IdentityTestEnvironment : public IdentityManager::DiagnosticsObserver {
#if defined(OS_CHROMEOS)
using SigninManagerForTest = FakeSigninManagerBase;
#else
using SigninManagerForTest = FakeSigninManager;
#endif // OS_CHROMEOS
public: public:
// Preferred constructor: constructs an IdentityManager object and its // Preferred constructor: constructs an IdentityManager object and its
// dependencies internally. Cannot be used if the client of this class // dependencies internally. Cannot be used if the client of this class
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_gaia_cookie_manager_service.h" #include "components/signin/core/browser/fake_gaia_cookie_manager_service.h"
#include "components/signin/core/browser/fake_signin_manager.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h" #include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "services/identity/public/cpp/identity_manager.h" #include "services/identity/public/cpp/identity_manager.h"
...@@ -127,11 +126,13 @@ void UpdateRefreshTokenForAccount(ProfileOAuth2TokenService* token_service, ...@@ -127,11 +126,13 @@ void UpdateRefreshTokenForAccount(ProfileOAuth2TokenService* token_service,
} // namespace } // namespace
AccountInfo SetPrimaryAccount(SigninManagerBase* signin_manager, AccountInfo SetPrimaryAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
const std::string& email) { const std::string& email) {
DCHECK(!signin_manager->IsAuthenticated());
DCHECK(!identity_manager->HasPrimaryAccount()); DCHECK(!identity_manager->HasPrimaryAccount());
SigninManagerBase* signin_manager = identity_manager->GetSigninManager();
DCHECK(!signin_manager->IsAuthenticated());
std::string gaia_id = "gaia_id_for_" + email; std::string gaia_id = "gaia_id_for_" + email;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
...@@ -168,48 +169,41 @@ AccountInfo SetPrimaryAccount(SigninManagerBase* signin_manager, ...@@ -168,48 +169,41 @@ AccountInfo SetPrimaryAccount(SigninManagerBase* signin_manager,
return identity_manager->GetPrimaryAccountInfo(); return identity_manager->GetPrimaryAccountInfo();
} }
void SetRefreshTokenForPrimaryAccount(ProfileOAuth2TokenService* token_service, void SetRefreshTokenForPrimaryAccount(IdentityManager* identity_manager) {
IdentityManager* identity_manager) {
DCHECK(identity_manager->HasPrimaryAccount()); DCHECK(identity_manager->HasPrimaryAccount());
std::string account_id = identity_manager->GetPrimaryAccountId(); std::string account_id = identity_manager->GetPrimaryAccountId();
std::string refresh_token = "refresh_token_for_" + account_id; std::string refresh_token = "refresh_token_for_" + account_id;
SetRefreshTokenForAccount(token_service, identity_manager, account_id); SetRefreshTokenForAccount(identity_manager, account_id);
} }
void SetInvalidRefreshTokenForPrimaryAccount( void SetInvalidRefreshTokenForPrimaryAccount(
ProfileOAuth2TokenService* token_service,
IdentityManager* identity_manager) { IdentityManager* identity_manager) {
DCHECK(identity_manager->HasPrimaryAccount()); DCHECK(identity_manager->HasPrimaryAccount());
std::string account_id = identity_manager->GetPrimaryAccountId(); std::string account_id = identity_manager->GetPrimaryAccountId();
SetInvalidRefreshTokenForAccount(token_service, identity_manager, account_id); SetInvalidRefreshTokenForAccount(identity_manager, account_id);
} }
void RemoveRefreshTokenForPrimaryAccount( void RemoveRefreshTokenForPrimaryAccount(
ProfileOAuth2TokenService* token_service,
IdentityManager* identity_manager) { IdentityManager* identity_manager) {
if (!identity_manager->HasPrimaryAccount()) if (!identity_manager->HasPrimaryAccount())
return; return;
std::string account_id = identity_manager->GetPrimaryAccountId(); std::string account_id = identity_manager->GetPrimaryAccountId();
RemoveRefreshTokenForAccount(token_service, identity_manager, account_id); RemoveRefreshTokenForAccount(identity_manager, account_id);
} }
AccountInfo MakePrimaryAccountAvailable( AccountInfo MakePrimaryAccountAvailable(
SigninManagerBase* signin_manager,
ProfileOAuth2TokenService* token_service,
IdentityManager* identity_manager, IdentityManager* identity_manager,
const std::string& email) { const std::string& email) {
AccountInfo account_info = AccountInfo account_info = SetPrimaryAccount(identity_manager, email);
SetPrimaryAccount(signin_manager, identity_manager, email); SetRefreshTokenForPrimaryAccount(identity_manager);
SetRefreshTokenForPrimaryAccount(token_service, identity_manager);
return account_info; return account_info;
} }
void ClearPrimaryAccount(SigninManagerBase* signin_manager, void ClearPrimaryAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
ClearPrimaryAccountPolicy policy) { ClearPrimaryAccountPolicy policy) {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// TODO(blundell): If we ever need this functionality on ChromeOS (which seems // TODO(blundell): If we ever need this functionality on ChromeOS (which seems
...@@ -225,8 +219,8 @@ void ClearPrimaryAccount(SigninManagerBase* signin_manager, ...@@ -225,8 +219,8 @@ void ClearPrimaryAccount(SigninManagerBase* signin_manager,
identity_manager, run_loop.QuitClosure(), identity_manager, run_loop.QuitClosure(),
IdentityManagerEvent::PRIMARY_ACCOUNT_CLEARED); IdentityManagerEvent::PRIMARY_ACCOUNT_CLEARED);
SigninManager* real_signin_manager = SigninManager* real_signin_manager = SigninManager::FromSigninManagerBase(
SigninManager::FromSigninManagerBase(signin_manager); identity_manager->GetSigninManager());
signin_metrics::ProfileSignout signout_source_metric = signin_metrics::ProfileSignout signout_source_metric =
signin_metrics::SIGNOUT_TEST; signin_metrics::SIGNOUT_TEST;
signin_metrics::SignoutDelete signout_delete_metric = signin_metrics::SignoutDelete signout_delete_metric =
...@@ -251,10 +245,12 @@ void ClearPrimaryAccount(SigninManagerBase* signin_manager, ...@@ -251,10 +245,12 @@ void ClearPrimaryAccount(SigninManagerBase* signin_manager,
#endif #endif
} }
AccountInfo MakeAccountAvailable(AccountTrackerService* account_tracker_service, AccountInfo MakeAccountAvailable(IdentityManager* identity_manager,
ProfileOAuth2TokenService* token_service,
IdentityManager* identity_manager,
const std::string& email) { const std::string& email) {
AccountTrackerService* account_tracker_service =
identity_manager->GetAccountTrackerService();
DCHECK(account_tracker_service);
DCHECK(account_tracker_service->FindAccountInfoByEmail(email).IsEmpty()); DCHECK(account_tracker_service->FindAccountInfoByEmail(email).IsEmpty());
std::string gaia_id = "gaia_id_for_" + email; std::string gaia_id = "gaia_id_for_" + email;
...@@ -264,30 +260,26 @@ AccountInfo MakeAccountAvailable(AccountTrackerService* account_tracker_service, ...@@ -264,30 +260,26 @@ AccountInfo MakeAccountAvailable(AccountTrackerService* account_tracker_service,
account_tracker_service->FindAccountInfoByEmail(email); account_tracker_service->FindAccountInfoByEmail(email);
DCHECK(!account_info.account_id.empty()); DCHECK(!account_info.account_id.empty());
SetRefreshTokenForAccount(token_service, identity_manager, SetRefreshTokenForAccount(identity_manager, account_info.account_id);
account_info.account_id);
return account_info; return account_info;
} }
void SetRefreshTokenForAccount(ProfileOAuth2TokenService* token_service, void SetRefreshTokenForAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
const std::string& account_id) { const std::string& account_id) {
std::string refresh_token = "refresh_token_for_" + account_id; std::string refresh_token = "refresh_token_for_" + account_id;
UpdateRefreshTokenForAccount(token_service, identity_manager, account_id, UpdateRefreshTokenForAccount(identity_manager->GetTokenService(),
refresh_token); identity_manager, account_id, refresh_token);
} }
void SetInvalidRefreshTokenForAccount(ProfileOAuth2TokenService* token_service, void SetInvalidRefreshTokenForAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
const std::string& account_id) { const std::string& account_id) {
UpdateRefreshTokenForAccount( UpdateRefreshTokenForAccount(
token_service, identity_manager, account_id, identity_manager->GetTokenService(), identity_manager, account_id,
OAuth2TokenServiceDelegate::kInvalidRefreshToken); OAuth2TokenServiceDelegate::kInvalidRefreshToken);
} }
void RemoveRefreshTokenForAccount(ProfileOAuth2TokenService* token_service, void RemoveRefreshTokenForAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
const std::string& account_id) { const std::string& account_id) {
if (!identity_manager->HasAccountWithRefreshToken(account_id)) if (!identity_manager->HasAccountWithRefreshToken(account_id))
return; return;
...@@ -297,7 +289,7 @@ void RemoveRefreshTokenForAccount(ProfileOAuth2TokenService* token_service, ...@@ -297,7 +289,7 @@ void RemoveRefreshTokenForAccount(ProfileOAuth2TokenService* token_service,
identity_manager, run_loop.QuitClosure(), identity_manager, run_loop.QuitClosure(),
IdentityManagerEvent::REFRESH_TOKEN_REMOVED); IdentityManagerEvent::REFRESH_TOKEN_REMOVED);
token_service->RevokeCredentials(account_id); identity_manager->GetTokenService()->RevokeCredentials(account_id);
run_loop.Run(); run_loop.Run();
} }
...@@ -326,9 +318,14 @@ void SetCookieAccounts(FakeGaiaCookieManagerService* cookie_manager, ...@@ -326,9 +318,14 @@ void SetCookieAccounts(FakeGaiaCookieManagerService* cookie_manager,
run_loop.Run(); run_loop.Run();
} }
void UpdateAccountInfoForAccount(AccountTrackerService* account_tracker_service, void UpdateAccountInfoForAccount(IdentityManager* identity_manager,
AccountInfo account_info) { AccountInfo account_info) {
// Make sure the account being updated is a known account. // Make sure the account being updated is a known account.
AccountTrackerService* account_tracker_service =
identity_manager->GetAccountTrackerService();
DCHECK(account_tracker_service);
DCHECK(!account_tracker_service->GetAccountInfo(account_info.account_id) DCHECK(!account_tracker_service->GetAccountInfo(account_info.account_id)
.account_id.empty()); .account_id.empty());
......
...@@ -10,18 +10,7 @@ ...@@ -10,18 +10,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/signin/core/browser/account_info.h" #include "components/signin/core/browser/account_info.h"
class AccountTrackerService;
class FakeGaiaCookieManagerService; class FakeGaiaCookieManagerService;
class FakeSigninManagerBase;
class FakeSigninManager;
class ProfileOAuth2TokenService;
class SigninManagerBase;
#if defined(OS_CHROMEOS)
using SigninManagerForTest = FakeSigninManagerBase;
#else
using SigninManagerForTest = FakeSigninManager;
#endif // OS_CHROMEOS
// Test-related utilities that don't fit in either IdentityTestEnvironment or // Test-related utilities that don't fit in either IdentityTestEnvironment or
// IdentityManager itself. NOTE: Using these utilities directly is discouraged, // IdentityManager itself. NOTE: Using these utilities directly is discouraged,
...@@ -57,28 +46,24 @@ class IdentityManager; ...@@ -57,28 +46,24 @@ class IdentityManager;
// SigninManager callbacks for signin success. Blocks until the primary account // SigninManager callbacks for signin success. Blocks until the primary account
// is set. Returns the AccountInfo of the newly-set account. // is set. Returns the AccountInfo of the newly-set account.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
AccountInfo SetPrimaryAccount(SigninManagerBase* signin_manager, AccountInfo SetPrimaryAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
const std::string& email); const std::string& email);
// Sets a refresh token for the primary account (which must already be set). // Sets a refresh token for the primary account (which must already be set).
// Blocks until the refresh token is set. // Blocks until the refresh token is set.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
void SetRefreshTokenForPrimaryAccount(ProfileOAuth2TokenService* token_service, void SetRefreshTokenForPrimaryAccount(IdentityManager* identity_manager);
IdentityManager* identity_manager);
// Sets a special invalid refresh token for the primary account (which must // Sets a special invalid refresh token for the primary account (which must
// already be set). Blocks until the refresh token is set. // already be set). Blocks until the refresh token is set.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
void SetInvalidRefreshTokenForPrimaryAccount( void SetInvalidRefreshTokenForPrimaryAccount(
ProfileOAuth2TokenService* token_service,
IdentityManager* identity_manager); IdentityManager* identity_manager);
// Removes any refresh token for the primary account, if present. Blocks until // Removes any refresh token for the primary account, if present. Blocks until
// the refresh token is removed. // the refresh token is removed.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
void RemoveRefreshTokenForPrimaryAccount( void RemoveRefreshTokenForPrimaryAccount(
ProfileOAuth2TokenService* token_service,
IdentityManager* identity_manager); IdentityManager* identity_manager);
// Makes the primary account (which must not already be set) available for the // Makes the primary account (which must not already be set) available for the
...@@ -89,8 +74,6 @@ void RemoveRefreshTokenForPrimaryAccount( ...@@ -89,8 +74,6 @@ void RemoveRefreshTokenForPrimaryAccount(
// newly-available account. // newly-available account.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
AccountInfo MakePrimaryAccountAvailable( AccountInfo MakePrimaryAccountAvailable(
SigninManagerBase* signin_manager,
ProfileOAuth2TokenService* token_service,
IdentityManager* identity_manager, IdentityManager* identity_manager,
const std::string& email); const std::string& email);
...@@ -100,7 +83,6 @@ AccountInfo MakePrimaryAccountAvailable( ...@@ -100,7 +83,6 @@ AccountInfo MakePrimaryAccountAvailable(
// until the primary account is cleared. // until the primary account is cleared.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
void ClearPrimaryAccount( void ClearPrimaryAccount(
SigninManagerBase* signin_manager,
IdentityManager* identity_manager, IdentityManager* identity_manager,
ClearPrimaryAccountPolicy policy = ClearPrimaryAccountPolicy::DEFAULT); ClearPrimaryAccountPolicy policy = ClearPrimaryAccountPolicy::DEFAULT);
...@@ -109,31 +91,26 @@ void ClearPrimaryAccount( ...@@ -109,31 +91,26 @@ void ClearPrimaryAccount(
// until the account is available. Returns the AccountInfo of the // until the account is available. Returns the AccountInfo of the
// newly-available account. // newly-available account.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
AccountInfo MakeAccountAvailable(AccountTrackerService* account_tracker_service, AccountInfo MakeAccountAvailable(IdentityManager* identity_manager,
ProfileOAuth2TokenService* token_service,
IdentityManager* identity_manager,
const std::string& email); const std::string& email);
// Sets a refresh token for the given account (which must already be available). // Sets a refresh token for the given account (which must already be available).
// Blocks until the refresh token is set. // Blocks until the refresh token is set.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
void SetRefreshTokenForAccount(ProfileOAuth2TokenService* token_service, void SetRefreshTokenForAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
const std::string& account_id); const std::string& account_id);
// Sets a special invalid refresh token for the given account (which must // Sets a special invalid refresh token for the given account (which must
// already be available). Blocks until the refresh token is set. // already be available). Blocks until the refresh token is set.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
void SetInvalidRefreshTokenForAccount(ProfileOAuth2TokenService* token_service, void SetInvalidRefreshTokenForAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
const std::string& account_id); const std::string& account_id);
// Removes any refresh token that is present for the given account. Blocks until // Removes any refresh token that is present for the given account. Blocks until
// the refresh token is removed. Is a no-op if no refresh token is present for // the refresh token is removed. Is a no-op if no refresh token is present for
// the given account. // the given account.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
void RemoveRefreshTokenForAccount(ProfileOAuth2TokenService* token_service, void RemoveRefreshTokenForAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager,
const std::string& account_id); const std::string& account_id);
// Puts the given accounts into the Gaia cookie, replacing any previous // Puts the given accounts into the Gaia cookie, replacing any previous
...@@ -145,7 +122,7 @@ void SetCookieAccounts(FakeGaiaCookieManagerService* cookie_manager, ...@@ -145,7 +122,7 @@ void SetCookieAccounts(FakeGaiaCookieManagerService* cookie_manager,
// Updates the info for |account_info.account_id|, which must be a known // Updates the info for |account_info.account_id|, which must be a known
// account. // account.
void UpdateAccountInfoForAccount(AccountTrackerService* account_tracker_service, void UpdateAccountInfoForAccount(IdentityManager* identity_manager,
AccountInfo account_info); AccountInfo account_info);
} // namespace identity } // namespace identity
......
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