| Index: chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
|
| 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 084c30be9a3bb57d62ddf264e84493c0ce8fe9a3..68775d1b26db1eff190a43023728dcf5be61861b 100644
|
| --- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
|
| +++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/values.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/signin/about_signin_internals_factory.h"
|
| +#include "chrome/browser/signin/account_tracker_service_factory.h"
|
| #include "chrome/browser/signin/chrome_signin_client_factory.h"
|
| #include "chrome/browser/signin/local_auth.h"
|
| #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
|
| @@ -29,6 +30,7 @@
|
| #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "components/signin/core/browser/about_signin_internals.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_error_controller.h"
|
| #include "components/signin/core/browser/signin_oauth_helper.h"
|
| @@ -51,6 +53,7 @@ class InlineSigninHelper : public SigninOAuthHelper::Consumer {
|
| Profile* profile,
|
| const GURL& current_url,
|
| const std::string& email,
|
| + const std::string& gaia_id,
|
| const std::string& password,
|
| const std::string& session_index,
|
| const std::string& signin_scoped_device_id,
|
| @@ -71,6 +74,7 @@ class InlineSigninHelper : public SigninOAuthHelper::Consumer {
|
| Profile* profile_;
|
| GURL current_url_;
|
| std::string email_;
|
| + std::string gaia_id_;
|
| std::string password_;
|
| std::string session_index_;
|
| bool choose_what_to_sync_;
|
| @@ -85,6 +89,7 @@ InlineSigninHelper::InlineSigninHelper(
|
| Profile* profile,
|
| const GURL& current_url,
|
| const std::string& email,
|
| + const std::string& gaia_id,
|
| const std::string& password,
|
| const std::string& session_index,
|
| const std::string& signin_scoped_device_id,
|
| @@ -96,6 +101,7 @@ InlineSigninHelper::InlineSigninHelper(
|
| profile_(profile),
|
| current_url_(current_url),
|
| email_(email),
|
| + gaia_id_(gaia_id),
|
| password_(password),
|
| session_index_(session_index),
|
| choose_what_to_sync_(choose_what_to_sync),
|
| @@ -119,6 +125,14 @@ void InlineSigninHelper::OnSigninOAuthInformationAvailable(
|
| 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(account_id, gaia_id_, email_);
|
| +
|
| signin::Source source = signin::GetSourceForPromoURL(current_url_);
|
|
|
| std::string primary_email =
|
| @@ -132,7 +146,7 @@ void InlineSigninHelper::OnSigninOAuthInformationAvailable(
|
| if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT ||
|
| source == signin::SOURCE_REAUTH) {
|
| ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
|
| - UpdateCredentials(email, refresh_token);
|
| + UpdateCredentials(account_id, refresh_token);
|
|
|
| if (signin::IsAutoCloseEnabledInURL(current_url_)) {
|
| // Close the gaia sign in tab via a task to make sure we aren't in the
|
| @@ -195,7 +209,7 @@ void InlineSigninHelper::OnSigninOAuthInformationAvailable(
|
| // OneClickSigninSyncStarter will delete itself once the job is done.
|
| new OneClickSigninSyncStarter(
|
| profile_, browser,
|
| - email, password_, refresh_token,
|
| + account_id, password_, refresh_token,
|
| start_mode,
|
| contents,
|
| confirmation_required,
|
| @@ -305,6 +319,11 @@ void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
|
| dict->GetString("password", &password_string16);
|
| std::string password(base::UTF16ToASCII(password_string16));
|
|
|
| + base::string16 gaia_id_string16;
|
| + dict->GetString("gaiaId", &gaia_id_string16);
|
| + DCHECK(!gaia_id_string16.empty());
|
| + std::string gaia_id = base::UTF16ToASCII(gaia_id_string16);
|
| +
|
| // When doing a SAML sign in, this email check may result in a false
|
| // positive. This happens when the user types one email address in the
|
| // gaia sign in page, but signs in to a different account in the SAML sign in
|
| @@ -383,7 +402,7 @@ void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
|
| // InlineSigninHelper will delete itself.
|
| new InlineSigninHelper(GetWeakPtr(), partition->GetURLRequestContext(),
|
| Profile::FromWebUI(web_ui()), current_url,
|
| - email, password, session_index,
|
| + email, gaia_id, password, session_index,
|
| signin_scoped_device_id, choose_what_to_sync,
|
| confirm_untrusted_signin_);
|
|
|
|
|