Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Unified Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 1079083002: [cros New-GAIA] Webview login and new GAIA endpoint enabled by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix saml test Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/session/user_session_manager.cc
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc
index 31395c2b73cb07d7f854207cc1e38720eb50e920..50f75fb68cd713c08ddc28c90c3147a267af8aac 100644
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc
@@ -997,14 +997,29 @@ void UserSessionManager::UserProfileInitialized(Profile* profile,
// empty if |transfer_saml_auth_cookies_on_subsequent_login| is true.
const bool transfer_auth_cookies_and_channel_ids_on_first_login =
has_auth_cookies_;
- ProfileAuthData::Transfer(
- GetAuthRequestContext(),
- profile->GetRequestContext(),
- transfer_auth_cookies_and_channel_ids_on_first_login,
- transfer_saml_auth_cookies_on_subsequent_login,
- base::Bind(&UserSessionManager::CompleteProfileCreateAfterAuthTransfer,
- AsWeakPtr(),
- profile));
+
+ net::URLRequestContextGetter* auth_request_context =
+ GetAuthRequestContext();
+
+ // Authentication request context may be missing especially if user didn't
+ // sign in using GAIA (webview) and webview didn't yet initialize.
+ if (auth_request_context) {
+ ProfileAuthData::Transfer(
+ auth_request_context, profile->GetRequestContext(),
+ transfer_auth_cookies_and_channel_ids_on_first_login,
+ transfer_saml_auth_cookies_on_subsequent_login,
+ base::Bind(
+ &UserSessionManager::CompleteProfileCreateAfterAuthTransfer,
+ AsWeakPtr(), profile));
+ } else {
+ // We need to post task so that OnProfileCreated() caller sends out
+ // NOTIFICATION_PROFILE_CREATED which marks user profile as initialized.
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &UserSessionManager::CompleteProfileCreateAfterAuthTransfer,
+ AsWeakPtr(), profile));
+ }
return;
}
@@ -1231,9 +1246,18 @@ void UserSessionManager::RestoreAuthSessionImpl(
OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile);
login_manager->AddObserver(this);
- login_manager->RestoreSession(
- GetAuthRequestContext(), session_restore_strategy_,
- user_context_.GetRefreshToken(), user_context_.GetAuthCode());
+ net::URLRequestContextGetter* auth_request_context = GetAuthRequestContext();
+
+ // Authentication request context may not be available if user was not
+ // signing in with GAIA webview (i.e. webview instance hasn't been
+ // initialized at all). Use fallback request context.
+ if (!auth_request_context) {
+ auth_request_context =
+ authenticator_->authentication_context()->GetRequestContext();
+ }
+ login_manager->RestoreSession(auth_request_context, session_restore_strategy_,
+ user_context_.GetRefreshToken(),
+ user_context_.GetAuthCode());
}
void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) {
@@ -1422,13 +1446,15 @@ void UserSessionManager::UpdateEasyUnlockKeys(const UserContext& user_context) {
net::URLRequestContextGetter*
UserSessionManager::GetAuthRequestContext() const {
- net::URLRequestContextGetter* auth_request_context = NULL;
+ net::URLRequestContextGetter* auth_request_context = nullptr;
if (StartupUtils::IsWebviewSigninEnabled()) {
// Webview uses different partition storage than iframe. We need to get
// cookies from the right storage for url request to get auth token into
// session.
- auth_request_context = login::GetSigninPartition()->GetURLRequestContext();
+ content::StoragePartition* signin_partition = login::GetSigninPartition();
+ if (signin_partition)
+ auth_request_context = signin_partition->GetURLRequestContext();
} else if (authenticator_.get() && authenticator_->authentication_context()) {
auth_request_context =
authenticator_->authentication_context()->GetRequestContext();
« no previous file with comments | « chrome/browser/chromeos/login/saml/saml_browsertest.cc ('k') | chrome/browser/chromeos/login/signin/oauth2_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698