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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 268293002: Revert of Start session fail causes restart chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void UserProfileInitialized(Profile* user_profile); 193 void UserProfileInitialized(Profile* user_profile);
194 194
195 // Callback for Profile::CREATE_STATUS_INITIALIZED profile state for an OTR 195 // Callback for Profile::CREATE_STATUS_INITIALIZED profile state for an OTR
196 // login. 196 // login.
197 void OTRProfileInitialized(Profile* user_profile); 197 void OTRProfileInitialized(Profile* user_profile);
198 198
199 // Callback to resume profile creation after transferring auth data from 199 // Callback to resume profile creation after transferring auth data from
200 // the authentication profile. 200 // the authentication profile.
201 void CompleteProfileCreate(Profile* user_profile); 201 void CompleteProfileCreate(Profile* user_profile);
202 202
203 // Callback to resume profile preparing after start session.
204 void OnSessionStarted(const UserContext& user_context,
205 const std::string& display_email,
206 bool has_cookies,
207 LoginUtils::Delegate* delegate,
208 bool success);
209
210 // Complete profile preparation with having active session.
211 void CompletePrepareProfileWithActiveSession(const UserContext& user_context,
212 const std::string& display_email,
213 bool has_cookies,
214 LoginUtils::Delegate* delegate);
215
216 // Finalized profile preparation. 203 // Finalized profile preparation.
217 void FinalizePrepareProfile(Profile* user_profile); 204 void FinalizePrepareProfile(Profile* user_profile);
218 205
219 // Initializes member variables needed for session restore process via 206 // Initializes member variables needed for session restore process via
220 // OAuthLoginManager. 207 // OAuthLoginManager.
221 void InitSessionRestoreStrategy(); 208 void InitSessionRestoreStrategy();
222 209
223 // Restores GAIA auth cookies for the created user profile from OAuth2 token. 210 // Restores GAIA auth cookies for the created user profile from OAuth2 token.
224 void RestoreAuthSession(Profile* user_profile, 211 void RestoreAuthSession(Profile* user_profile,
225 bool restore_from_auth_cookies); 212 bool restore_from_auth_cookies);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 bool has_cookies, 393 bool has_cookies,
407 bool has_active_session, 394 bool has_active_session,
408 LoginUtils::Delegate* delegate) { 395 LoginUtils::Delegate* delegate) {
409 BootTimesLoader* btl = BootTimesLoader::Get(); 396 BootTimesLoader* btl = BootTimesLoader::Get();
410 397
411 VLOG(1) << "Completing login for " << user_context.username; 398 VLOG(1) << "Completing login for " << user_context.username;
412 399
413 if (!has_active_session) { 400 if (!has_active_session) {
414 btl->AddLoginTimeMarker("StartSession-Start", false); 401 btl->AddLoginTimeMarker("StartSession-Start", false);
415 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( 402 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession(
416 user_context.username, 403 user_context.username);
417 base::Bind(&LoginUtilsImpl::OnSessionStarted, 404 btl->AddLoginTimeMarker("StartSession-End", false);
418 AsWeakPtr(),
419 user_context,
420 display_email,
421 has_cookies,
422 delegate));
423 return;
424 } 405 }
425 CompletePrepareProfileWithActiveSession(
426 user_context, display_email, has_cookies, delegate);
427 }
428 406
429 void LoginUtilsImpl::OnSessionStarted(const UserContext& user_context,
430 const std::string& display_email,
431 bool has_cookies,
432 LoginUtils::Delegate* delegate,
433 bool success) {
434 BootTimesLoader* btl = BootTimesLoader::Get();
435 btl->AddLoginTimeMarker("StartSession-End", false);
436
437 if (!success) {
438 LOG(ERROR) << "StartSession failed";
439 chrome::AttemptUserExit();
440 return;
441 }
442 CompletePrepareProfileWithActiveSession(
443 user_context, display_email, has_cookies, delegate);
444 }
445
446 void LoginUtilsImpl::CompletePrepareProfileWithActiveSession(
447 const UserContext& user_context,
448 const std::string& display_email,
449 bool has_cookies,
450 LoginUtils::Delegate* delegate) {
451 BootTimesLoader* btl = BootTimesLoader::Get();
452 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); 407 btl->AddLoginTimeMarker("UserLoggedIn-Start", false);
453 UserManager* user_manager = UserManager::Get(); 408 UserManager* user_manager = UserManager::Get();
454 user_manager->UserLoggedIn(user_context.username, 409 user_manager->UserLoggedIn(user_context.username,
455 user_context.username_hash, 410 user_context.username_hash,
456 false); 411 false);
457 btl->AddLoginTimeMarker("UserLoggedIn-End", false); 412 btl->AddLoginTimeMarker("UserLoggedIn-End", false);
458 413
459 // Switch log file as soon as possible. 414 // Switch log file as soon as possible.
460 if (base::SysInfo::IsRunningOnChromeOS()) 415 if (base::SysInfo::IsRunningOnChromeOS())
461 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess())); 416 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess()));
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 CrosSettings* cros_settings = CrosSettings::Get(); 957 CrosSettings* cros_settings = CrosSettings::Get();
1003 bool allow_new_user = false; 958 bool allow_new_user = false;
1004 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 959 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
1005 if (allow_new_user) 960 if (allow_new_user)
1006 return true; 961 return true;
1007 return cros_settings->FindEmailInList( 962 return cros_settings->FindEmailInList(
1008 kAccountsPrefUsers, username, wildcard_match); 963 kAccountsPrefUsers, username, wildcard_match);
1009 } 964 }
1010 965
1011 } // namespace chromeos 966 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698