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 13c59ca1bcaf13d849f8f9cbdd3699fc59f720c8..a3d56d65090cab156f1dc4b5e93ec27f8923bb6a 100644 |
--- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc |
+++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc |
@@ -33,10 +33,10 @@ |
#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" |
#include "components/signin/core/common/profile_management_switches.h" |
#include "content/public/browser/storage_partition.h" |
#include "content/public/browser/web_ui.h" |
-#include "google_apis/gaia/gaia_auth_consumer.h" |
#include "google_apis/gaia/gaia_auth_fetcher.h" |
#include "google_apis/gaia/gaia_auth_util.h" |
#include "google_apis/gaia/gaia_constants.h" |
@@ -45,7 +45,7 @@ |
namespace { |
-class InlineSigninHelper : public GaiaAuthConsumer { |
+class InlineSigninHelper : public SigninOAuthHelper::Consumer { |
public: |
InlineSigninHelper( |
base::WeakPtr<InlineLoginHandlerImpl> handler, |
@@ -53,7 +53,6 @@ |
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, |
@@ -61,17 +60,19 @@ |
bool confirm_untrusted_signin); |
private: |
- // Overridden from GaiaAuthConsumer. |
- void OnClientOAuthSuccess(const ClientOAuthResult& result) override; |
- void OnClientOAuthFailure(const GoogleServiceAuthError& error) |
- override; |
- |
- GaiaAuthFetcher gaia_auth_fetcher_; |
+ // Overriden from SigninOAuthHelper::Consumer. |
+ void OnSigninOAuthInformationAvailable( |
+ const std::string& email, |
+ const std::string& display_email, |
+ const std::string& refresh_token) override; |
+ void OnSigninOAuthInformationFailure( |
+ const GoogleServiceAuthError& error) override; |
+ |
+ SigninOAuthHelper signin_oauth_helper_; |
base::WeakPtr<InlineLoginHandlerImpl> handler_; |
Profile* profile_; |
GURL current_url_; |
std::string email_; |
- std::string gaia_id_; |
std::string password_; |
std::string session_index_; |
bool choose_what_to_sync_; |
@@ -86,29 +87,29 @@ |
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, |
bool choose_what_to_sync, |
bool confirm_untrusted_signin) |
- : gaia_auth_fetcher_(this, GaiaConstants::kChromeSource, getter), |
+ : signin_oauth_helper_(getter, session_index, signin_scoped_device_id, |
+ this), |
handler_(handler), |
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), |
confirm_untrusted_signin_(confirm_untrusted_signin) { |
DCHECK(profile_); |
DCHECK(!email_.empty()); |
- gaia_auth_fetcher_.StartCookieForOAuthLoginTokenExchangeWithDeviceId( |
- session_index, signin_scoped_device_id); |
-} |
- |
-void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) { |
+} |
+ |
+void InlineSigninHelper::OnSigninOAuthInformationAvailable( |
+ const std::string& email, |
+ const std::string& display_email, |
+ const std::string& refresh_token) { |
content::WebContents* contents = NULL; |
Browser* browser = NULL; |
if (handler_) { |
@@ -120,19 +121,11 @@ |
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_); |
- |
signin::Source source = signin::GetSourceForPromoURL(current_url_); |
std::string primary_email = |
SigninManagerFactory::GetForProfile(profile_)->GetAuthenticatedUsername(); |
- if (gaia::AreEmailsSame(email_, primary_email) && |
+ if (gaia::AreEmailsSame(email, primary_email) && |
source == signin::SOURCE_REAUTH && |
switches::IsNewProfileManagement()) { |
chrome::SetLocalAuthCredentials(profile_, password_); |
@@ -140,8 +133,14 @@ |
if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || |
source == signin::SOURCE_REAUTH) { |
+ // TODO(rogerta): the javascript code will need to pass in the gaia-id |
+ // of the account instead of the email when chrome uses gaia-id as key. |
+ DCHECK_EQ(AccountTrackerService::MIGRATION_NOT_STARTED, |
+ AccountTrackerServiceFactory::GetForProfile(profile_)-> |
+ GetMigrationState()); |
+ const std::string account_id = gaia::CanonicalizeEmail(email); |
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> |
- UpdateCredentials(account_id, result.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 |
@@ -193,7 +192,7 @@ |
bool start_signin = |
!OneClickSigninHelper::HandleCrossAccountError( |
profile_, "", |
- email_, password_, result.refresh_token, |
+ email, password_, refresh_token, |
OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT, |
source, start_mode, |
base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, |
@@ -203,7 +202,7 @@ |
// OneClickSigninSyncStarter will delete itself once the job is done. |
new OneClickSigninSyncStarter( |
profile_, browser, |
- account_id, password_, result.refresh_token, |
+ email, password_, refresh_token, |
start_mode, |
contents, |
confirmation_required, |
@@ -215,7 +214,7 @@ |
base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
} |
-void InlineSigninHelper::OnClientOAuthFailure( |
+void InlineSigninHelper::OnSigninOAuthInformationFailure( |
const GoogleServiceAuthError& error) { |
if (handler_) |
handler_->HandleLoginError(error.ToString()); |
@@ -312,11 +311,6 @@ |
base::string16 password_string16; |
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 |
@@ -396,7 +390,7 @@ |
// InlineSigninHelper will delete itself. |
new InlineSigninHelper(GetWeakPtr(), partition->GetURLRequestContext(), |
Profile::FromWebUI(web_ui()), current_url, |
- email, gaia_id, password, session_index, |
+ email, password, session_index, |
signin_scoped_device_id, choose_what_to_sync, |
confirm_untrusted_signin_); |