Chromium Code Reviews| 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 d9ed6882a2324458d01520760ef12797b0cd1eb0..632dd5f7302c4e018ac7c8088510e704e9144bd3 100644 |
| --- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc |
| +++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc |
| @@ -48,7 +48,8 @@ |
| namespace { |
| -class InlineSigninHelper : public GaiaAuthConsumer { |
| +class InlineSigninHelper : public GaiaAuthConsumer, |
| + public MergeSessionHelper::Observer { |
| public: |
| InlineSigninHelper( |
| base::WeakPtr<InlineLoginHandlerImpl> handler, |
| @@ -69,6 +70,10 @@ class InlineSigninHelper : public GaiaAuthConsumer { |
| void OnClientOAuthFailure(const GoogleServiceAuthError& error) |
| override; |
| + // Overridden from MergeSessionHelper::Observer. |
| + void MergeSessionCompleted(const std::string& account_id, |
| + const GoogleServiceAuthError& error) override; |
| + |
| GaiaAuthFetcher gaia_auth_fetcher_; |
| base::WeakPtr<InlineLoginHandlerImpl> handler_; |
| Profile* profile_; |
| @@ -79,6 +84,8 @@ class InlineSigninHelper : public GaiaAuthConsumer { |
| std::string session_index_; |
| bool choose_what_to_sync_; |
| bool confirm_untrusted_signin_; |
| + // Helper to merge signed in account into the content area. |
| + scoped_ptr<MergeSessionHelper> merge_session_helper_; |
| DISALLOW_COPY_AND_ASSIGN(InlineSigninHelper); |
| }; |
| @@ -145,8 +152,9 @@ void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) { |
| if (source == signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || |
| source == signin_metrics::SOURCE_REAUTH) { |
| - ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> |
| - UpdateCredentials(account_id, result.refresh_token); |
| + ProfileOAuth2TokenService* token_service = |
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
| + token_service->UpdateCredentials(account_id, result.refresh_token); |
| if (signin::IsAutoCloseEnabledInURL(current_url_)) { |
| // Close the gaia sign in tab via a task to make sure we aren't in the |
| @@ -157,6 +165,17 @@ void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) { |
| handler_, |
| signin::ShouldShowAccountManagement(current_url_))); |
| } |
| + |
| + SigninClient* signin_client = |
| + ChromeSigninClientFactory::GetForProfile(profile_); |
| + if (signin_client->ShouldMergeSigninCredentialsIntoCookieJar()) { |
| + merge_session_helper_.reset(new MergeSessionHelper( |
| + token_service, GaiaConstants::kChromeSource, |
| + signin_client->GetURLRequestContext(), NULL)); |
| + merge_session_helper_->LogIn(account_id); |
| + } else { |
| + base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| + } |
|
Roger Tawa OOO till Jul 10th
2015/02/12 14:54:38
As discussed offline, it would be better to refact
Mike Lerman
2015/02/13 19:17:06
Done.
|
| } else { |
| ProfileSyncService* sync_service = |
| ProfileSyncServiceFactory::GetForProfile(profile_); |
| @@ -214,9 +233,8 @@ void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) { |
| signin::GetNextPageURLForPromoURL(current_url_), |
| base::Bind(&InlineLoginHandlerImpl::SyncStarterCallback, handler_)); |
| } |
| + base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| } |
| - |
| - base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| } |
| void InlineSigninHelper::OnClientOAuthFailure( |
| @@ -231,6 +249,12 @@ void InlineSigninHelper::OnClientOAuthFailure( |
| base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| } |
| +void InlineSigninHelper::MergeSessionCompleted( |
| + const std::string& account_id, |
| + const GoogleServiceAuthError& error) { |
| + base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| +} |
| + |
| } // namespace |
| InlineLoginHandlerImpl::InlineLoginHandlerImpl() |