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

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

Issue 228703004: Start session fail causes restart chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comments and rebase Created 6 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 (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
203 // Finalized profile preparation. 216 // Finalized profile preparation.
204 void FinalizePrepareProfile(Profile* user_profile); 217 void FinalizePrepareProfile(Profile* user_profile);
205 218
206 // Initializes member variables needed for session restore process via 219 // Initializes member variables needed for session restore process via
207 // OAuthLoginManager. 220 // OAuthLoginManager.
208 void InitSessionRestoreStrategy(); 221 void InitSessionRestoreStrategy();
209 222
210 // Restores GAIA auth cookies for the created user profile from OAuth2 token. 223 // Restores GAIA auth cookies for the created user profile from OAuth2 token.
211 void RestoreAuthSession(Profile* user_profile, 224 void RestoreAuthSession(Profile* user_profile,
212 bool restore_from_auth_cookies); 225 bool restore_from_auth_cookies);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 bool has_cookies, 406 bool has_cookies,
394 bool has_active_session, 407 bool has_active_session,
395 LoginUtils::Delegate* delegate) { 408 LoginUtils::Delegate* delegate) {
396 BootTimesLoader* btl = BootTimesLoader::Get(); 409 BootTimesLoader* btl = BootTimesLoader::Get();
397 410
398 VLOG(1) << "Completing login for " << user_context.username; 411 VLOG(1) << "Completing login for " << user_context.username;
399 412
400 if (!has_active_session) { 413 if (!has_active_session) {
401 btl->AddLoginTimeMarker("StartSession-Start", false); 414 btl->AddLoginTimeMarker("StartSession-Start", false);
402 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( 415 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession(
403 user_context.username); 416 user_context.username,
404 btl->AddLoginTimeMarker("StartSession-End", false); 417 base::Bind(&LoginUtilsImpl::OnSessionStarted,
418 AsWeakPtr(),
419 user_context,
420 display_email,
421 has_cookies,
422 delegate));
423 return;
405 } 424 }
425 CompletePrepareProfileWithActiveSession(
426 user_context, display_email, has_cookies, delegate);
427 }
406 428
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();
407 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); 452 btl->AddLoginTimeMarker("UserLoggedIn-Start", false);
408 UserManager* user_manager = UserManager::Get(); 453 UserManager* user_manager = UserManager::Get();
409 user_manager->UserLoggedIn(user_context.username, 454 user_manager->UserLoggedIn(user_context.username,
410 user_context.username_hash, 455 user_context.username_hash,
411 false); 456 false);
412 btl->AddLoginTimeMarker("UserLoggedIn-End", false); 457 btl->AddLoginTimeMarker("UserLoggedIn-End", false);
413 458
414 // Switch log file as soon as possible. 459 // Switch log file as soon as possible.
415 if (base::SysInfo::IsRunningOnChromeOS()) 460 if (base::SysInfo::IsRunningOnChromeOS())
416 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess())); 461 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess()));
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 CrosSettings* cros_settings = CrosSettings::Get(); 1002 CrosSettings* cros_settings = CrosSettings::Get();
958 bool allow_new_user = false; 1003 bool allow_new_user = false;
959 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 1004 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
960 if (allow_new_user) 1005 if (allow_new_user)
961 return true; 1006 return true;
962 return cros_settings->FindEmailInList( 1007 return cros_settings->FindEmailInList(
963 kAccountsPrefUsers, username, wildcard_match); 1008 kAccountsPrefUsers, username, wildcard_match);
964 } 1009 }
965 1010
966 } // namespace chromeos 1011 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698