summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorrogerta <rogerta@chromium.org>2015-04-16 21:16:37 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-17 04:16:59 +0000
commita1e15d29e401465bacd0681f256af567e7b8242f (patch)
tree5225a6498d80fa5bdaf6639cd51f9fe1ac3eef32 /chrome/browser
parent950576043d18caee3fc8bb28dfc432c3d6adcbda (diff)
downloadchromium_src-a1e15d29e401465bacd0681f256af567e7b8242f.zip
chromium_src-a1e15d29e401465bacd0681f256af567e7b8242f.tar.gz
chromium_src-a1e15d29e401465bacd0681f256af567e7b8242f.tar.bz2
Replace SetAuthenticatedUsername with SetAuthenticatedAccountId.
Depends on https://codereview.chromium.org/964553002/ BUG=341408 Review URL: https://codereview.chromium.org/964563002 Cr-Commit-Position: refs/heads/master@{#325594}
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/app_controller_mac_unittest.mm4
-rw-r--r--chrome/browser/autocomplete/search_provider_unittest.cc4
-rw-r--r--chrome/browser/autofill/personal_data_manager_factory.cc4
-rw-r--r--chrome/browser/chromeos/file_manager/file_manager_browsertest.cc13
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller_browsertest.cc8
-rw-r--r--chrome/browser/chromeos/login/login_browsertest.cc2
-rw-r--r--chrome/browser/chromeos/login/login_manager_test.cc7
-rw-r--r--chrome/browser/chromeos/login/login_manager_test.h2
-rw-r--r--chrome/browser/chromeos/login/session/stub_login_session_manager_delegate.cc2
-rw-r--r--chrome/browser/chromeos/login/session/user_session_manager.cc20
-rw-r--r--chrome/browser/chromeos/login/signin/oauth2_browsertest.cc60
-rw-r--r--chrome/browser/chromeos/login/supervised/supervised_user_test_base.cc1
-rw-r--r--chrome/browser/chromeos/policy/consumer_enrollment_handler_unittest.cc26
-rw-r--r--chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc28
-rw-r--r--chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc6
-rw-r--r--chrome/browser/extensions/api/identity/identity_apitest.cc22
-rw-r--r--chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc3
-rw-r--r--chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc2
-rw-r--r--chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc4
-rw-r--r--chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc6
-rw-r--r--chrome/browser/policy/cloud/cloud_policy_browsertest.cc8
-rw-r--r--chrome/browser/policy/cloud/cloud_policy_manager_browsertest.cc2
-rw-r--r--chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc2
-rw-r--r--chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc63
-rw-r--r--chrome/browser/prefs/chrome_pref_service_factory.cc8
-rw-r--r--chrome/browser/profiles/gaia_info_update_service_unittest.cc9
-rw-r--r--chrome/browser/services/gcm/fake_signin_manager.cc15
-rw-r--r--chrome/browser/signin/account_reconcilor_unittest.cc203
-rw-r--r--chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc2
-rw-r--r--chrome/browser/signin/fake_signin_manager.cc27
-rw-r--r--chrome/browser/signin/fake_signin_manager.h12
-rw-r--r--chrome/browser/signin/signin_global_error_unittest.cc6
-rw-r--r--chrome/browser/signin/signin_manager_factory.cc15
-rw-r--r--chrome/browser/signin/signin_manager_unittest.cc103
-rw-r--r--chrome/browser/signin/signin_names_io_thread_unittest.cc9
-rw-r--r--chrome/browser/signin/signin_tracker_unittest.cc25
-rw-r--r--chrome/browser/supervised_user/supervised_user_service_unittest.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_autofill_unittest.cc8
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_startup_unittest.cc100
-rw-r--r--chrome/browser/sync/profile_sync_service_typed_url_unittest.cc9
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc15
-rw-r--r--chrome/browser/sync/sync_ui_util_unittest.cc7
-rw-r--r--chrome/browser/sync/test/integration/profile_sync_service_harness.cc16
-rw-r--r--chrome/browser/ui/app_list/speech_auth_helper_unittest.cc5
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc7
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc6
-rw-r--r--chrome/browser/ui/autofill/country_combobox_model_unittest.cc6
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/search/search_tab_helper_unittest.cc2
-rw-r--r--chrome/browser/ui/sync/one_click_signin_sync_starter.cc5
-rw-r--r--chrome/browser/ui/sync/one_click_signin_sync_starter.h1
-rw-r--r--chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc9
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bubble_view_unittest.cc3
-rw-r--r--chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc3
-rw-r--r--chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc3
-rw-r--r--chrome/browser/ui/webui/options/options_ui_browsertest.cc9
-rw-r--r--chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc4
-rw-r--r--chrome/browser/ui/webui/signin/inline_login_handler_impl.cc13
-rw-r--r--chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc2
61 files changed, 670 insertions, 304 deletions
diff --git a/chrome/browser/app_controller_mac_unittest.mm b/chrome/browser/app_controller_mac_unittest.mm
index 5994196..a0de9d4 100644
--- a/chrome/browser/app_controller_mac_unittest.mm
+++ b/chrome/browser/app_controller_mac_unittest.mm
@@ -124,7 +124,7 @@ TEST_F(AppControllerTest, TestSigninMenuItemNoErrors) {
NSString* alreadySignedIn = l10n_util::GetNSStringFWithFixup(
IDS_SYNC_MENU_SYNCED_LABEL, base::UTF8ToUTF16(username));
SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
- signin->SetAuthenticatedUsername(username);
+ signin->SetAuthenticatedAccountInfo(username, username);
ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile(profile_);
sync->SetSyncSetupCompleted();
[AppController updateSigninItem:syncMenuItem
@@ -144,7 +144,7 @@ TEST_F(AppControllerTest, TestSigninMenuItemAuthError) {
// Now sign in.
std::string username = "foo@example.com";
SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
- signin->SetAuthenticatedUsername(username);
+ signin->SetAuthenticatedAccountInfo(username, username);
ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile(profile_);
sync->SetSyncSetupCompleted();
// Force an auth error.
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index 68cb6f0..9723caf 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/autocomplete/history_url_provider.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
@@ -45,6 +46,7 @@
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/pref_names.h"
#include "components/variations/entropy_provider.h"
@@ -3242,7 +3244,7 @@ TEST_F(SearchProviderTest, CanSendURL) {
GURL("https://www.google.com/complete/search"), &google_template_url,
metrics::OmniboxEventProto::OTHER, SearchTermsData(), &client));
SigninManagerBase* signin = SigninManagerFactory::GetForProfile(&profile_);
- signin->SetAuthenticatedUsername("test");
+ signin->SetAuthenticatedAccountInfo("gaia_id", "test");
// All conditions should be met.
EXPECT_TRUE(SearchProvider::CanSendURL(
diff --git a/chrome/browser/autofill/personal_data_manager_factory.cc b/chrome/browser/autofill/personal_data_manager_factory.cc
index 7550508..c68b7af 100644
--- a/chrome/browser/autofill/personal_data_manager_factory.cc
+++ b/chrome/browser/autofill/personal_data_manager_factory.cc
@@ -9,10 +9,12 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/webdata/web_data_service_factory.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "components/signin/core/browser/account_tracker_service.h"
namespace autofill {
@@ -32,6 +34,7 @@ PersonalDataManagerFactory::PersonalDataManagerFactory()
: BrowserContextKeyedServiceFactory(
"PersonalDataManager",
BrowserContextDependencyManager::GetInstance()) {
+ DependsOn(AccountTrackerServiceFactory::GetInstance());
DependsOn(WebDataServiceFactory::GetInstance());
}
@@ -46,6 +49,7 @@ KeyedService* PersonalDataManagerFactory::BuildServiceInstanceFor(
service->Init(WebDataServiceFactory::GetAutofillWebDataForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS),
profile->GetPrefs(),
+ AccountTrackerServiceFactory::GetForProfile(profile),
profile->IsOffTheRecord());
return service;
}
diff --git a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc
index 0221a61..cef9f59 100644
--- a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc
+++ b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc
@@ -1224,6 +1224,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
// Structure to describe an account info.
struct TestAccountInfo {
+ const char* const gaia_id;
const char* const email;
const char* const hash;
const char* const display_name;
@@ -1236,10 +1237,10 @@ enum {
};
static const TestAccountInfo kTestAccounts[] = {
- {"__dummy__@invalid.domain", "hashdummy", "Dummy Account"},
- {"alice@invalid.domain", "hashalice", "Alice"},
- {"bob@invalid.domain", "hashbob", "Bob"},
- {"charlie@invalid.domain", "hashcharlie", "Charlie"},
+ {"gaia-id-d", "__dummy__@invalid.domain", "hashdummy", "Dummy Account"},
+ {"gaia-id-a", "alice@invalid.domain", "hashalice", "Alice"},
+ {"gaia-id-b", "bob@invalid.domain", "hashbob", "Bob"},
+ {"gaia-id-c", "charlie@invalid.domain", "hashcharlie", "Charlie"},
};
// Test fixture class for testing multi-profile features.
@@ -1292,8 +1293,8 @@ class MultiProfileFileManagerBrowserTest : public FileManagerBrowserTestBase {
user_manager->SaveUserDisplayName(info.email,
base::UTF8ToUTF16(info.display_name));
SigninManagerFactory::GetForProfile(
- chromeos::ProfileHelper::GetProfileByUserIdHash(info.hash))->
- SetAuthenticatedUsername(info.email);
+ chromeos::ProfileHelper::GetProfileByUserIdHash(info.hash))
+ ->SetAuthenticatedAccountInfo(info.gaia_id, info.email);
}
private:
diff --git a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
index bfc4e3b..ca519f1 100644
--- a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
@@ -71,6 +71,7 @@ namespace chromeos {
namespace {
+const char kGaiaID[] = "12345";
const char kUsername[] = "test_user@gmail.com";
const char kSupervisedUserID[] = "supervised_user@locally-managed.localhost";
const char kPassword[] = "test_password";
@@ -227,6 +228,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) {
EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
.Times(2);
UserContext user_context(kUsername);
+ user_context.SetGaiaID(kGaiaID);
user_context.SetKey(Key(kPassword));
user_context.SetUserIDHash(kUsername);
test::UserSessionManagerTestApi session_manager_test_api(
@@ -277,6 +279,7 @@ void ExistingUserControllerUntrustedTest::SetUpSessionManager() {
IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest,
ExistingUserLoginForbidden) {
UserContext user_context(kUsername);
+ user_context.SetGaiaID(kGaiaID);
user_context.SetKey(Key(kPassword));
user_context.SetUserIDHash(kUsername);
existing_user_controller()->Login(user_context, SigninSpecifics());
@@ -285,6 +288,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest,
IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest,
NewUserLoginForbidden) {
UserContext user_context(kUsername);
+ user_context.SetGaiaID(kGaiaID);
user_context.SetKey(Key(kPassword));
user_context.SetUserIDHash(kUsername);
existing_user_controller()->CompleteLogin(user_context);
@@ -569,6 +573,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
LoginStopsAutoLogin) {
// Set up mocks to check login success.
UserContext user_context(kUsername);
+ user_context.SetGaiaID(kGaiaID);
user_context.SetKey(Key(kPassword));
user_context.SetUserIDHash(user_context.GetUserID());
ExpectSuccessfulLogin(user_context);
@@ -602,6 +607,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
.Times(2);
UserContext user_context(kUsername);
+ user_context.SetGaiaID(kGaiaID);
user_context.SetKey(Key(kPassword));
test::UserSessionManagerTestApi session_manager_test_api(
UserSessionManager::GetInstance());
@@ -631,6 +637,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
CompleteLoginStopsAutoLogin) {
// Set up mocks to check login success.
UserContext user_context(kUsername);
+ user_context.SetGaiaID(kGaiaID);
user_context.SetKey(Key(kPassword));
user_context.SetUserIDHash(user_context.GetUserID());
ExpectSuccessfulLogin(user_context);
@@ -703,6 +710,7 @@ IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
// Check that the attempt to start a public session fails with an error.
ExpectLoginFailure();
UserContext user_context(kUsername);
+ user_context.SetGaiaID(kGaiaID);
user_context.SetKey(Key(kPassword));
user_context.SetUserIDHash(user_context.GetUserID());
existing_user_controller()->Login(user_context, SigninSpecifics());
diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc
index 5d1cffa..fa8574b 100644
--- a/chrome/browser/chromeos/login/login_browsertest.cc
+++ b/chrome/browser/chromeos/login/login_browsertest.cc
@@ -42,6 +42,7 @@ using ::testing::Return;
namespace {
+const char kGaiaId[] = "12345";
const char kTestUser[] = "test-user@gmail.com";
const char kPassword[] = "password";
@@ -262,6 +263,7 @@ IN_PROC_BROWSER_TEST_F(LoginOfflineTest, GaiaAuthOffline) {
StartGaiaAuthOffline();
chromeos::UserContext user_context(kTestUser);
+ user_context.SetGaiaID(kGaiaId);
user_context.SetKey(chromeos::Key(kPassword));
SetExpectedCredentials(user_context);
diff --git a/chrome/browser/chromeos/login/login_manager_test.cc b/chrome/browser/chromeos/login/login_manager_test.cc
index bd44832..89cf712 100644
--- a/chrome/browser/chromeos/login/login_manager_test.cc
+++ b/chrome/browser/chromeos/login/login_manager_test.cc
@@ -136,6 +136,7 @@ bool LoginManagerTest::AddUserToSession(const UserContext& user_context) {
void LoginManagerTest::LoginUser(const std::string& user_id) {
UserContext user_context(user_id);
+ user_context.SetGaiaID(GetGaiaIDForUserID(user_id));
user_context.SetKey(Key("password"));
SetExpectedCredentials(user_context);
EXPECT_TRUE(TryToLogin(user_context));
@@ -143,11 +144,17 @@ void LoginManagerTest::LoginUser(const std::string& user_id) {
void LoginManagerTest::AddUser(const std::string& user_id) {
UserContext user_context(user_id);
+ user_context.SetGaiaID(GetGaiaIDForUserID(user_id));
user_context.SetKey(Key("password"));
SetExpectedCredentials(user_context);
EXPECT_TRUE(AddUserToSession(user_context));
}
+// static
+std::string LoginManagerTest::GetGaiaIDForUserID(const std::string& user_id) {
+ return "gaia-id-" + user_id;
+}
+
void LoginManagerTest::JSExpect(const std::string& expression) {
js_checker_.ExpectTrue(expression);
}
diff --git a/chrome/browser/chromeos/login/login_manager_test.h b/chrome/browser/chromeos/login/login_manager_test.h
index ff4a6dd..caa2a14 100644
--- a/chrome/browser/chromeos/login/login_manager_test.h
+++ b/chrome/browser/chromeos/login/login_manager_test.h
@@ -67,6 +67,8 @@ class LoginManagerTest : public MixinBasedBrowserTest {
test::JSChecker& js_checker() { return js_checker_; }
+ static std::string GetGaiaIDForUserID(const std::string& user_id);
+
protected:
bool use_webview() { return use_webview_; }
void set_use_webview(bool use_webview) { use_webview_ = use_webview; }
diff --git a/chrome/browser/chromeos/login/session/stub_login_session_manager_delegate.cc b/chrome/browser/chromeos/login/session/stub_login_session_manager_delegate.cc
index 5a76212..b9f4083 100644
--- a/chrome/browser/chromeos/login/session/stub_login_session_manager_delegate.cc
+++ b/chrome/browser/chromeos/login/session/stub_login_session_manager_delegate.cc
@@ -26,7 +26,7 @@ void StubLoginSessionManagerDelegate::Start() {
// For dev machines and stub user emulate as if sync has been initialized.
SigninManagerFactory::GetForProfile(profile())
- ->SetAuthenticatedUsername(login_user_id());
+ ->SetAuthenticatedAccountInfo(login_user_id(), login_user_id());
RestoreAfterCrashSessionManagerDelegate::Start();
}
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc
index 50f75fb..01d04f1 100644
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc
@@ -929,15 +929,18 @@ void UserSessionManager::InitProfilePreferences(
supervised_user_sync_id);
} else if (user_manager::UserManager::Get()->
IsLoggedInAsUserWithGaiaAccount()) {
- // Prime the account tracker with this combination of gaia id/display email.
- // Don't do this unless both email and gaia_id are valid. They may not
- // be when simply unlocking the profile.
- if (!user_context.GetGaiaID().empty() &&
- !user_context.GetUserID().empty()) {
+ // Get the Gaia ID from the user context. If it's not available, this may
+ // not be available when unlocking a previously opened profile, or when
+ // creating a supervised users. However, in these cases the gaia_id should
+ // be already available in the account tracker.
+ std::string gaia_id = user_context.GetGaiaID();
+ if (gaia_id.empty()) {
AccountTrackerService* account_tracker =
AccountTrackerServiceFactory::GetForProfile(profile);
- account_tracker->SeedAccountInfo(user_context.GetGaiaID(),
- user_context.GetUserID());
+ AccountTrackerService::AccountInfo info =
+ account_tracker->FindAccountInfoByEmail(user_context.GetUserID());
+ gaia_id = info.gaia;
+ DCHECK(!gaia_id.empty());
}
// Make sure that the google service username is properly set (we do this
@@ -945,7 +948,8 @@ void UserSessionManager::InitProfilePreferences(
// profiles that might not have it set yet).
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfile(profile);
- signin_manager->SetAuthenticatedUsername(user_context.GetUserID());
+ signin_manager->SetAuthenticatedAccountInfo(gaia_id,
+ user_context.GetUserID());
}
}
diff --git a/chrome/browser/chromeos/login/signin/oauth2_browsertest.cc b/chrome/browser/chromeos/login/signin/oauth2_browsertest.cc
index c09e3a7..dc10ab14 100644
--- a/chrome/browser/chromeos/login/signin/oauth2_browsertest.cc
+++ b/chrome/browser/chromeos/login/signin/oauth2_browsertest.cc
@@ -29,6 +29,7 @@
#include "chromeos/login/auth/user_context.h"
#include "components/app_modal/javascript_app_modal_dialog.h"
#include "components/app_modal/native_app_modal_dialog.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
@@ -58,8 +59,9 @@ namespace chromeos {
namespace {
// Email of owner account for test.
-const char kTestAccountId[] = "username@gmail.com";
-const char kTestRawAccountId[] = "User.Name";
+const char kTestGaiaId[] = "12345";
+const char kTestEmail[] = "username@gmail.com";
+const char kTestRawEmail[] = "User.Name@gmail.com";
const char kTestAccountPassword[] = "fake-password";
const char kTestAuthCode[] = "fake-auth-code";
const char kTestGaiaUberToken[] = "fake-uber-token";
@@ -76,6 +78,13 @@ const char kTestLoginToken[] = "fake-login-token";
const char kTestSyncToken[] = "fake-sync-token";
const char kTestAuthLoginToken[] = "fake-oauthlogin-token";
+std::string PickAccountId(Profile* profile,
+ const std::string& gaia_id,
+ const std::string& email) {
+ return AccountTrackerService::PickAccountIdForAccount(profile->GetPrefs(),
+ gaia_id, email);
+}
+
class OAuth2LoginManagerStateWaiter : public OAuth2LoginManager::Observer {
public:
explicit OAuth2LoginManagerStateWaiter(Profile* profile)
@@ -162,7 +171,7 @@ class OAuth2Test : public OobeBaseTest,
void SetupGaiaServerForUnexpiredAccount() {
FakeGaia::MergeSessionParams params;
- params.email = kTestAccountId;
+ params.email = kTestEmail;
fake_gaia_->SetMergeSessionParams(params);
SetupGaiaServerWithAccessTokens();
}
@@ -184,10 +193,14 @@ class OAuth2Test : public OobeBaseTest,
JsExpect("!!document.querySelector('#account-picker')");
JsExpect("!!document.querySelector('#pod-row')");
- EXPECT_EQ(GetOAuthStatusFromLocalState(kTestAccountId),
+ std::string account_id = PickAccountId(
+ ProfileManager::GetPrimaryUserProfile(), kTestGaiaId, kTestEmail);
+
+ EXPECT_EQ(GetOAuthStatusFromLocalState(account_id),
user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
- EXPECT_TRUE(TryToLogin(kTestAccountId, kTestAccountPassword));
+ // Try login. Primary profile has changed.
+ EXPECT_TRUE(TryToLogin(kTestGaiaId, kTestEmail, kTestAccountPassword));
Profile* profile = ProfileManager::GetPrimaryUserProfile();
// Wait for the session merge to finish.
@@ -196,15 +209,16 @@ class OAuth2Test : public OobeBaseTest,
// Check for existance of refresh token.
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
- EXPECT_TRUE(token_service->RefreshTokenIsAvailable(kTestAccountId));
+ EXPECT_TRUE(token_service->RefreshTokenIsAvailable(account_id));
- EXPECT_EQ(GetOAuthStatusFromLocalState(kTestAccountId),
+ EXPECT_EQ(GetOAuthStatusFromLocalState(account_id),
user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
}
- bool TryToLogin(const std::string& username,
+ bool TryToLogin(const std::string& gaia_id,
+ const std::string& username,
const std::string& password) {
- if (!AddUserToSession(username, password))
+ if (!AddUserToSession(gaia_id, username, password))
return false;
if (const user_manager::User* active_user =
@@ -216,14 +230,14 @@ class OAuth2Test : public OobeBaseTest,
}
user_manager::User::OAuthTokenStatus GetOAuthStatusFromLocalState(
- const std::string& user_id) const {
+ const std::string& account_id) const {
PrefService* local_state = g_browser_process->local_state();
const base::DictionaryValue* prefs_oauth_status =
local_state->GetDictionary("OAuthTokenStatus");
int oauth_token_status = user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN;
if (prefs_oauth_status &&
prefs_oauth_status->GetIntegerWithoutPathExpansion(
- user_id, &oauth_token_status)) {
+ account_id, &oauth_token_status)) {
user_manager::User::OAuthTokenStatus result =
static_cast<user_manager::User::OAuthTokenStatus>(oauth_token_status);
return result;
@@ -240,7 +254,8 @@ class OAuth2Test : public OobeBaseTest,
return OobeBaseTest::profile();
}
- bool AddUserToSession(const std::string& username,
+ bool AddUserToSession(const std::string& gaia_id,
+ const std::string& username,
const std::string& password) {
ExistingUserController* controller =
ExistingUserController::current_controller();
@@ -250,6 +265,7 @@ class OAuth2Test : public OobeBaseTest,
}
UserContext user_context(username);
+ user_context.SetGaiaID(gaia_id);
user_context.SetKey(Key(password));
controller->Login(user_context, SigninSpecifics());
content::WindowedNotificationObserver(
@@ -267,6 +283,8 @@ class OAuth2Test : public OobeBaseTest,
}
void SetupGaiaServerWithAccessTokens() {
+ fake_gaia_->MapEmailToGaiaId(kTestEmail, kTestGaiaId);
+
// Configure OAuth authentication.
GaiaUrls* gaia_urls = GaiaUrls::GetInstance();
@@ -277,7 +295,7 @@ class OAuth2Test : public OobeBaseTest,
userinfo_token_info.scopes.insert(
"https://www.googleapis.com/auth/userinfo.email");
userinfo_token_info.audience = gaia_urls->oauth2_chrome_client_id();
- userinfo_token_info.email = kTestAccountId;
+ userinfo_token_info.email = kTestEmail;
fake_gaia_->IssueOAuthToken(kTestRefreshToken, userinfo_token_info);
FakeGaia::AccessTokenInfo userinfo_profile_token_info;
@@ -285,7 +303,7 @@ class OAuth2Test : public OobeBaseTest,
userinfo_profile_token_info.scopes.insert(
"https://www.googleapis.com/auth/userinfo.profile");
userinfo_profile_token_info.audience = gaia_urls->oauth2_chrome_client_id();
- userinfo_profile_token_info.email = kTestAccountId;
+ userinfo_profile_token_info.email = kTestEmail;
fake_gaia_->IssueOAuthToken(kTestRefreshToken, userinfo_profile_token_info);
// The any-api access token for accessing the token minting endpoint.
@@ -339,7 +357,7 @@ class OAuth2Test : public OobeBaseTest,
// Use capitalized and dotted user name on purpose to make sure
// our email normalization kicks in.
- GetLoginDisplay()->ShowSigninScreenForCreds(kTestRawAccountId,
+ GetLoginDisplay()->ShowSigninScreenForCreds(kTestRawEmail,
kTestAccountPassword);
session_start_waiter.Wait();
@@ -415,12 +433,13 @@ class CookieReader : public base::RefCountedThreadSafe<CookieReader> {
IN_PROC_BROWSER_TEST_P(OAuth2Test, PRE_PRE_PRE_MergeSession) {
StartNewUserSession(true);
// Check for existance of refresh token.
+ std::string account_id = PickAccountId(profile(), kTestGaiaId, kTestEmail);
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(
profile());
- EXPECT_TRUE(token_service->RefreshTokenIsAvailable(kTestAccountId));
+ EXPECT_TRUE(token_service->RefreshTokenIsAvailable(account_id));
- EXPECT_EQ(GetOAuthStatusFromLocalState(kTestAccountId),
+ EXPECT_EQ(GetOAuthStatusFromLocalState(account_id),
user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
scoped_refptr<CookieReader> cookie_reader(new CookieReader());
cookie_reader->ReadCookies(profile());
@@ -472,15 +491,16 @@ IN_PROC_BROWSER_TEST_P(OAuth2Test, MergeSession) {
JsExpect("!!document.querySelector('#account-picker')");
JsExpect("!!document.querySelector('#pod-row')");
- EXPECT_EQ(GetOAuthStatusFromLocalState(kTestAccountId),
+ std::string account_id = PickAccountId(profile(), kTestGaiaId, kTestEmail);
+ EXPECT_EQ(GetOAuthStatusFromLocalState(account_id),
user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
- EXPECT_TRUE(TryToLogin(kTestAccountId, kTestAccountPassword));
+ EXPECT_TRUE(TryToLogin(kTestGaiaId, kTestEmail, kTestAccountPassword));
// Wait for the session merge to finish.
WaitForMergeSessionCompletion(OAuth2LoginManager::SESSION_RESTORE_FAILED);
- EXPECT_EQ(GetOAuthStatusFromLocalState(kTestAccountId),
+ EXPECT_EQ(GetOAuthStatusFromLocalState(account_id),
user_manager::User::OAUTH2_TOKEN_STATUS_INVALID);
}
diff --git a/chrome/browser/chromeos/login/supervised/supervised_user_test_base.cc b/chrome/browser/chromeos/login/supervised/supervised_user_test_base.cc
index 64bec8af0..f8e1a67 100644
--- a/chrome/browser/chromeos/login/supervised/supervised_user_test_base.cc
+++ b/chrome/browser/chromeos/login/supervised/supervised_user_test_base.cc
@@ -295,6 +295,7 @@ void SupervisedUserTestBase::StartFlowLoginAsManager() {
// Next button is now enabled.
JSExpect("!$('supervised-user-creation-next-button').disabled");
UserContext user_context(kTestManager);
+ user_context.SetGaiaID(GetGaiaIDForUserID(kTestManager));
user_context.SetKey(Key(kTestManagerPassword));
SetExpectedCredentials(user_context);
content::WindowedNotificationObserver login_observer(
diff --git a/chrome/browser/chromeos/policy/consumer_enrollment_handler_unittest.cc b/chrome/browser/chromeos/policy/consumer_enrollment_handler_unittest.cc
index 15ecd7e..70d20d2 100644
--- a/chrome/browser/chromeos/policy/consumer_enrollment_handler_unittest.cc
+++ b/chrome/browser/chromeos/policy/consumer_enrollment_handler_unittest.cc
@@ -4,8 +4,11 @@
#include "chrome/browser/chromeos/policy/consumer_enrollment_handler.h"
+#include <utility>
+
#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
@@ -16,6 +19,7 @@
#include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
#include "chrome/browser/chromeos/policy/fake_consumer_management_service.h"
#include "chrome/browser/chromeos/policy/fake_device_cloud_policy_initializer.h"
+#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
@@ -65,17 +69,21 @@ class ConsumerEnrollmentHandlerTest : public testing::Test {
void SetUp() override {
ASSERT_TRUE(testing_profile_manager_->SetUp());
- profile_ = testing_profile_manager_->CreateTestingProfile(kTestUser);
-
- // Set up FakeProfileOAuth2TokenService and issue a fake refresh token.
- ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
- profile_, &BuildAutoIssuingFakeProfileOAuth2TokenService);
- GetFakeProfileOAuth2TokenService()->
- IssueRefreshTokenForUser(kTestOwner, "fake_token");
+ TestingProfile::TestingFactories factories;
+ factories.push_back(
+ std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(),
+ BuildAutoIssuingFakeProfileOAuth2TokenService));
+ profile_ = testing_profile_manager_->CreateTestingProfile(
+ kTestUser, scoped_ptr<PrefServiceSyncable>(),
+ base::UTF8ToUTF16(kTestUser), 0, std::string(), factories);
// Set up the authenticated user name and ID.
- SigninManagerFactory::GetForProfile(profile_)->
- SetAuthenticatedUsername(kTestOwner);
+ SigninManagerFactory::GetForProfile(profile_)
+ ->SetAuthenticatedAccountInfo(kTestOwner, kTestOwner);
+
+ // Issue a fake refresh token.
+ GetFakeProfileOAuth2TokenService()->IssueRefreshTokenForUser(kTestOwner,
+ "fake_token");
}
FakeProfileOAuth2TokenService* GetFakeProfileOAuth2TokenService() {
diff --git a/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc b/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc
index f0cbfd2..9791ecd 100644
--- a/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc
+++ b/chrome/browser/devtools/device/webrtc/devtools_bridge_client_browsertest.cc
@@ -6,11 +6,20 @@
#include "chrome/browser/devtools/device/webrtc/devtools_bridge_client.h"
#include "chrome/browser/local_discovery/gcd_api_flow.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_signin_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "content/public/browser/web_ui_message_handler.h"
+namespace {
+
+const char kGaiaId[] = "stub-user@example.com";
+const char kUsername[] = "stub-user@example.com";
+
+} // namespace
+
class DevToolsBridgeClientBrowserTest::GCDApiFlowMock
: public local_discovery::GCDApiFlow {
public:
@@ -79,10 +88,14 @@ class DevToolsBridgeClientBrowserTest::DevToolsBridgeClientMock
void GoogleSigninSucceeded() {
// This username is checked on Chrome OS.
- const std::string username = "stub-user@example.com";
- test_->fake_signin_manager_->SetAuthenticatedUsername(username);
- identity_provider().GoogleSigninSucceeded("test_account", username,
- "testing");
+ const std::string account_id =
+ AccountTrackerServiceFactory::GetForProfile(
+ test_->browser()->profile())
+ ->PickAccountIdForAccount(kGaiaId, kUsername);
+ test_->fake_signin_manager_->SetAuthenticatedAccountInfo(kGaiaId,
+ kUsername);
+ identity_provider().GoogleSigninSucceeded(account_id, kUsername,
+ "password");
}
private:
@@ -109,8 +122,11 @@ class DevToolsBridgeClientBrowserTest::MessageHandler
void SignIn(const base::ListValue*) {
if (test_->client_mock_.get())
test_->client_mock_->GoogleSigninSucceeded();
- test_->fake_token_service_->UpdateCredentials("test_user@gmail.com",
- "token");
+ const std::string account_id =
+ AccountTrackerServiceFactory::GetForProfile(
+ test_->browser()->profile())->PickAccountIdForAccount(kGaiaId,
+ kUsername);
+ test_->fake_token_service_->UpdateCredentials(account_id, "token");
}
void GCDApiResponse(const base::ListValue* params) {
diff --git a/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc b/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc
index 7c31488..d85b6ad 100644
--- a/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc
+++ b/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc
@@ -200,7 +200,7 @@ class EPKPChallengeKeyTestBase : public BrowserWithTestWindowTest {
// user in the SigninManager class.
virtual void SetAuthenticatedUser() {
SigninManagerFactory::GetForProfile(browser()->profile())->
- SetAuthenticatedUsername("test@google.com");
+ SetAuthenticatedAccountInfo("12345", "test@google.com");
}
NiceMock<chromeos::MockCryptohomeClient> mock_cryptohome_client_;
@@ -517,7 +517,7 @@ class EPKPChallengeMachineKeyUnmanagedUserTest
protected:
void SetAuthenticatedUser() override {
SigninManagerFactory::GetForProfile(browser()->profile())->
- SetAuthenticatedUsername("test@chromium.com");
+ SetAuthenticatedAccountInfo("12345", "test@chromium.com");
}
};
@@ -530,7 +530,7 @@ class EPKPChallengeUserKeyUnmanagedUserTest : public EPKPChallengeUserKeyTest {
protected:
void SetAuthenticatedUser() override {
SigninManagerFactory::GetForProfile(browser()->profile())->
- SetAuthenticatedUsername("test@chromium.com");
+ SetAuthenticatedAccountInfo("12345", "test@chromium.com");
}
};
diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc
index 5ff783d..1d4ba1e 100644
--- a/chrome/browser/extensions/api/identity/identity_apitest.cc
+++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -573,20 +573,22 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest {
}
protected:
- void SignIn(const std::string account_key) {
-#if defined(OS_CHROMEOS)
- signin_manager_->SetAuthenticatedUsername(account_key);
-#else
- signin_manager_->SignIn(account_key, "password");
-#endif
- token_service_->IssueRefreshTokenForUser(account_key, "refresh_token");
+ void SignIn(const std::string& account_key) {
+ SignIn(account_key, account_key);
}
- void SignIn(const std::string& account_key, const std::string& gaia) {
+ void SignIn(const std::string& email, const std::string& gaia) {
AccountTrackerService* account_tracker =
AccountTrackerServiceFactory::GetForProfile(profile());
- account_tracker->SeedAccountInfo(gaia, account_key);
- SignIn(account_key);
+ std::string account_id =
+ account_tracker->SeedAccountInfo(gaia, email);
+
+#if defined(OS_CHROMEOS)
+ signin_manager_->SetAuthenticatedAccountInfo(gaia, email);
+#else
+ signin_manager_->SignIn(gaia, email, "password");
+#endif
+ token_service_->IssueRefreshTokenForUser(account_id, "refresh_token");
}
FakeSigninManagerForTesting* signin_manager_;
diff --git a/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc b/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
index 9c1b39c..5c79260 100644
--- a/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
+++ b/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
@@ -22,6 +22,7 @@ namespace extensions {
namespace {
+const char kTestGaiaId[] = "gaia-id-testuser@gmail.com";
const char kAttemptClickAuthMessage[] = "attemptClickAuth";
const char kTestExtensionId[] = "lkegkdgachcnekllcdfkijonogckdnjo";
const char kTestUser[] = "testuser@gmail.com";
@@ -49,7 +50,7 @@ class ScreenlockPrivateApiTest : public ExtensionApiTest,
void SetUpOnMainThread() override {
SigninManagerFactory::GetForProfile(profile())
- ->SetAuthenticatedUsername(kTestUser);
+ ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
ProfileInfoCache& info_cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
size_t index = info_cache.GetIndexOfProfileWithPath(profile()->GetPath());
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc
index 992a817..708bb4a 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc
@@ -28,7 +28,7 @@ KeyedService* CreateProfileSyncServiceMock(content::BrowserContext* profile) {
TEST(SignedInDevicesManager, UpdateListener) {
scoped_ptr<TestingProfile> profile(new TestingProfile());
SigninManagerFactory::GetForProfile(profile.get())->
- SetAuthenticatedUsername("foo");
+ SetAuthenticatedAccountInfo("gaia_id", "foo");
ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(
profile.get(), CreateProfileSyncServiceMock);
SignedInDevicesManager manager(profile.get());
diff --git a/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc b/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc
index bafa06b..d3e3c42 100644
--- a/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc
+++ b/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc
@@ -135,8 +135,8 @@ class SyncFileSystemTest : public extensions::PlatformAppBrowserTest,
}
void SignIn() {
- fake_signin_manager_->SetAuthenticatedUsername("tester");
- sync_engine()->GoogleSigninSucceeded("test_account", "tester", "testing");
+ fake_signin_manager_->SetAuthenticatedAccountInfo("12345", "tester");
+ sync_engine()->GoogleSigninSucceeded("12345", "tester", "password");
}
void SetSyncEnabled(bool enabled) {
diff --git a/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc b/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc
index d399b10..809e2e9 100644
--- a/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc
+++ b/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc
@@ -157,7 +157,8 @@ TEST_F(ExternalProviderImplChromeOSTest, PolicyDisabled) {
new ProfileManagerWithoutInit(temp_dir().path()));
SigninManagerBase* signin =
SigninManagerFactory::GetForProfile(profile_.get());
- signin->SetAuthenticatedUsername("test_user@gmail.com");
+ signin->SetAuthenticatedAccountInfo("gaia-id-test_user@gmail.com",
+ "test_user@gmail.com");
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())
->UpdateCredentials("test_user@gmail.com", "oauth2_login_token");
@@ -184,7 +185,8 @@ TEST_F(ExternalProviderImplChromeOSTest, PriorityCompleted) {
// User is logged in.
SigninManagerBase* signin =
SigninManagerFactory::GetForProfile(profile_.get());
- signin->SetAuthenticatedUsername("test_user@gmail.com");
+ signin->SetAuthenticatedAccountInfo("gaia-id-test_user@gmail.com",
+ "test_user@gmail.com");
// App sync will wait for priority sync to complete.
service_->CheckForExternalUpdates();
diff --git a/chrome/browser/policy/cloud/cloud_policy_browsertest.cc b/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
index 96d9e07..ebce294 100644
--- a/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
@@ -84,6 +84,12 @@ KeyedService* BuildFakeProfileInvalidationProvider(
new invalidation::FakeInvalidationService));
}
+#if !defined(OS_CHROMEOS)
+const char* GetTestGaiaId() {
+ return "gaia-id-user@example.com";
+}
+#endif
+
const char* GetTestUser() {
#if defined(OS_CHROMEOS)
return chromeos::login::kStubUser;
@@ -246,7 +252,7 @@ class CloudPolicyTest : public InProcessBrowserTest,
SigninManager* signin_manager =
SigninManagerFactory::GetForProfile(browser()->profile());
ASSERT_TRUE(signin_manager);
- signin_manager->SetAuthenticatedUsername(GetTestUser());
+ signin_manager->SetAuthenticatedAccountInfo(GetTestGaiaId(), GetTestUser());
UserCloudPolicyManager* policy_manager =
UserCloudPolicyManagerFactory::GetForBrowserContext(
diff --git a/chrome/browser/policy/cloud/cloud_policy_manager_browsertest.cc b/chrome/browser/policy/cloud/cloud_policy_manager_browsertest.cc
index d8699bf..9c63d1a 100644
--- a/chrome/browser/policy/cloud/cloud_policy_manager_browsertest.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_manager_browsertest.cc
@@ -73,7 +73,7 @@ class CloudPolicyManagerTest : public InProcessBrowserTest {
SigninManager* signin_manager =
SigninManagerFactory::GetForProfile(browser()->profile());
ASSERT_TRUE(signin_manager);
- signin_manager->SetAuthenticatedUsername("user@example.com");
+ signin_manager->SetAuthenticatedAccountInfo("12345", "user@example.com");
ASSERT_TRUE(policy_manager());
policy_manager()->Connect(
diff --git a/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc b/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc
index c909b22..d1adf4e 100644
--- a/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc
+++ b/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc
@@ -182,7 +182,7 @@ class ComponentCloudPolicyTest : public ExtensionBrowserTest {
SigninManager* signin_manager =
SigninManagerFactory::GetForProfile(browser()->profile());
ASSERT_TRUE(signin_manager);
- signin_manager->SetAuthenticatedUsername("user@example.com");
+ signin_manager->SetAuthenticatedAccountInfo("12345", "user@example.com");
UserCloudPolicyManager* policy_manager =
UserCloudPolicyManagerFactory::GetForBrowserContext(
diff --git a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
index 9bd3908..4cc4e8e 100644
--- a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
+++ b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
@@ -33,6 +33,7 @@
#include "components/policy/core/common/cloud/mock_user_cloud_policy_store.h"
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#include "components/policy/core/common/schema_registry.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/notification_details.h"
@@ -65,6 +66,7 @@ namespace policy {
namespace {
+const char kTestGaiaId[] = "gaia-id-testuser@test.com";
const char kTestUser[] = "testuser@test.com";
#if !defined(OS_ANDROID)
@@ -134,8 +136,10 @@ class UserPolicySigninServiceTest : public testing::Test {
// a valid login token, while on other platforms, the login refresh token
// is specified directly.
#if defined(OS_ANDROID)
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth2_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ AccountTrackerService::PickAccountIdForAccount(
+ profile_.get()->GetPrefs(), kTestGaiaId, kTestUser),
+ "oauth2_login_refresh_token");
#endif
service->RegisterForPolicy(
kTestUser,
@@ -390,7 +394,7 @@ class UserPolicySigninServiceSignedInTest : public UserPolicySigninServiceTest {
// Set the user as signed in.
SigninManagerFactory::GetForProfile(profile_.get())->
- SetAuthenticatedUsername(kTestUser);
+ SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
// Let the SigninService know that the profile has been created.
content::NotificationService::current()->Notify(
@@ -425,8 +429,10 @@ TEST_F(UserPolicySigninServiceSignedInTest, InitWhileSignedIn) {
ASSERT_FALSE(IsRequestActive());
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// Client registration should be in progress since we now have an oauth token.
EXPECT_EQ(mock_store_->signin_username_, kTestUser);
@@ -444,8 +450,10 @@ TEST_F(UserPolicySigninServiceSignedInTest, InitWhileSignedInOAuthError) {
ASSERT_FALSE(IsRequestActive());
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// Client registration should be in progress since we now have an oauth token.
ASSERT_TRUE(IsRequestActive());
@@ -463,15 +471,17 @@ TEST_F(UserPolicySigninServiceTest, SignInAfterInit) {
ASSERT_FALSE(manager_->core()->service());
// Now sign in the user.
- SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername(
- kTestUser);
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
// Complete initialization of the store.
mock_store_->NotifyStoreLoaded();
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// UserCloudPolicyManager should be initialized.
EXPECT_EQ(mock_store_->signin_username_, kTestUser);
@@ -487,15 +497,18 @@ TEST_F(UserPolicySigninServiceTest, SignInWithNonEnterpriseUser) {
ASSERT_FALSE(manager_->core()->service());
// Now sign in a non-enterprise user (blacklisted gmail.com domain).
- SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername(
- "non_enterprise_user@gmail.com");
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->SetAuthenticatedAccountInfo("gaia-id-non_enterprise_user@gmail.com",
+ "non_enterprise_user@gmail.com");
// Complete initialization of the store.
mock_store_->NotifyStoreLoaded();
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// UserCloudPolicyManager should not be initialized and there should be no
// DMToken request active.
@@ -509,12 +522,14 @@ TEST_F(UserPolicySigninServiceTest, UnregisteredClient) {
ASSERT_FALSE(manager_->core()->service());
// Now sign in the user.
- SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername(
- kTestUser);
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// UserCloudPolicyManager should be initialized.
EXPECT_EQ(mock_store_->signin_username_, kTestUser);
@@ -537,12 +552,14 @@ TEST_F(UserPolicySigninServiceTest, RegisteredClient) {
ASSERT_FALSE(manager_->core()->service());
// Now sign in the user.
- SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername(
- kTestUser);
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// UserCloudPolicyManager should be initialized.
EXPECT_EQ(mock_store_->signin_username_, kTestUser);
diff --git a/chrome/browser/prefs/chrome_pref_service_factory.cc b/chrome/browser/prefs/chrome_pref_service_factory.cc
index 3581fe1..a22f002 100644
--- a/chrome/browser/prefs/chrome_pref_service_factory.cc
+++ b/chrome/browser/prefs/chrome_pref_service_factory.cc
@@ -221,6 +221,8 @@ const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = {
PrefHashFilter::VALUE_IMPERSONAL
},
#endif
+ // This pref is deprecated and will be removed a few releases after M43.
+ // kGoogleServicesAccountId replaces it.
{
21, prefs::kGoogleServicesUsername,
PrefHashFilter::ENFORCE_ON_LOAD,
@@ -235,6 +237,12 @@ const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = {
PrefHashFilter::VALUE_IMPERSONAL
},
#endif
+ {
+ 23, prefs::kGoogleServicesAccountId,
+ PrefHashFilter::ENFORCE_ON_LOAD,
+ PrefHashFilter::TRACKING_STRATEGY_ATOMIC,
+ PrefHashFilter::VALUE_PERSONAL
+ },
// See note at top, new items added here also need to be added to
// histograms.xml's TrackedPreference enum.
};
diff --git a/chrome/browser/profiles/gaia_info_update_service_unittest.cc b/chrome/browser/profiles/gaia_info_update_service_unittest.cc
index 4a89e37..64c1a85 100644
--- a/chrome/browser/profiles/gaia_info_update_service_unittest.cc
+++ b/chrome/browser/profiles/gaia_info_update_service_unittest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_info_cache_unittest.h"
#include "chrome/browser/profiles/profiles_state.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/test_signin_client_builder.h"
@@ -19,6 +20,7 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_unittest_util.h"
@@ -280,7 +282,7 @@ TEST_F(GAIAInfoUpdateServiceTest, ScheduleUpdate) {
TEST_F(GAIAInfoUpdateServiceTest, LogOut) {
SigninManager* signin_manager =
SigninManagerFactory::GetForProfile(profile());
- signin_manager->SetAuthenticatedUsername("pat@example.com");
+ signin_manager->SetAuthenticatedAccountInfo("gaia_id", "pat@example.com");
base::string16 gaia_name = base::UTF8ToUTF16("Pat Foo");
GetCache()->SetGAIANameOfProfileAtIndex(0, gaia_name);
gfx::Image gaia_picture = gfx::test::CreateImage(256,256);
@@ -303,9 +305,12 @@ TEST_F(GAIAInfoUpdateServiceTest, LogOut) {
TEST_F(GAIAInfoUpdateServiceTest, LogIn) {
// Log in.
EXPECT_CALL(*service(), Update());
+ std::string account_id =
+ AccountTrackerServiceFactory::GetForProfile(profile())
+ ->SeedAccountInfo("gaia_id", "pat@example.com");
SigninManager* signin_manager =
SigninManagerFactory::GetForProfile(profile());
- signin_manager->OnExternalSigninCompleted("pat@example.com");
+ signin_manager->OnExternalSigninCompleted(account_id);
}
#endif
diff --git a/chrome/browser/services/gcm/fake_signin_manager.cc b/chrome/browser/services/gcm/fake_signin_manager.cc
index 64f7ccc..563ee4f 100644
--- a/chrome/browser/services/gcm/fake_signin_manager.cc
+++ b/chrome/browser/services/gcm/fake_signin_manager.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "components/keyed_service/core/keyed_service.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/common/signin_pref_names.h"
#include "content/public/browser/browser_context.h"
@@ -23,7 +24,8 @@ namespace gcm {
FakeSigninManager::FakeSigninManager(Profile* profile)
#if defined(OS_CHROMEOS)
: SigninManagerBase(
- ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)),
+ ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
+ AccountTrackerServiceFactory::GetForProfile(profile)),
#else
: SigninManager(
ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
@@ -38,19 +40,20 @@ FakeSigninManager::FakeSigninManager(Profile* profile)
FakeSigninManager::~FakeSigninManager() {
}
-void FakeSigninManager::SignIn(const std::string& username) {
- SetAuthenticatedUsername(username);
+void FakeSigninManager::SignIn(const std::string& account_id) {
+ SetAuthenticatedAccountId(account_id);
FOR_EACH_OBSERVER(SigninManagerBase::Observer,
observer_list_,
- GoogleSigninSucceeded(username, username, std::string()));
+ GoogleSigninSucceeded(account_id, account_id,
+ std::string()));
}
void FakeSigninManager::SignOut(
signin_metrics::ProfileSignout signout_source_metric) {
const std::string account_id = GetAuthenticatedAccountId();
const std::string username = GetAuthenticatedUsername();
- ClearAuthenticatedUsername();
- profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
+ clear_authenticated_user();
+ profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesAccountId);
FOR_EACH_OBSERVER(SigninManagerBase::Observer,
observer_list_,
GoogleSignedOut(account_id, username));
diff --git a/chrome/browser/signin/account_reconcilor_unittest.cc b/chrome/browser/signin/account_reconcilor_unittest.cc
index 43f97c4..7d6e9c5 100644
--- a/chrome/browser/signin/account_reconcilor_unittest.cc
+++ b/chrome/browser/signin/account_reconcilor_unittest.cc
@@ -11,6 +11,7 @@
#include "build/build_config.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/signin/account_reconcilor_factory.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
@@ -23,6 +24,7 @@
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/signin/core/browser/account_reconcilor.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/browser/signin_metrics.h"
@@ -38,8 +40,6 @@
namespace {
-const char kTestEmail[] = "user@gmail.com";
-
class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> {
public:
static KeyedService* Build(content::BrowserContext* context);
@@ -87,6 +87,7 @@ class AccountReconcilorTest : public ::testing::TestWithParam<bool> {
FakeSigninManagerForTesting* signin_manager() { return signin_manager_; }
FakeProfileOAuth2TokenService* token_service() { return token_service_; }
TestSigninClient* test_signin_client() { return test_signin_client_; }
+ AccountTrackerService* account_tracker() { return account_tracker_; }
base::HistogramTester* histogram_tester() { return &histogram_tester_; }
void SetFakeResponse(const std::string& url,
@@ -98,6 +99,12 @@ class AccountReconcilorTest : public ::testing::TestWithParam<bool> {
MockAccountReconcilor* GetMockReconcilor();
+ std::string ConnectProfileToAccount(const std::string& gaia_id,
+ const std::string& username);
+
+ std::string PickAccountIdForAccount(const std::string& gaia_id,
+ const std::string& username);
+
void SimulateAddAccountToCookieCompleted(
GaiaCookieManagerService::Observer* observer,
const std::string& account_id,
@@ -118,6 +125,7 @@ class AccountReconcilorTest : public ::testing::TestWithParam<bool> {
FakeSigninManagerForTesting* signin_manager_;
FakeProfileOAuth2TokenService* token_service_;
TestSigninClient* test_signin_client_;
+ AccountTrackerService* account_tracker_;
MockAccountReconcilor* mock_reconcilor_;
net::FakeURLFetcherFactory url_fetcher_factory_;
scoped_ptr<TestingProfileManager> testing_profile_manager_;
@@ -173,17 +181,20 @@ void AccountReconcilorTest::SetUp() {
base::UTF8ToUTF16("name"), 0, std::string(),
factories);
- signin_manager_ =
- static_cast<FakeSigninManagerForTesting*>(
- SigninManagerFactory::GetForProfile(profile()));
+ test_signin_client_ =
+ static_cast<TestSigninClient*>(
+ ChromeSigninClientFactory::GetForProfile(profile()));
token_service_ =
static_cast<FakeProfileOAuth2TokenService*>(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile()));
- test_signin_client_ =
- static_cast<TestSigninClient*>(
- ChromeSigninClientFactory::GetForProfile(profile()));
+ account_tracker_ =
+ AccountTrackerServiceFactory::GetForProfile(profile());
+
+ signin_manager_ =
+ static_cast<FakeSigninManagerForTesting*>(
+ SigninManagerFactory::GetForProfile(profile()));
}
MockAccountReconcilor* AccountReconcilorTest::GetMockReconcilor() {
@@ -196,6 +207,24 @@ MockAccountReconcilor* AccountReconcilorTest::GetMockReconcilor() {
return mock_reconcilor_;
}
+std::string AccountReconcilorTest::ConnectProfileToAccount(
+ const std::string& gaia_id,
+ const std::string& username) {
+ const std::string account_id = PickAccountIdForAccount(gaia_id, username);
+#if !defined(OS_CHROMEOS)
+ signin_manager()->set_password("password");
+#endif
+ signin_manager()->SetAuthenticatedAccountInfo(gaia_id, username);
+ token_service()->UpdateCredentials(account_id, "refresh_token");
+ return account_id;
+}
+
+std::string AccountReconcilorTest::PickAccountIdForAccount(
+ const std::string& gaia_id,
+ const std::string& username) {
+ return account_tracker()->PickAccountIdForAccount(gaia_id, username);
+}
+
void AccountReconcilorTest::SimulateAddAccountToCookieCompleted(
GaiaCookieManagerService::Observer* observer,
const std::string& account_id,
@@ -231,8 +260,8 @@ TEST_F(AccountReconcilorTest, SigninManagerRegistration) {
ASSERT_TRUE(reconcilor);
ASSERT_FALSE(reconcilor->IsRegisteredWithTokenService());
- signin_manager()->set_password("password");
- signin_manager()->OnExternalSigninCompleted(kTestEmail);
+ account_tracker()->SeedAccountInfo("12345", "user@gmail.com");
+ signin_manager()->SignIn("12345", "user@gmail.com", "password");
ASSERT_TRUE(reconcilor->IsRegisteredWithTokenService());
EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction());
@@ -246,8 +275,9 @@ TEST_F(AccountReconcilorTest, SigninManagerRegistration) {
// method with an empty implementation. On MacOS, the normal implementation
// causes the try_bots to time out.
TEST_F(AccountReconcilorTest, Reauth) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- signin_manager()->set_password("password");
+ const std::string email = "user@gmail.com";
+ const std::string account_id =
+ ConnectProfileToAccount("12345", email);
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
@@ -255,14 +285,14 @@ TEST_F(AccountReconcilorTest, Reauth) {
ASSERT_TRUE(reconcilor->IsRegisteredWithTokenService());
// Simulate reauth. The state of the reconcilor should not change.
- signin_manager()->OnExternalSigninCompleted(kTestEmail);
+ signin_manager()->OnExternalSigninCompleted(email);
ASSERT_TRUE(reconcilor->IsRegisteredWithTokenService());
}
#endif // !defined(OS_CHROMEOS)
TEST_F(AccountReconcilorTest, ProfileAlreadyConnected) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
+ ConnectProfileToAccount("12345", "user@gmail.com");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
@@ -271,9 +301,10 @@ TEST_F(AccountReconcilorTest, ProfileAlreadyConnected) {
}
TEST_F(AccountReconcilorTest, GetAccountsFromCookieSuccess) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- token_service()->UpdateCredentials(kTestEmail, "refresh_token");
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(kTestEmail));
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
+
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
ASSERT_TRUE(reconcilor);
@@ -290,12 +321,11 @@ TEST_F(AccountReconcilorTest, GetAccountsFromCookieSuccess) {
const std::vector<std::pair<std::string, bool> >& accounts =
reconcilor->GetGaiaAccountsForTesting();
ASSERT_EQ(1u, accounts.size());
- ASSERT_EQ("user@gmail.com", accounts[0].first);
+ ASSERT_EQ(account_id, accounts[0].first);
}
TEST_F(AccountReconcilorTest, GetAccountsFromCookieFailure) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- token_service()->UpdateCredentials(kTestEmail, "refresh_token");
+ ConnectProfileToAccount("12345", "user@gmail.com");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
ASSERT_TRUE(reconcilor);
@@ -311,8 +341,8 @@ TEST_F(AccountReconcilorTest, GetAccountsFromCookieFailure) {
}
TEST_P(AccountReconcilorTest, StartReconcileNoop) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- token_service()->UpdateCredentials(kTestEmail, "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
@@ -338,8 +368,9 @@ TEST_P(AccountReconcilorTest, StartReconcileNoop) {
}
TEST_P(AccountReconcilorTest, StartReconcileCookiesDisabled) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- token_service()->UpdateCredentials(kTestEmail, "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ token_service()->UpdateCredentials(account_id, "refresh_token");
test_signin_client()->set_are_signin_cookies_allowed(false);
AccountReconcilor* reconcilor =
@@ -355,8 +386,9 @@ TEST_P(AccountReconcilorTest, StartReconcileCookiesDisabled) {
}
TEST_P(AccountReconcilorTest, StartReconcileContentSettings) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- token_service()->UpdateCredentials(kTestEmail, "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ token_service()->UpdateCredentials(account_id, "refresh_token");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
@@ -374,8 +406,9 @@ TEST_P(AccountReconcilorTest, StartReconcileContentSettings) {
}
TEST_P(AccountReconcilorTest, StartReconcileContentSettingsGaiaUrl) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- token_service()->UpdateCredentials(kTestEmail, "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ token_service()->UpdateCredentials(account_id, "refresh_token");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
@@ -388,8 +421,9 @@ TEST_P(AccountReconcilorTest, StartReconcileContentSettingsGaiaUrl) {
}
TEST_P(AccountReconcilorTest, StartReconcileContentSettingsNonGaiaUrl) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- token_service()->UpdateCredentials(kTestEmail, "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ token_service()->UpdateCredentials(account_id, "refresh_token");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
@@ -402,8 +436,9 @@ TEST_P(AccountReconcilorTest, StartReconcileContentSettingsNonGaiaUrl) {
}
TEST_P(AccountReconcilorTest, StartReconcileContentSettingsInvalidPattern) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- token_service()->UpdateCredentials(kTestEmail, "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ token_service()->UpdateCredentials(account_id, "refresh_token");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
@@ -417,7 +452,7 @@ TEST_P(AccountReconcilorTest, StartReconcileContentSettingsInvalidPattern) {
ASSERT_TRUE(reconcilor->is_reconcile_started_);
}
-// This is test is needed until chrome changes to use gaia obfuscated id.
+// This test is needed until chrome changes to use gaia obfuscated id.
// The signin manager and token service use the gaia "email" property, which
// preserves dots in usernames and preserves case. gaia::ParseListAccountsData()
// however uses gaia "displayEmail" which does not preserve case, and then
@@ -426,9 +461,13 @@ TEST_P(AccountReconcilorTest, StartReconcileContentSettingsInvalidPattern) {
// token service, will be considered the same as "dots@gmail.com" as returned
// by gaia::ParseListAccountsData().
TEST_P(AccountReconcilorTest, StartReconcileNoopWithDots) {
- signin_manager()->SetAuthenticatedUsername("Dot.S@gmail.com");
- token_service()->UpdateCredentials("Dot.S@gmail.com", "refresh_token");
+ if (account_tracker()->GetMigrationState() !=
+ AccountTrackerService::MIGRATION_NOT_STARTED) {
+ return;
+ }
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "Dot.S@gmail.com");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
ASSERT_TRUE(reconcilor);
@@ -450,9 +489,11 @@ TEST_P(AccountReconcilorTest, StartReconcileNoopWithDots) {
}
TEST_P(AccountReconcilorTest, StartReconcileNoopMultiple) {
- signin_manager()->SetAuthenticatedUsername("user@gmail.com");
- token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
- token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ const std::string account_id2 =
+ PickAccountIdForAccount("67890", "other@gmail.com");
+ token_service()->UpdateCredentials(account_id2, "refresh_token");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
@@ -477,11 +518,15 @@ TEST_P(AccountReconcilorTest, StartReconcileNoopMultiple) {
}
TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) {
- signin_manager()->SetAuthenticatedUsername("user@gmail.com");
- token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
- token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ token_service()->UpdateCredentials(account_id, "refresh_token");
+
+ const std::string account_id2 =
+ PickAccountIdForAccount("67890", "other@gmail.com");
+ token_service()->UpdateCredentials(account_id2, "refresh_token");
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com"));
+ EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id2));
SetFakeResponse(list_accounts_url().spec(),
"[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
@@ -492,7 +537,7 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) {
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(reconcilor->is_reconcile_started_);
- SimulateAddAccountToCookieCompleted(reconcilor, "other@gmail.com",
+ SimulateAddAccountToCookieCompleted(reconcilor, account_id2,
GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
@@ -507,11 +552,12 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) {
}
TEST_P(AccountReconcilorTest, StartReconcileRemoveFromCookie) {
- signin_manager()->SetAuthenticatedUsername("user@gmail.com");
- token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ token_service()->UpdateCredentials(account_id, "refresh_token");
EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction());
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com"));
+ EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
SetFakeResponse(list_accounts_url().spec(),
"[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], "
@@ -538,12 +584,17 @@ TEST_P(AccountReconcilorTest, StartReconcileRemoveFromCookie) {
}
TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
- signin_manager()->SetAuthenticatedUsername("user@gmail.com");
- token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
- token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ const std::string account_id2 =
+ PickAccountIdForAccount("67890", "other@gmail.com");
+ const std::string account_id3 =
+ PickAccountIdForAccount("34567", "third@gmail.com");
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com"));
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("third@gmail.com"));
+ token_service()->UpdateCredentials(account_id2, "refresh_token");
+
+ EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id2));
+ EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id3));
SetFakeResponse(
list_accounts_url().spec(),
@@ -557,7 +608,7 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(reconcilor->is_reconcile_started_);
SimulateAddAccountToCookieCompleted(
- reconcilor, "other@gmail.com", GoogleServiceAuthError::AuthErrorNone());
+ reconcilor, account_id2, GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
histogram_tester()->ExpectUniqueSample(
@@ -578,13 +629,12 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
// This will cause the reconcilor to fire.
- token_service()->UpdateCredentials("third@gmail.com", "refresh_token");
-
+ token_service()->UpdateCredentials(account_id3, "refresh_token");
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(reconcilor->is_reconcile_started_);
SimulateAddAccountToCookieCompleted(
- reconcilor, "third@gmail.com", GoogleServiceAuthError::AuthErrorNone());
+ reconcilor, account_id3, GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
histogram_tester()->ExpectUniqueSample(
@@ -606,13 +656,16 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
}
TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) {
- signin_manager()->SetAuthenticatedUsername("user@gmail.com");
- token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
- token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ const std::string account_id2 =
+ PickAccountIdForAccount("67890", "other@gmail.com");
+
+ token_service()->UpdateCredentials(account_id2, "refresh_token");
EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction());
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com"));
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com"));
+ EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
+ EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id2));
SetFakeResponse(list_accounts_url().spec(),
"[\"f\", [[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1], "
@@ -624,10 +677,10 @@ TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) {
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(reconcilor->is_reconcile_started_);
- SimulateAddAccountToCookieCompleted(reconcilor, "other@gmail.com",
+ SimulateAddAccountToCookieCompleted(reconcilor, account_id2,
GoogleServiceAuthError::AuthErrorNone());
ASSERT_TRUE(reconcilor->is_reconcile_started_);
- SimulateAddAccountToCookieCompleted(reconcilor, "user@gmail.com",
+ SimulateAddAccountToCookieCompleted(reconcilor, account_id,
GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
@@ -642,8 +695,8 @@ TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) {
}
TEST_P(AccountReconcilorTest, StartReconcileOnlyOnce) {
- signin_manager()->SetAuthenticatedUsername(kTestEmail);
- token_service()->UpdateCredentials(kTestEmail, "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
@@ -662,11 +715,13 @@ TEST_P(AccountReconcilorTest, StartReconcileOnlyOnce) {
}
TEST_P(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) {
- signin_manager()->SetAuthenticatedUsername("user@gmail.com");
- token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
- token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
+ const std::string account_id2 =
+ PickAccountIdForAccount("67890", "other@gmail.com");
+ token_service()->UpdateCredentials(account_id2, "refresh_token");
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com"));
+ EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
SetFakeResponse(list_accounts_url().spec(),
"[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 0],"
@@ -682,16 +737,16 @@ TEST_P(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) {
ASSERT_TRUE(reconcilor->is_reconcile_started_);
base::RunLoop().RunUntilIdle();
- SimulateAddAccountToCookieCompleted(reconcilor, "user@gmail.com",
+ SimulateAddAccountToCookieCompleted(reconcilor, account_id,
GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
}
TEST_F(AccountReconcilorTest, AddAccountToCookieCompletedWithBogusAccount) {
- signin_manager()->SetAuthenticatedUsername("user@gmail.com");
- token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
+ const std::string account_id =
+ ConnectProfileToAccount("12345", "user@gmail.com");
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com"));
+ EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
SetFakeResponse(list_accounts_url().spec(),
"[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 0]]]",
@@ -708,11 +763,11 @@ TEST_F(AccountReconcilorTest, AddAccountToCookieCompletedWithBogusAccount) {
base::RunLoop().RunUntilIdle();
// If an unknown account id is sent, it should not upset the state.
- SimulateAddAccountToCookieCompleted(reconcilor, "bogus@gmail.com",
+ SimulateAddAccountToCookieCompleted(reconcilor, "bogus_account_id",
GoogleServiceAuthError::AuthErrorNone());
ASSERT_TRUE(reconcilor->is_reconcile_started_);
- SimulateAddAccountToCookieCompleted(reconcilor, "user@gmail.com",
+ SimulateAddAccountToCookieCompleted(reconcilor, account_id,
GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
}
diff --git a/chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc b/chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc
index 6651564..c5b3418 100644
--- a/chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc
+++ b/chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc
@@ -280,7 +280,7 @@ class EasyUnlockServiceTest : public testing::Test {
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfile(profile->get());
- signin_manager->SetAuthenticatedUsername(user_id);
+ signin_manager->SetAuthenticatedAccountInfo(user_id, user_id);
}
protected:
diff --git a/chrome/browser/signin/fake_signin_manager.cc b/chrome/browser/signin/fake_signin_manager.cc
index 8314079..6cc2902 100644
--- a/chrome/browser/signin/fake_signin_manager.cc
+++ b/chrome/browser/signin/fake_signin_manager.cc
@@ -14,10 +14,13 @@
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/global_error/global_error_service.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
+#include "chrome/common/pref_names.h"
+#include "components/signin/core/browser/account_tracker_service.h"
FakeSigninManagerBase::FakeSigninManagerBase(Profile* profile)
: SigninManagerBase(
- ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)) {}
+ ChromeSigninClientFactory::GetForProfile(profile),
+ AccountTrackerServiceFactory::GetForProfile(profile)) {}
FakeSigninManagerBase::~FakeSigninManagerBase() {
}
@@ -41,7 +44,7 @@ KeyedService* FakeSigninManagerBase::Build(content::BrowserContext* context) {
FakeSigninManager::FakeSigninManager(Profile* profile)
: SigninManager(
- ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
+ ChromeSigninClientFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
AccountTrackerServiceFactory::GetForProfile(profile),
GaiaCookieManagerServiceFactory::GetForProfile(profile)) {}
@@ -51,30 +54,36 @@ FakeSigninManager::~FakeSigninManager() {
void FakeSigninManager::StartSignInWithRefreshToken(
const std::string& refresh_token,
+ const std::string& gaia_id,
const std::string& username,
const std::string& password,
const OAuthTokenFetchedCallback& oauth_fetched_callback) {
- set_auth_in_progress(username);
+ set_auth_in_progress(
+ account_tracker_service()->SeedAccountInfo(gaia_id, username));
set_password(password);
+ username_ = username;
+
if (!oauth_fetched_callback.is_null())
oauth_fetched_callback.Run(refresh_token);
}
void FakeSigninManager::CompletePendingSignin() {
- SetAuthenticatedUsername(GetUsernameForAuthInProgress());
+ SetAuthenticatedAccountId(GetAccountIdForAuthInProgress());
set_auth_in_progress(std::string());
FOR_EACH_OBSERVER(SigninManagerBase::Observer,
observer_list_,
- GoogleSigninSucceeded(authenticated_username_,
- authenticated_username_,
+ GoogleSigninSucceeded(authenticated_account_id_,
+ username_,
password_));
}
-void FakeSigninManager::SignIn(const std::string& username,
+void FakeSigninManager::SignIn(const std::string& gaia_id,
+ const std::string& username,
const std::string& password) {
StartSignInWithRefreshToken(
- std::string(), username, password, OAuthTokenFetchedCallback());
+ std::string(), gaia_id, username, password,
+ OAuthTokenFetchedCallback());
CompletePendingSignin();
}
@@ -92,7 +101,7 @@ void FakeSigninManager::SignOut(
set_password(std::string());
const std::string account_id = GetAuthenticatedAccountId();
const std::string username = GetAuthenticatedUsername();
- ClearAuthenticatedUsername();
+ authenticated_account_id_.clear();
FOR_EACH_OBSERVER(SigninManagerBase::Observer, observer_list_,
GoogleSignedOut(account_id, username));
diff --git a/chrome/browser/signin/fake_signin_manager.h b/chrome/browser/signin/fake_signin_manager.h
index 8e91531..24e59c4 100644
--- a/chrome/browser/signin/fake_signin_manager.h
+++ b/chrome/browser/signin/fake_signin_manager.h
@@ -44,18 +44,21 @@ class FakeSigninManager : public SigninManager {
explicit FakeSigninManager(Profile* profile);
~FakeSigninManager() override;
- void set_auth_in_progress(const std::string& username) {
- possibly_invalid_username_ = username;
+ void set_auth_in_progress(const std::string& account_id) {
+ possibly_invalid_account_id_ = account_id;
}
void set_password(const std::string& password) { password_ = password; }
- void SignIn(const std::string& username, const std::string& password);
+ void SignIn(const std::string& account_id,
+ const std::string& username,
+ const std::string& password);
void FailSignin(const GoogleServiceAuthError& error);
void StartSignInWithRefreshToken(
const std::string& refresh_token,
+ const std::string& gaia_id,
const std::string& username,
const std::string& password,
const OAuthTokenFetchedCallback& oauth_fetched_callback) override;
@@ -63,6 +66,9 @@ class FakeSigninManager : public SigninManager {
void SignOut(signin_metrics::ProfileSignout signout_source_metric) override;
void CompletePendingSignin() override;
+
+ // Username specified in StartSignInWithRefreshToken() call.
+ std::string username_;
};
#endif // !defined (OS_CHROMEOS)
diff --git a/chrome/browser/signin/signin_global_error_unittest.cc b/chrome/browser/signin/signin_global_error_unittest.cc
index 0b16dcf8..c9416dc 100644
--- a/chrome/browser/signin/signin_global_error_unittest.cc
+++ b/chrome/browser/signin/signin_global_error_unittest.cc
@@ -30,7 +30,7 @@
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
-static const char kTestAccountId[] = "testuser@test.com";
+static const char kTestAccountId[] = "id-testuser@test.com";
static const char kTestUsername[] = "testuser@test.com";
class SigninGlobalErrorTest : public testing::Test {
@@ -54,12 +54,12 @@ class SigninGlobalErrorTest : public testing::Test {
base::UTF8ToUTF16("Person 1"), 0, std::string(), testing_factories);
SigninManagerFactory::GetForProfile(profile())
- ->SetAuthenticatedUsername(kTestAccountId);
+ ->SetAuthenticatedAccountInfo(kTestAccountId, kTestUsername);
ProfileInfoCache& cache =
profile_manager_.profile_manager()->GetProfileInfoCache();
cache.SetUserNameOfProfileAtIndex(
cache.GetIndexOfProfileWithPath(profile()->GetPath()),
- base::UTF8ToUTF16(kTestAccountId));
+ base::UTF8ToUTF16(kTestUsername));
global_error_ = SigninGlobalErrorFactory::GetForProfile(profile());
error_controller_ = SigninErrorControllerFactory::GetForProfile(profile());
diff --git a/chrome/browser/signin/signin_manager_factory.cc b/chrome/browser/signin/signin_manager_factory.cc
index f7f828e..9222645 100644
--- a/chrome/browser/signin/signin_manager_factory.cc
+++ b/chrome/browser/signin/signin_manager_factory.cc
@@ -98,11 +98,11 @@ void SigninManagerFactory::RegisterProfilePrefs(
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterStringPref(
- prefs::kGoogleServicesUserAccountId,
+ prefs::kGoogleServicesAccountId,
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterStringPref(
- prefs::kGoogleServicesUsername,
+ prefs::kGoogleServicesUserAccountId,
std::string(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
@@ -120,7 +120,14 @@ void SigninManagerFactory::RegisterProfilePrefs(
prefs::kSignedInTime,
base::Time().ToInternalValue(),
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+
LocalAuth::RegisterLocalAuthPrefs(registry);
+
+ // Deprecated prefs: will be removed in a future release.
+ registry->RegisterStringPref(
+ prefs::kGoogleServicesUsername,
+ std::string(),
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
// static
@@ -149,7 +156,9 @@ KeyedService* SigninManagerFactory::BuildServiceInstanceFor(
SigninClient* client =
ChromeSigninClientFactory::GetInstance()->GetForProfile(profile);
#if defined(OS_CHROMEOS)
- service = new SigninManagerBase(client);
+ service = new SigninManagerBase(
+ client,
+ AccountTrackerServiceFactory::GetForProfile(profile));
#else
service = new SigninManager(
client,
diff --git a/chrome/browser/signin/signin_manager_unittest.cc b/chrome/browser/signin/signin_manager_unittest.cc
index 44d2f11..750333e 100644
--- a/chrome/browser/signin/signin_manager_unittest.cc
+++ b/chrome/browser/signin/signin_manager_unittest.cc
@@ -29,6 +29,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/test_signin_client.h"
#include "content/public/browser/child_process_security_policy.h"
@@ -115,7 +116,10 @@ class SigninManagerTest : public testing::Test {
FakeAccountTrackerService::Build);
profile_ = builder.Build();
- signin_client()->SetURLRequestContext(profile_->GetRequestContext());
+ TestSigninClient* client =
+ static_cast<TestSigninClient*>(
+ ChromeSigninClientFactory::GetForProfile(profile()));
+ client->SetURLRequestContext(profile_->GetRequestContext());
}
void TearDown() override {
@@ -144,6 +148,17 @@ class SigninManagerTest : public testing::Test {
ChromeSigninClientFactory::GetInstance()->GetForProfile(profile()));
}
+ // Seed the account tracker with information from logged in user. Normally
+ // this is done by UI code before calling SigninManager. Returns the string
+ // to use as the account_id.
+ std::string AddToAccountTracker(const std::string& gaia_id,
+ const std::string& email) {
+ AccountTrackerService* service =
+ AccountTrackerServiceFactory::GetForProfile(profile());
+ service->SeedAccountInfo(gaia_id, email);
+ return service->PickAccountIdForAccount(gaia_id, email);
+ }
+
// Sets up the signin manager as a service if other code will try to get it as
// a PKS.
void SetUpSigninManagerAsService() {
@@ -179,11 +194,13 @@ class SigninManagerTest : public testing::Test {
void ExpectSignInWithRefreshTokenSuccess() {
EXPECT_TRUE(manager_->IsAuthenticated());
+ EXPECT_FALSE(manager_->GetAuthenticatedAccountId().empty());
+ EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty());
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
EXPECT_TRUE(token_service->RefreshTokenIsAvailable(
- manager_->GetAuthenticatedUsername()));
+ manager_->GetAuthenticatedAccountId()));
// Should go into token service and stop.
EXPECT_EQ(1, test_observer_.num_successful_signins_);
@@ -210,8 +227,10 @@ TEST_F(SigninManagerTest, SignInWithRefreshToken) {
SetUpSigninManagerAsService();
EXPECT_FALSE(manager_->IsAuthenticated());
+ std::string account_id = AddToAccountTracker("gaia_id", "user@gmail.com");
manager_->StartSignInWithRefreshToken(
- "rt1",
+ "rt",
+ "gaia_id",
"user@gmail.com",
"password",
SigninManager::OAuthTokenFetchedCallback());
@@ -222,7 +241,7 @@ TEST_F(SigninManagerTest, SignInWithRefreshToken) {
ShutDownManager();
CreateNakedSigninManager();
manager_->Initialize(NULL);
- EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
+ EXPECT_EQ(account_id, manager_->GetAuthenticatedAccountId());
}
TEST_F(SigninManagerTest, SignInWithRefreshTokenCallbackComplete) {
@@ -234,14 +253,15 @@ TEST_F(SigninManagerTest, SignInWithRefreshTokenCallbackComplete) {
base::Bind(&SigninManagerTest::CompleteSigninCallback,
base::Unretained(this));
manager_->StartSignInWithRefreshToken(
- "rt1",
+ "rt",
+ "gaia_id",
"user@gmail.com",
"password",
callback);
ExpectSignInWithRefreshTokenSuccess();
ASSERT_EQ(1U, oauth_tokens_fetched_.size());
- EXPECT_EQ(oauth_tokens_fetched_[0], "rt1");
+ EXPECT_EQ(oauth_tokens_fetched_[0], "rt");
}
TEST_F(SigninManagerTest, SignInWithRefreshTokenCallsPostSignout) {
@@ -263,6 +283,7 @@ TEST_F(SigninManagerTest, SignInWithRefreshTokenCallsPostSignout) {
manager_->StartSignInWithRefreshToken(
"rt1",
+ gaia_id,
email,
"password",
SigninManager::OAuthTokenFetchedCallback());
@@ -283,24 +304,31 @@ TEST_F(SigninManagerTest, SignInWithRefreshTokenCallsPostSignout) {
TEST_F(SigninManagerTest, SignOut) {
SetUpSigninManagerAsService();
manager_->StartSignInWithRefreshToken(
- "rt1",
+ "rt",
+ "gaia_id",
"user@gmail.com",
"password",
SigninManager::OAuthTokenFetchedCallback());
manager_->SignOut(signin_metrics::SIGNOUT_TEST);
EXPECT_FALSE(manager_->IsAuthenticated());
+ EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
+ EXPECT_TRUE(manager_->GetAuthenticatedAccountId().empty());
// Should not be persisted anymore
ShutDownManager();
CreateNakedSigninManager();
manager_->Initialize(NULL);
EXPECT_FALSE(manager_->IsAuthenticated());
+ EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
+ EXPECT_TRUE(manager_->GetAuthenticatedAccountId().empty());
}
TEST_F(SigninManagerTest, SignOutWhileProhibited) {
SetUpSigninManagerAsService();
EXPECT_FALSE(manager_->IsAuthenticated());
+ EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
+ EXPECT_TRUE(manager_->GetAuthenticatedAccountId().empty());
- manager_->SetAuthenticatedUsername("user@gmail.com");
+ manager_->SetAuthenticatedAccountInfo("gaia_id", "user@gmail.com");
manager_->ProhibitSignout(true);
manager_->SignOut(signin_metrics::SIGNOUT_TEST);
EXPECT_TRUE(manager_->IsAuthenticated());
@@ -336,47 +364,80 @@ TEST_F(SigninManagerTest, TestAlternateWildcard) {
}
TEST_F(SigninManagerTest, ProhibitedAtStartup) {
- profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
- "monkey@invalid.com");
+ std::string account_id = AddToAccountTracker("gaia_id", "user@gmail.com");
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesAccountId, account_id);
g_browser_process->local_state()->SetString(
prefs::kGoogleServicesUsernamePattern, ".*@google.com");
CreateNakedSigninManager();
manager_->Initialize(g_browser_process->local_state());
// Currently signed in user is prohibited by policy, so should be signed out.
EXPECT_EQ("", manager_->GetAuthenticatedUsername());
+ EXPECT_EQ("", manager_->GetAuthenticatedAccountId());
}
TEST_F(SigninManagerTest, ProhibitedAfterStartup) {
- std::string user("monkey@invalid.com");
- profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user);
+ std::string account_id = AddToAccountTracker("gaia_id", "user@gmail.com");
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesAccountId, account_id);
CreateNakedSigninManager();
manager_->Initialize(g_browser_process->local_state());
- EXPECT_EQ(user, manager_->GetAuthenticatedUsername());
+ EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
+ EXPECT_EQ(account_id, manager_->GetAuthenticatedAccountId());
// Update the profile - user should be signed out.
g_browser_process->local_state()->SetString(
prefs::kGoogleServicesUsernamePattern, ".*@google.com");
EXPECT_EQ("", manager_->GetAuthenticatedUsername());
+ EXPECT_EQ("", manager_->GetAuthenticatedAccountId());
}
TEST_F(SigninManagerTest, ExternalSignIn) {
CreateNakedSigninManager();
manager_->Initialize(g_browser_process->local_state());
- EXPECT_EQ("",
- profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername));
EXPECT_EQ("", manager_->GetAuthenticatedUsername());
+ EXPECT_EQ("", manager_->GetAuthenticatedAccountId());
EXPECT_EQ(0, test_observer_.num_successful_signins_);
- manager_->OnExternalSigninCompleted("external@example.com");
+ std::string account_id = AddToAccountTracker("gaia_id", "user@gmail.com");
+ manager_->OnExternalSigninCompleted(account_id);
EXPECT_EQ(1, test_observer_.num_successful_signins_);
EXPECT_EQ(0, test_observer_.num_failed_signins_);
- EXPECT_EQ("external@example.com",
- profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername));
- EXPECT_EQ("external@example.com", manager_->GetAuthenticatedUsername());
+ EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
+ EXPECT_EQ(account_id, manager_->GetAuthenticatedAccountId());
}
TEST_F(SigninManagerTest, SigninNotAllowed) {
std::string user("user@google.com");
- profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user);
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesAccountId, user);
profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
- SetUpSigninManagerAsService();
+ CreateNakedSigninManager();
+ AddToAccountTracker("gaia_id", user);
+ manager_->Initialize(g_browser_process->local_state());
+ // Currently signing in is prohibited by policy, so should be signed out.
+ EXPECT_EQ("", manager_->GetAuthenticatedUsername());
+ EXPECT_EQ("", manager_->GetAuthenticatedAccountId());
+}
+
+TEST_F(SigninManagerTest, UpgradeToNewPrefs) {
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
+ "user@gmail.com");
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesUserAccountId,
+ "account_id");
+ CreateNakedSigninManager();
+ manager_->Initialize(g_browser_process->local_state());
+ EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
+
+ // TODO(rogerta): until the migration to gaia id, the account id will remain
+ // the old username.
+ EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedAccountId());
+ EXPECT_EQ("user@gmail.com",
+ profile()->GetPrefs()->GetString(prefs::kGoogleServicesAccountId));
+ EXPECT_EQ("",
+ profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername));
+
+ // Make sure account tracker was updated.
+ AccountTrackerService* service =
+ AccountTrackerServiceFactory::GetForProfile(profile());
+ AccountTrackerService::AccountInfo info = service->GetAccountInfo(
+ manager_->GetAuthenticatedAccountId());
+ EXPECT_EQ("user@gmail.com", info.email);
+ EXPECT_EQ("account_id", info.gaia);
}
diff --git a/chrome/browser/signin/signin_names_io_thread_unittest.cc b/chrome/browser/signin/signin_names_io_thread_unittest.cc
index d79013e..607f8e1 100644
--- a/chrome/browser/signin/signin_names_io_thread_unittest.cc
+++ b/chrome/browser/signin/signin_names_io_thread_unittest.cc
@@ -8,11 +8,13 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile_info_cache.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_signin_manager.h"
#include "chrome/browser/signin/signin_names_io_thread.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_browser_thread.h"
@@ -59,7 +61,12 @@ void SigninNamesOnIOThreadTest::TearDown() {
}
void SigninNamesOnIOThreadTest::SimulateSignin(const base::string16& email) {
- signin_manager_->SignIn(base::UTF16ToUTF8(email), "password");
+ const std::string gaia_id = "gaia_id";
+ const std::string email_str = base::UTF16ToUTF8(email);
+ AccountTrackerService* service =
+ AccountTrackerServiceFactory::GetForProfile(profile_.get());
+ service->SeedAccountInfo(gaia_id, email_str);
+ signin_manager_->SignIn(gaia_id, email_str, "password");
}
void SigninNamesOnIOThreadTest::AddNewProfile(const base::string16& name,
diff --git a/chrome/browser/signin/signin_tracker_unittest.cc b/chrome/browser/signin/signin_tracker_unittest.cc
index e982549..34483b7 100644
--- a/chrome/browser/signin/signin_tracker_unittest.cc
+++ b/chrome/browser/signin/signin_tracker_unittest.cc
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/fake_signin_manager.h"
@@ -18,6 +19,7 @@
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_auth_status_provider.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
@@ -69,11 +71,22 @@ class SigninTrackerTest : public testing::Test {
tracker_ =
SigninTrackerFactory::CreateForProfile(profile_.get(), &observer_);
}
+
void TearDown() override {
tracker_.reset();
profile_.reset();
}
+ // Seed the account tracker with information from logged in user. Normally
+ // this is done by UI code before calling SigninManager. Returns the string
+ // to use as the account_id.
+ std::string AddToAccountTracker(const std::string& gaia_id,
+ const std::string& email) {
+ AccountTrackerService* service =
+ AccountTrackerServiceFactory::GetForProfile(profile_.get());
+ return service->SeedAccountInfo(gaia_id, email);
+ }
+
content::TestBrowserThreadBundle thread_bundle_;
scoped_ptr<SigninTracker> tracker_;
scoped_ptr<TestingProfile> profile_;
@@ -99,7 +112,13 @@ TEST_F(SigninTrackerTest, SignInSucceeds) {
EXPECT_CALL(observer_, SigninSuccess());
EXPECT_CALL(observer_, SigninFailed(_)).Times(0);
- mock_signin_manager_->SetAuthenticatedUsername("user@gmail.com");
- fake_oauth2_token_service_->IssueRefreshTokenForUser(
- "user@gmail.com", "refresh_token");
+ AccountTrackerService* service =
+ AccountTrackerServiceFactory::GetForProfile(profile_.get());
+ std::string gaia_id = "gaia_id";
+ std::string email = "user@gmail.com";
+ std::string account_id = service->SeedAccountInfo(gaia_id, email);
+
+ mock_signin_manager_->SetAuthenticatedAccountInfo(gaia_id, email);
+ fake_oauth2_token_service_->IssueRefreshTokenForUser(account_id,
+ "refresh_token");
}
diff --git a/chrome/browser/supervised_user/supervised_user_service_unittest.cc b/chrome/browser/supervised_user/supervised_user_service_unittest.cc
index 83778b3..eb01a78 100644
--- a/chrome/browser/supervised_user/supervised_user_service_unittest.cc
+++ b/chrome/browser/supervised_user/supervised_user_service_unittest.cc
@@ -219,7 +219,7 @@ TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) {
// Emulate being logged in, then start to download a profile so a
// ProfileDownloader gets created.
SigninManagerFactory::GetForProfile(profile_.get())->
- SetAuthenticatedUsername("Logged In");
+ SetAuthenticatedAccountInfo("12345", "Logged In");
downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail));
}
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
index 758db1b..25082eb 100644
--- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
@@ -23,6 +23,7 @@
#include "base/time/time.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
@@ -47,6 +48,7 @@
#include "components/autofill/core/browser/webdata/autofill_profile_syncable_service.h"
#include "components/autofill/core/browser/webdata/autofill_table.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/data_type_controller.h"
#include "components/webdata/common/web_database.h"
@@ -497,6 +499,7 @@ class ProfileSyncServiceAutofillTest
WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS),
profile_->GetPrefs(),
+ AccountTrackerServiceFactory::GetForProfile(profile_),
profile_->IsOffTheRecord());
web_data_service_->StartSyncableService();
@@ -534,7 +537,7 @@ class ProfileSyncServiceAutofillTest
syncer::ModelType type) {
AbstractAutofillFactory* factory = GetFactory(type);
SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_);
- signin->SetAuthenticatedUsername("test_user@gmail.com");
+ signin->SetAuthenticatedAccountInfo("12345", "test_user@gmail.com");
sync_service_ = TestProfileSyncService::BuildAutoStartAsyncInit(profile_,
callback);
@@ -556,7 +559,8 @@ class ProfileSyncServiceAutofillTest
// We need tokens to get the tests going
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)
- ->UpdateCredentials("test_user@gmail.com", "oauth2_login_token");
+ ->UpdateCredentials(signin->GetAuthenticatedAccountId(),
+ "oauth2_login_token");
sync_service_->RegisterDataTypeController(data_type_controller);
sync_service_->Initialize();
diff --git a/chrome/browser/sync/profile_sync_service_mock.cc b/chrome/browser/sync/profile_sync_service_mock.cc
index 1bdcc4d..343c793 100644
--- a/chrome/browser/sync/profile_sync_service_mock.cc
+++ b/chrome/browser/sync/profile_sync_service_mock.cc
@@ -47,7 +47,7 @@ ProfileSyncServiceMock::~ProfileSyncServiceMock() {
TestingProfile* ProfileSyncServiceMock::MakeSignedInTestingProfile() {
TestingProfile* profile = new TestingProfile();
SigninManagerFactory::GetForProfile(profile)->
- SetAuthenticatedUsername("foo");
+ SetAuthenticatedAccountInfo("12345", "foo");
return profile;
}
diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
index 4db61d7..55563b9 100644
--- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
@@ -7,6 +7,7 @@
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/fake_signin_manager.h"
@@ -21,6 +22,7 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/data_type_manager.h"
@@ -47,6 +49,14 @@ using testing::Mock;
using testing::Return;
using testing::SaveArg;
+namespace {
+
+const char kGaiaId[] = "12345";
+const char kEmail[] = "test_user@gmail.com";
+const char kDummyPassword[] = "";
+
+} // namespace
+
ACTION_P(InvokeOnConfigureStart, pss) {
ProfileSyncService* service =
static_cast<ProfileSyncService*>(pss);
@@ -129,9 +139,9 @@ class ProfileSyncServiceStartupTest : public testing::Test {
sync_->AddObserver(&observer_);
}
- void IssueTestTokens() {
+ void IssueTestTokens(const std::string& account_id) {
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)
- ->UpdateCredentials("test_user@gmail.com", "oauth2_login_token");
+ ->UpdateCredentials(account_id, "oauth2_login_token");
}
ProfileSyncComponentsFactoryMock* components_factory_mock() {
@@ -153,15 +163,23 @@ class ProfileSyncServiceStartupTest : public testing::Test {
}
protected:
- void SimulateTestUserSignin() {
+ static std::string SimulateTestUserSignin(
+ Profile* profile,
+ FakeSigninManagerForTesting* fake_signin,
+ ProfileSyncService* sync) {
+ std::string account_id =
+ AccountTrackerServiceFactory::GetForProfile(profile)
+ ->SeedAccountInfo(kGaiaId, kEmail);
+ profile->GetPrefs()->SetString(prefs::kGoogleServicesAccountId,
+ account_id);
#if !defined(OS_CHROMEOS)
- fake_signin()->SignIn("test_user@gmail.com", "");
+ fake_signin->SignIn(kGaiaId, kEmail, kDummyPassword);
#else
- fake_signin()->SetAuthenticatedUsername("test_user@gmail.com");
- sync_->GoogleSigninSucceeded("test_user@gmail.com",
- "test_user@gmail.com",
- "");
+ fake_signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail);
+ if (sync)
+ sync->GoogleSigninSucceeded(account_id, kEmail, kDummyPassword);
#endif
+ return account_id;
}
DataTypeManagerMock* SetUpDataTypeManager() {
@@ -201,9 +219,10 @@ class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest {
static KeyedService* BuildCrosService(content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- SigninManagerBase* signin =
- SigninManagerFactory::GetForProfile(profile);
- signin->SetAuthenticatedUsername("test_user@gmail.com");
+ FakeSigninManagerForTesting* signin =
+ static_cast<FakeSigninManagerForTesting*>(
+ SigninManagerFactory::GetForProfile(profile));
+ SimulateTestUserSignin(profile, signin, nullptr);
ProfileOAuth2TokenService* oauth2_token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
EXPECT_TRUE(signin->IsAuthenticated());
@@ -250,9 +269,10 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
sync_->SetSetupInProgress(true);
// Simulate successful signin as test_user.
- SimulateTestUserSignin();
+ std::string account_id =
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
// Create some tokens in the token service.
- IssueTestTokens();
+ IssueTestTokens(account_id);
// Simulate the UI telling sync it has finished setting up.
sync_->SetSetupInProgress(false);
@@ -283,11 +303,12 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartNoCredentials) {
sync_->SetSetupInProgress(true);
// Simulate successful signin as test_user.
- SimulateTestUserSignin();
+ std::string account_id =
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
- token_service->LoadCredentials("test_user@gmail.com");
+ token_service->LoadCredentials(account_id);
sync_->SetSetupInProgress(false);
// ProfileSyncService should try to start by requesting access token.
@@ -299,8 +320,9 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartNoCredentials) {
// TODO(pavely): Reenable test once android is switched to oauth2.
TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartInvalidCredentials) {
- sync_->signin()->SetAuthenticatedUsername("test_user@gmail.com");
CreateSyncService();
+ std::string account_id =
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
SyncBackendHostMock* mock_sbh = SetUpSyncBackendHost();
// Tell the backend to stall while downloading control types (simulating an
@@ -324,7 +346,7 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartInvalidCredentials) {
sync_->SetSetupInProgress(true);
// Simulate successful signin.
- SimulateTestUserSignin();
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
sync_->SetSetupInProgress(false);
@@ -365,7 +387,9 @@ TEST_F(ProfileSyncServiceStartupCrosTest, StartFirstTime) {
EXPECT_CALL(*data_type_manager, Stop()).Times(1);
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
- IssueTestTokens();
+ IssueTestTokens(
+ AccountTrackerServiceFactory::GetForProfile(profile_)
+ ->PickAccountIdForAccount("12345", kEmail));
sync_->Initialize();
EXPECT_TRUE(sync_->SyncActive());
}
@@ -378,9 +402,9 @@ TEST_F(ProfileSyncServiceStartupCrosTest, StartFirstTime) {
#endif
TEST_F(ProfileSyncServiceStartupTest, MAYBE_StartNormal) {
// Pre load the tokens
- SigninManagerFactory::GetForProfile(profile_)
- ->SetAuthenticatedUsername("test_user@gmail.com");
CreateSyncService();
+ std::string account_id =
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
sync_->SetSyncSetupCompleted();
SetUpSyncBackendHost();
DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
@@ -390,7 +414,7 @@ TEST_F(ProfileSyncServiceStartupTest, MAYBE_StartNormal) {
EXPECT_CALL(*data_type_manager, Stop()).Times(1);
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
- IssueTestTokens();
+ IssueTestTokens(account_id);
sync_->Initialize();
}
@@ -410,9 +434,9 @@ TEST_F(ProfileSyncServiceStartupTest, StartRecoverDatatypePrefs) {
}
// Pre load the tokens
- SigninManagerFactory::GetForProfile(profile_)
- ->SetAuthenticatedUsername("test_user@gmail.com");
CreateSyncService();
+ std::string account_id =
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
sync_->SetSyncSetupCompleted();
SetUpSyncBackendHost();
DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
@@ -422,7 +446,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartRecoverDatatypePrefs) {
EXPECT_CALL(*data_type_manager, Stop()).Times(1);
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
- IssueTestTokens();
+ IssueTestTokens(account_id);
sync_->Initialize();
EXPECT_TRUE(profile_->GetPrefs()->GetBoolean(
@@ -444,9 +468,9 @@ TEST_F(ProfileSyncServiceStartupTest, MAYBE_StartDontRecoverDatatypePrefs) {
sync_driver::prefs::kSyncKeepEverythingSynced, false);
// Pre load the tokens
- SigninManagerFactory::GetForProfile(profile_)
- ->SetAuthenticatedUsername("test_user@gmail.com");
CreateSyncService();
+ std::string account_id =
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
sync_->SetSyncSetupCompleted();
SetUpSyncBackendHost();
DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
@@ -455,7 +479,7 @@ TEST_F(ProfileSyncServiceStartupTest, MAYBE_StartDontRecoverDatatypePrefs) {
WillRepeatedly(Return(DataTypeManager::CONFIGURED));
EXPECT_CALL(*data_type_manager, Stop()).Times(1);
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
- IssueTestTokens();
+ IssueTestTokens(account_id);
sync_->Initialize();
EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(
@@ -470,8 +494,8 @@ TEST_F(ProfileSyncServiceStartupTest, MAYBE_StartDontRecoverDatatypePrefs) {
#endif
TEST_F(ProfileSyncServiceStartupTest, MAYBE_ManagedStartup) {
// Service should not be started by Initialize() since it's managed.
- profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
- "test_user@gmail.com");
+ profile_->GetPrefs()->SetString(prefs::kGoogleServicesAccountId,
+ kEmail);
CreateSyncService();
// Disable sync through policy.
@@ -484,15 +508,15 @@ TEST_F(ProfileSyncServiceStartupTest, MAYBE_ManagedStartup) {
}
TEST_F(ProfileSyncServiceStartupTest, SwitchManaged) {
- SigninManagerFactory::GetForProfile(profile_)
- ->SetAuthenticatedUsername("test_user@gmail.com");
CreateSyncService();
+ std::string account_id =
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
sync_->SetSyncSetupCompleted();
SetUpSyncBackendHost();
DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
EXPECT_CALL(*data_type_manager, Configure(_, _));
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
- IssueTestTokens();
+ IssueTestTokens(account_id);
sync_->Initialize();
// The service should stop when switching to managed mode.
@@ -513,9 +537,9 @@ TEST_F(ProfileSyncServiceStartupTest, SwitchManaged) {
}
TEST_F(ProfileSyncServiceStartupTest, StartFailure) {
- SigninManagerFactory::GetForProfile(profile_)
- ->SetAuthenticatedUsername("test_user@gmail.com");
CreateSyncService();
+ std::string account_id =
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
sync_->SetSyncSetupCompleted();
SetUpSyncBackendHost();
DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
@@ -533,16 +557,16 @@ TEST_F(ProfileSyncServiceStartupTest, StartFailure) {
EXPECT_CALL(*data_type_manager, state()).
WillOnce(Return(DataTypeManager::STOPPED));
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
- IssueTestTokens();
+ IssueTestTokens(account_id);
sync_->Initialize();
EXPECT_TRUE(sync_->HasUnrecoverableError());
}
TEST_F(ProfileSyncServiceStartupTest, StartDownloadFailed) {
// Pre load the tokens
- SigninManagerFactory::GetForProfile(profile_)
- ->SetAuthenticatedUsername("test_user@gmail.com");
CreateSyncService();
+ std::string account_id =
+ SimulateTestUserSignin(profile_, fake_signin(), sync_);
SyncBackendHostMock* mock_sbh = SetUpSyncBackendHost();
mock_sbh->set_fail_initial_download(true);
@@ -552,7 +576,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartDownloadFailed) {
sync_->Initialize();
sync_->SetSetupInProgress(true);
- IssueTestTokens();
+ IssueTestTokens(account_id);
sync_->SetSetupInProgress(false);
EXPECT_FALSE(sync_->SyncActive());
}
diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
index 262bfc9..2a7bc23 100644
--- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/invalidation/fake_invalidation_service.h"
#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
@@ -47,6 +48,7 @@
#include "components/invalidation/invalidation_service.h"
#include "components/invalidation/profile_invalidation_provider.h"
#include "components/keyed_service/core/refcounted_keyed_service.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/data_type_error_handler_mock.h"
#include "content/public/browser/notification_service.h"
@@ -258,8 +260,11 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest {
TypedUrlModelAssociator* StartSyncService(const base::Closure& callback) {
TypedUrlModelAssociator* model_associator = NULL;
if (!sync_service_) {
+ std::string account_id =
+ AccountTrackerServiceFactory::GetForProfile(profile_)
+ ->SeedAccountInfo("gaia_id", "test");
SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_);
- signin->SetAuthenticatedUsername("test");
+ signin->SetAuthenticatedAccountInfo("gaia_id", "test");
sync_service_ = TestProfileSyncService::BuildAutoStartAsyncInit(profile_,
callback);
ProfileSyncComponentsFactoryMock* components =
@@ -279,7 +284,7 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest {
ProfileOAuth2TokenService* oauth2_token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
- oauth2_token_service->UpdateCredentials("test", "oauth2_login_token");
+ oauth2_token_service->UpdateCredentials(account_id, "oauth2_login_token");
sync_service_->RegisterDataTypeController(data_type_controller);
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index 2d08b39..cba1633 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -12,6 +12,7 @@
#include "base/values.h"
#include "chrome/browser/invalidation/fake_invalidation_service.h"
#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
@@ -28,6 +29,8 @@
#include "chrome/test/base/testing_profile_manager.h"
#include "components/invalidation/invalidation_service.h"
#include "components/invalidation/profile_invalidation_provider.h"
+#include "components/signin/core/browser/account_tracker_service.h"
+#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/data_type_manager.h"
#include "components/sync_driver/pref_names.h"
@@ -46,6 +49,9 @@ namespace browser_sync {
namespace {
+const char kGaiaId[] = "12345";
+const char kEmail[] = "test_user@gmail.com";
+
class FakeDataTypeManager : public sync_driver::DataTypeManager {
public:
explicit FakeDataTypeManager(sync_driver::DataTypeManagerObserver* observer)
@@ -205,14 +211,17 @@ class ProfileSyncServiceTest : public ::testing::Test {
}
void IssueTestTokens() {
+ std::string account_id =
+ AccountTrackerServiceFactory::GetForProfile(profile_)
+ ->SeedAccountInfo(kGaiaId, kEmail);
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)
- ->UpdateCredentials("test", "oauth2_login_token");
+ ->UpdateCredentials(account_id, "oauth2_login_token");
}
void CreateService(ProfileSyncServiceStartBehavior behavior) {
SigninManagerBase* signin =
SigninManagerFactory::GetForProfile(profile_);
- signin->SetAuthenticatedUsername("test");
+ signin->SetAuthenticatedAccountInfo(kGaiaId, kEmail);
ProfileOAuth2TokenService* oauth2_token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
components_factory_ = new ProfileSyncComponentsFactoryMock();
@@ -526,7 +535,7 @@ TEST_F(ProfileSyncServiceTest, BackupBeforeFirstSync) {
InitializeForFirstSync();
SigninManagerFactory::GetForProfile(profile())
- ->SetAuthenticatedUsername("test");
+ ->SetAuthenticatedAccountInfo(kGaiaId, kEmail);
IssueTestTokens();
PumpLoop();
diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc
index f84856a..157abc6 100644
--- a/chrome/browser/sync/sync_ui_util_unittest.cc
+++ b/chrome/browser/sync/sync_ui_util_unittest.cc
@@ -44,6 +44,7 @@ enum DistinctState {
namespace {
+const char kTestGaiaId[] = "gaia-id-test_user@test.com";
const char kTestUser[] = "test_user@test.com";
#if !defined(OS_CHROMEOS)
@@ -252,7 +253,7 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
.WillRepeatedly(DoAll(SetArgPointee<0>(status),
Return(false)));
provider->SetAuthError(
- kTestUser,
+ signin->GetAuthenticatedAccountId(),
kTestUser,
GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
EXPECT_CALL(service, HasUnrecoverableError())
@@ -339,7 +340,7 @@ TEST_F(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) {
GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone();
EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error));
FakeSigninManagerForSyncUIUtilTest signin(profile.get());
- signin.SetAuthenticatedUsername(kTestUser);
+ signin.SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
scoped_ptr<FakeAuthStatusProvider> provider(new FakeAuthStatusProvider(
SigninErrorControllerFactory::GetForProfile(profile.get())));
GetDistinctCase(service, &signin, provider.get(), idx);
@@ -378,7 +379,7 @@ TEST_F(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) {
GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone();
EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error));
FakeSigninManagerForSyncUIUtilTest signin(profile.get());
- signin.SetAuthenticatedUsername(kTestUser);
+ signin.SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
scoped_ptr<FakeAuthStatusProvider> provider(new FakeAuthStatusProvider(
SigninErrorControllerFactory::GetForProfile(profile.get())));
GetDistinctCase(service, &signin, provider.get(), idx);
diff --git a/chrome/browser/sync/test/integration/profile_sync_service_harness.cc b/chrome/browser/sync/test/integration/profile_sync_service_harness.cc
index 2f4450b..e739a36a 100644
--- a/chrome/browser/sync/test/integration/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/test/integration/profile_sync_service_harness.cc
@@ -37,6 +37,10 @@ using syncer::sessions::SyncSessionSnapshot;
namespace {
+std::string GetGaiaIdForUsername(const std::string& username) {
+ return "gaia-id-" + username;
+}
+
bool HasAuthError(ProfileSyncService* service) {
return service->GetAuthError().state() ==
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
@@ -155,6 +159,12 @@ bool ProfileSyncServiceHarness::SetupSync(
// until we've finished configuration.
service()->SetSetupInProgress(true);
+ // Authenticate sync client using GAIA credentials.
+ std::string gaia_id = GetGaiaIdForUsername(username_);
+ service()->signin()->SetAuthenticatedAccountInfo(gaia_id, username_);
+ std::string account_id = service()->signin()->GetAuthenticatedAccountId();
+ service()->GoogleSigninSucceeded(account_id, username_, password_);
+
DCHECK(!username_.empty());
if (signin_type_ == SigninType::UI_SIGNIN) {
Browser* browser =
@@ -166,10 +176,10 @@ bool ProfileSyncServiceHarness::SetupSync(
}
} else if (signin_type_ == SigninType::FAKE_SIGNIN) {
// Authenticate sync client using GAIA credentials.
- service()->signin()->SetAuthenticatedUsername(username_);
- service()->GoogleSigninSucceeded(username_, username_, password_);
+ service()->signin()->SetAuthenticatedAccountInfo(gaia_id, username_);
+ service()->GoogleSigninSucceeded(account_id, username_, password_);
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
- UpdateCredentials(username_, GenerateFakeOAuth2RefreshTokenString());
+ UpdateCredentials(account_id, GenerateFakeOAuth2RefreshTokenString());
} else {
LOG(ERROR) << "Unsupported profile signin type.";
}
diff --git a/chrome/browser/ui/app_list/speech_auth_helper_unittest.cc b/chrome/browser/ui/app_list/speech_auth_helper_unittest.cc
index 7302af1..902f9b5 100644
--- a/chrome/browser/ui/app_list/speech_auth_helper_unittest.cc
+++ b/chrome/browser/ui/app_list/speech_auth_helper_unittest.cc
@@ -25,6 +25,7 @@
namespace app_list {
+static const char* kTestGaiaId = "gaia_id";
static const char* kTestUser = "test.user@chromium.org.test";
static const char* kScope = "https://www.googleapis.com/auth/webhistory";
static const char* kAccessToken = "fake_access_token";
@@ -53,8 +54,8 @@ class SpeechAuthHelperTest : public testing::Test {
factories);
// Set up the authenticated user name and ID.
- SigninManagerFactory::GetForProfile(profile_)->SetAuthenticatedUsername(
- kTestUser);
+ SigninManagerFactory::GetForProfile(profile_)->SetAuthenticatedAccountInfo(
+ kTestGaiaId, kTestUser);
}
protected:
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
index aa5e119..e1e566e 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
@@ -14,6 +14,7 @@
#include "base/time/time.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/ui/autofill/account_chooser_model.h"
#include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
@@ -43,6 +44,7 @@
#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/navigation_details.h"
@@ -104,9 +106,12 @@ class TestAutofillDialogController : public AutofillDialogControllerImpl {
use_validation_(false),
sign_in_user_index_(0U),
weak_ptr_factory_(this) {
+ Profile* profile =
+ Profile::FromBrowserContext(contents->GetBrowserContext());
test_manager_.Init(
NULL,
- Profile::FromBrowserContext(contents->GetBrowserContext())->GetPrefs(),
+ profile->GetPrefs(),
+ AccountTrackerServiceFactory::GetForProfile(profile),
false);
}
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
index 55b9a39..4b7e267 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
@@ -18,6 +18,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view.h"
@@ -48,6 +49,7 @@
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_data.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/mock_render_process_host.h"
@@ -267,10 +269,12 @@ class TestAutofillDialogController
}
void Init(content::BrowserContext* browser_context) {
+ Profile* profile = Profile::FromBrowserContext(browser_context);
test_manager_.Init(WebDataServiceFactory::GetAutofillWebDataForProfile(
- Profile::FromBrowserContext(browser_context),
+ profile,
ServiceAccessType::EXPLICIT_ACCESS),
user_prefs::UserPrefs::Get(browser_context),
+ AccountTrackerServiceFactory::GetForProfile(profile),
browser_context->IsOffTheRecord());
}
diff --git a/chrome/browser/ui/autofill/country_combobox_model_unittest.cc b/chrome/browser/ui/autofill/country_combobox_model_unittest.cc
index c243d8e..1952c14 100644
--- a/chrome/browser/ui/autofill/country_combobox_model_unittest.cc
+++ b/chrome/browser/ui/autofill/country_combobox_model_unittest.cc
@@ -6,9 +6,11 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/test_personal_data_manager.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui_component.h"
@@ -19,7 +21,9 @@ namespace autofill {
class CountryComboboxModelTest : public testing::Test {
public:
CountryComboboxModelTest() {
- manager_.Init(NULL, profile_.GetPrefs(), false);
+ manager_.Init(
+ NULL, profile_.GetPrefs(),
+ AccountTrackerServiceFactory::GetForProfile(&profile_), false);
manager_.set_timezone_country_code("KR");
model_.reset(new CountryComboboxModel());
model_->SetCountries(manager_, base::Callback<bool(const std::string&)>());
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm
index d93356f..d979bbe 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm
@@ -468,7 +468,7 @@ TEST_F(BookmarkBubbleControllerTest, SyncPromoNotSignedIn) {
// Confirm that the sync promo is not displayed when the user is signed in.
TEST_F(BookmarkBubbleControllerTest, SyncPromoSignedIn) {
SigninManager* signin = SigninManagerFactory::GetForProfile(profile());
- signin->SetAuthenticatedUsername("fake_username");
+ signin->SetAuthenticatedAccountInfo("fake_username", "fake_username");
const BookmarkNode* node = CreateTestBookmark();
BookmarkBubbleController* controller = ControllerForNode(node);
diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm
index 2a4958e..2b1afd9 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm
@@ -370,7 +370,7 @@ TEST_F(ProfileChooserControllerTest, AccountManagementLayout) {
// Set up the signin manager and the OAuth2Tokens.
Profile* profile = browser()->profile();
SigninManagerFactory::GetForProfile(profile)->
- SetAuthenticatedUsername(kEmail);
+ SetAuthenticatedAccountInfo(kEmail, kEmail);
ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
UpdateCredentials(kEmail, kLoginToken);
ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
diff --git a/chrome/browser/ui/search/search_tab_helper_unittest.cc b/chrome/browser/ui/search/search_tab_helper_unittest.cc
index 9855cc4..850a574 100644
--- a/chrome/browser/ui/search/search_tab_helper_unittest.cc
+++ b/chrome/browser/ui/search/search_tab_helper_unittest.cc
@@ -99,7 +99,7 @@ class SearchTabHelperTest : public ChromeRenderViewHostTestHarness {
if (!username.empty()) {
ASSERT_TRUE(signin_manager);
- signin_manager->SetAuthenticatedUsername(username);
+ signin_manager->SetAuthenticatedAccountInfo(username, username);
}
}
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
index ad9d1f2..9c347ba 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
@@ -73,6 +73,7 @@ void SetUserChoiceHistogram(SigninChoice choice) {
OneClickSigninSyncStarter::OneClickSigninSyncStarter(
Profile* profile,
Browser* browser,
+ const std::string& gaia_id,
const std::string& email,
const std::string& password,
const std::string& refresh_token,
@@ -98,7 +99,7 @@ OneClickSigninSyncStarter::OneClickSigninSyncStarter(
// before signin completes.
SigninManagerFactory::GetForProfile(profile_)->
StartSignInWithRefreshToken(
- refresh_token, email, password,
+ refresh_token, gaia_id, email, password,
base::Bind(&OneClickSigninSyncStarter::ConfirmSignin,
weak_pointer_factory_.GetWeakPtr()));
}
@@ -149,7 +150,7 @@ void OneClickSigninSyncStarter::Initialize(Profile* profile, Browser* browser) {
void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) {
DCHECK(!oauth_token.empty());
SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
- // If this is a new signin (no authenticated username yet) try loading
+ // If this is a new signin (no account authenticated yet) try loading
// policy for this user now, before any signed in services are initialized.
if (!signin->IsAuthenticated()) {
#if defined(ENABLE_CONFIGURATION_POLICY)
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.h b/chrome/browser/ui/sync/one_click_signin_sync_starter.h
index b66f918..f5b6466 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter.h
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.h
@@ -94,6 +94,7 @@ class OneClickSigninSyncStarter : public SigninTracker::Observer,
// It can be empty.
OneClickSigninSyncStarter(Profile* profile,
Browser* browser,
+ const std::string& gaia_id,
const std::string& email,
const std::string& password,
const std::string& refresh_token,
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc
index 10b5228..571f624 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc
@@ -8,18 +8,23 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
+
+const char* kTestingGaiaId = "gaia_id";
const char* kTestingUsername = "fake_username";
+
} // namespace
class OneClickSigninSyncStarterTest : public ChromeRenderViewHostTestHarness {
@@ -41,7 +46,8 @@ class OneClickSigninSyncStarterTest : public ChromeRenderViewHostTestHarness {
SigninManagerFactory::GetForProfile(profile()));
signin_manager->Initialize(NULL);
- signin_manager->SetAuthenticatedUsername(kTestingUsername);
+ signin_manager->SetAuthenticatedAccountInfo(kTestingGaiaId,
+ kTestingUsername);
}
void Callback(OneClickSigninSyncStarter::SyncSetupResult result) {
@@ -67,6 +73,7 @@ class OneClickSigninSyncStarterTest : public ChromeRenderViewHostTestHarness {
sync_starter_ = new OneClickSigninSyncStarter(
profile(),
NULL,
+ kTestingGaiaId,
kTestingUsername,
std::string(),
"refresh_token",
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view_unittest.cc
index 25dae71..14fe038 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view_unittest.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view_unittest.cc
@@ -69,10 +69,11 @@ class BookmarkBubbleViewTest : public BrowserWithTestWindowTest {
void SetUpSigninManager(const std::string& username) {
if (username.empty())
return;
+
SigninManagerBase* signin_manager = static_cast<SigninManagerBase*>(
SigninManagerFactory::GetForProfile(profile()));
ASSERT_TRUE(signin_manager);
- signin_manager->SetAuthenticatedUsername(username);
+ signin_manager->SetAuthenticatedAccountInfo(username, username);
}
scoped_ptr<BookmarkBubbleView> bubble_;
diff --git a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
index fb99545..45d41c8 100644
--- a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
@@ -275,6 +275,7 @@ const char kURLRegisterComplete[] =
const char kURLGaiaToken[] =
"https://accounts.google.com/o/oauth2/token";
+const char kSampleGaiaId[] = "12345";
const char kSampleUser[] = "user@host.com";
class TestMessageLoopCondition {
@@ -364,7 +365,7 @@ class LocalDiscoveryUITest : public WebUIBrowserTest {
SigninManagerFactory::GetForProfile(browser()->profile());
DCHECK(signin_manager);
- signin_manager->SetAuthenticatedUsername(kSampleUser);
+ signin_manager->SetAuthenticatedAccountInfo(kSampleGaiaId, kSampleUser);
fake_fetcher_factory().SetFakeResponse(
GURL(kURLInfo),
diff --git a/chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc b/chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc
index d51fd41..ba10be6 100644
--- a/chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc
+++ b/chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc
@@ -139,7 +139,8 @@ class SharedOptionsTest : public LoginManagerTest {
Browser* CreateBrowserForUser(const user_manager::User* user) {
Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user);
SigninManagerFactory::GetForProfile(profile)->
- SetAuthenticatedUsername(user->email());
+ SetAuthenticatedAccountInfo(GetGaiaIDForUserID(user->email()),
+ user->email());
ui_test_utils::BrowserAddedObserver observer;
Browser* browser = CreateBrowser(profile);
diff --git a/chrome/browser/ui/webui/options/options_ui_browsertest.cc b/chrome/browser/ui/webui/options/options_ui_browsertest.cc
index 091f4c3..284c38a 100644
--- a/chrome/browser/ui/webui/options/options_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/options/options_ui_browsertest.cc
@@ -9,6 +9,7 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/chrome_pages.h"
@@ -18,6 +19,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_frame_host.h"
@@ -248,10 +250,13 @@ IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, MAYBE_VerifyManagedSignout) {
}
IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, VerifyUnmanagedSignout) {
+ const std::string user = "test@example.com";
+ std::string account_id =
+ AccountTrackerServiceFactory::GetForProfile(browser()->profile())
+ ->SeedAccountInfo("12345", user);
SigninManager* signin =
SigninManagerFactory::GetForProfile(browser()->profile());
- const std::string user = "test@example.com";
- signin->OnExternalSigninCompleted(user);
+ signin->OnExternalSigninCompleted(account_id);
NavigateToSettingsFrame();
diff --git a/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc b/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc
index 92fd14d..db05b3c 100644
--- a/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc
+++ b/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc
@@ -276,7 +276,7 @@ class SyncSetupHandlerTest : public testing::Test {
SigninManagerFactory::GetForProfile(profile_.get()));
std::string username = GetTestUser();
if (!username.empty())
- mock_signin_->SetAuthenticatedUsername(username);
+ mock_signin_->SetAuthenticatedAccountInfo(username, username);
mock_pss_ = static_cast<ProfileSyncServiceMock*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
@@ -865,7 +865,7 @@ TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) {
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
SetupInitializedProfileSyncService();
- mock_signin_->SetAuthenticatedUsername(kTestUser);
+ mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser);
FakeAuthStatusProvider provider(
SigninErrorControllerFactory::GetForProfile(profile_.get()));
provider.SetAuthError(kTestUser, kTestUser, error_);
diff --git a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
index a76a764..697d92f 100644
--- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
+++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
@@ -306,13 +306,10 @@ void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) {
AboutSigninInternalsFactory::GetForProfile(profile_);
about_signin_internals->OnRefreshTokenReceived("Successful");
- AccountTrackerService* account_tracker =
- AccountTrackerServiceFactory::GetForProfile(profile_);
- std::string account_id =
- account_tracker->PickAccountIdForAccount(gaia_id_, email_);
-
// Prime the account tracker with this combination of gaia id/display email.
- account_tracker->SeedAccountInfo(gaia_id_, email_);
+ std::string account_id =
+ AccountTrackerServiceFactory::GetForProfile(profile_)
+ ->SeedAccountInfo(gaia_id_, email_);
signin_metrics::Source source = signin::GetSourceForPromoURL(current_url_);
@@ -387,7 +384,7 @@ void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) {
// OneClickSigninSyncStarter will delete itself once the job is done.
new OneClickSigninSyncStarter(
profile_, browser,
- email_, password_, result.refresh_token,
+ gaia_id_, email_, password_, result.refresh_token,
start_mode,
contents,
confirmation_required,
@@ -448,7 +445,7 @@ void InlineSigninHelper::ConfirmEmailAction(
break;
case ConfirmEmailDialogDelegate::START_SYNC:
new OneClickSigninSyncStarter(
- profile_, browser, email_, password_, refresh_token,
+ profile_, browser, gaia_id_, email_, password_, refresh_token,
start_mode, web_contents, confirmation_required, GURL(),
base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, handler_));
break;
diff --git a/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc b/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
index 1f822e6..f34482f 100644
--- a/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
@@ -137,7 +137,7 @@ void InlineLoginUIBrowserTest::SetUpSigninManager(const std::string& username) {
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfile(browser()->profile());
- signin_manager->SetAuthenticatedUsername(username);
+ signin_manager->SetAuthenticatedAccountInfo(username, username);
}
void InlineLoginUIBrowserTest::EnableSigninAllowed(bool enable) {