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

Side by Side Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 1083683003: Speculative revert by sheriff (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed an unrelated commit that had accidentally slipped in. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 // authentication to the user's profile. The proxy authentication state is 990 // authentication to the user's profile. The proxy authentication state is
991 // transferred unconditionally. If the user authenticated via an auth 991 // transferred unconditionally. If the user authenticated via an auth
992 // extension, authentication cookies and channel IDs will be transferred as 992 // extension, authentication cookies and channel IDs will be transferred as
993 // well when the user's cookie jar is empty. If the cookie jar is not empty, 993 // well when the user's cookie jar is empty. If the cookie jar is not empty,
994 // the authentication states in the browser context and the user's profile 994 // the authentication states in the browser context and the user's profile
995 // must be merged using /MergeSession instead. Authentication cookies set by 995 // must be merged using /MergeSession instead. Authentication cookies set by
996 // a SAML IdP will also be transferred when the user's cookie jar is not 996 // a SAML IdP will also be transferred when the user's cookie jar is not
997 // empty if |transfer_saml_auth_cookies_on_subsequent_login| is true. 997 // empty if |transfer_saml_auth_cookies_on_subsequent_login| is true.
998 const bool transfer_auth_cookies_and_channel_ids_on_first_login = 998 const bool transfer_auth_cookies_and_channel_ids_on_first_login =
999 has_auth_cookies_; 999 has_auth_cookies_;
1000 1000 ProfileAuthData::Transfer(
1001 net::URLRequestContextGetter* auth_request_context = 1001 GetAuthRequestContext(),
1002 GetAuthRequestContext(); 1002 profile->GetRequestContext(),
1003 1003 transfer_auth_cookies_and_channel_ids_on_first_login,
1004 // Authentication request context may be missing especially if user didn't 1004 transfer_saml_auth_cookies_on_subsequent_login,
1005 // sign in using GAIA (webview) and webview didn't yet initialize. 1005 base::Bind(&UserSessionManager::CompleteProfileCreateAfterAuthTransfer,
1006 if (auth_request_context) { 1006 AsWeakPtr(),
1007 ProfileAuthData::Transfer( 1007 profile));
1008 auth_request_context, profile->GetRequestContext(),
1009 transfer_auth_cookies_and_channel_ids_on_first_login,
1010 transfer_saml_auth_cookies_on_subsequent_login,
1011 base::Bind(
1012 &UserSessionManager::CompleteProfileCreateAfterAuthTransfer,
1013 AsWeakPtr(), profile));
1014 } else {
1015 // We need to post task so that OnProfileCreated() caller sends out
1016 // NOTIFICATION_PROFILE_CREATED which marks user profile as initialized.
1017 base::MessageLoopProxy::current()->PostTask(
1018 FROM_HERE,
1019 base::Bind(
1020 &UserSessionManager::CompleteProfileCreateAfterAuthTransfer,
1021 AsWeakPtr(), profile));
1022 }
1023 return; 1008 return;
1024 } 1009 }
1025 1010
1026 FinalizePrepareProfile(profile); 1011 FinalizePrepareProfile(profile);
1027 } 1012 }
1028 1013
1029 void UserSessionManager::CompleteProfileCreateAfterAuthTransfer( 1014 void UserSessionManager::CompleteProfileCreateAfterAuthTransfer(
1030 Profile* profile) { 1015 Profile* profile) {
1031 RestoreAuthSessionImpl(profile, has_auth_cookies_); 1016 RestoreAuthSessionImpl(profile, has_auth_cookies_);
1032 FinalizePrepareProfile(profile); 1017 FinalizePrepareProfile(profile);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 1224
1240 exit_after_session_restore_ = false; 1225 exit_after_session_restore_ = false;
1241 1226
1242 // Remove legacy OAuth1 token if we have one. If it's valid, we should already 1227 // Remove legacy OAuth1 token if we have one. If it's valid, we should already
1243 // have OAuth2 refresh token in OAuth2TokenService that could be used to 1228 // have OAuth2 refresh token in OAuth2TokenService that could be used to
1244 // retrieve all other tokens and user_context. 1229 // retrieve all other tokens and user_context.
1245 OAuth2LoginManager* login_manager = 1230 OAuth2LoginManager* login_manager =
1246 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile); 1231 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile);
1247 login_manager->AddObserver(this); 1232 login_manager->AddObserver(this);
1248 1233
1249 net::URLRequestContextGetter* auth_request_context = GetAuthRequestContext(); 1234 login_manager->RestoreSession(
1250 1235 GetAuthRequestContext(), session_restore_strategy_,
1251 // Authentication request context may not be available if user was not 1236 user_context_.GetRefreshToken(), user_context_.GetAuthCode());
1252 // signing in with GAIA webview (i.e. webview instance hasn't been
1253 // initialized at all). Use fallback request context.
1254 if (!auth_request_context) {
1255 auth_request_context =
1256 authenticator_->authentication_context()->GetRequestContext();
1257 }
1258 login_manager->RestoreSession(auth_request_context, session_restore_strategy_,
1259 user_context_.GetRefreshToken(),
1260 user_context_.GetAuthCode());
1261 } 1237 }
1262 1238
1263 void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) { 1239 void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) {
1264 #if defined(ENABLE_RLZ) 1240 #if defined(ENABLE_RLZ)
1265 PrefService* local_state = g_browser_process->local_state(); 1241 PrefService* local_state = g_browser_process->local_state();
1266 if (disabled) { 1242 if (disabled) {
1267 // Empty brand code means an organic install (no RLZ pings are sent). 1243 // Empty brand code means an organic install (no RLZ pings are sent).
1268 google_brand::chromeos::ClearBrandForCurrentSession(); 1244 google_brand::chromeos::ClearBrandForCurrentSession();
1269 } 1245 }
1270 if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) { 1246 if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager(); 1415 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager();
1440 running_easy_unlock_key_ops_ = true; 1416 running_easy_unlock_key_ops_ = true;
1441 key_manager->RefreshKeys( 1417 key_manager->RefreshKeys(
1442 user_context, *device_list, 1418 user_context, *device_list,
1443 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(), 1419 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(),
1444 user_context.GetUserID())); 1420 user_context.GetUserID()));
1445 } 1421 }
1446 1422
1447 net::URLRequestContextGetter* 1423 net::URLRequestContextGetter*
1448 UserSessionManager::GetAuthRequestContext() const { 1424 UserSessionManager::GetAuthRequestContext() const {
1449 net::URLRequestContextGetter* auth_request_context = nullptr; 1425 net::URLRequestContextGetter* auth_request_context = NULL;
1450 1426
1451 if (StartupUtils::IsWebviewSigninEnabled()) { 1427 if (StartupUtils::IsWebviewSigninEnabled()) {
1452 // Webview uses different partition storage than iframe. We need to get 1428 // Webview uses different partition storage than iframe. We need to get
1453 // cookies from the right storage for url request to get auth token into 1429 // cookies from the right storage for url request to get auth token into
1454 // session. 1430 // session.
1455 content::StoragePartition* signin_partition = login::GetSigninPartition(); 1431 auth_request_context = login::GetSigninPartition()->GetURLRequestContext();
1456 if (signin_partition)
1457 auth_request_context = signin_partition->GetURLRequestContext();
1458 } else if (authenticator_.get() && authenticator_->authentication_context()) { 1432 } else if (authenticator_.get() && authenticator_->authentication_context()) {
1459 auth_request_context = 1433 auth_request_context =
1460 authenticator_->authentication_context()->GetRequestContext(); 1434 authenticator_->authentication_context()->GetRequestContext();
1461 } 1435 }
1462 return auth_request_context; 1436 return auth_request_context;
1463 } 1437 }
1464 1438
1465 void UserSessionManager::AttemptRestart(Profile* profile) { 1439 void UserSessionManager::AttemptRestart(Profile* profile) {
1466 if (CheckEasyUnlockKeyOps(base::Bind(&UserSessionManager::AttemptRestart, 1440 if (CheckEasyUnlockKeyOps(base::Bind(&UserSessionManager::AttemptRestart,
1467 AsWeakPtr(), profile))) { 1441 AsWeakPtr(), profile))) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 if (is_enterprise_managed) 1623 if (is_enterprise_managed)
1650 display = USER_PODS_DISPLAY_DISABLED_MANAGED; 1624 display = USER_PODS_DISPLAY_DISABLED_MANAGED;
1651 else 1625 else
1652 display = USER_PODS_DISPLAY_DISABLED_REGULAR; 1626 display = USER_PODS_DISPLAY_DISABLED_REGULAR;
1653 } 1627 }
1654 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display, 1628 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display,
1655 NUM_USER_PODS_DISPLAY); 1629 NUM_USER_PODS_DISPLAY);
1656 } 1630 }
1657 1631
1658 } // namespace chromeos 1632 } // namespace chromeos
OLDNEW
« 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