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

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 more browser tests 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void UserProfileInitialized(Profile* user_profile); 192 void UserProfileInitialized(Profile* user_profile);
193 193
194 // Callback for Profile::CREATE_STATUS_INITIALIZED profile state for an OTR 194 // Callback for Profile::CREATE_STATUS_INITIALIZED profile state for an OTR
195 // login. 195 // login.
196 void OTRProfileInitialized(Profile* user_profile); 196 void OTRProfileInitialized(Profile* user_profile);
197 197
198 // Callback to resume profile creation after transferring auth data from 198 // Callback to resume profile creation after transferring auth data from
199 // the authentication profile. 199 // the authentication profile.
200 void CompleteProfileCreate(Profile* user_profile); 200 void CompleteProfileCreate(Profile* user_profile);
201 201
202 // Callback to resume profile preparing after start session
Nikita (slow) 2014/04/18 05:22:59 nit: Add dot at the end, otherwise comment looks l
Roman Sorokin (ftl) 2014/04/22 08:28:47 Done.
203 void OnSessionStarted(const UserContext& user_context,
204 const std::string& display_email,
205 bool has_cookies,
206 LoginUtils::Delegate* delegate,
207 bool success);
208
209 // Complete profile preparation with having active session
Nikita (slow) 2014/04/18 05:22:59 nit: same here.
Roman Sorokin (ftl) 2014/04/22 08:28:47 Done.
210 void CompletePrepareProfileWithActiveSession(const UserContext& user_context,
211 const std::string& display_email,
212 bool has_cookies,
213 LoginUtils::Delegate* delegate);
214
202 // Finalized profile preparation. 215 // Finalized profile preparation.
203 void FinalizePrepareProfile(Profile* user_profile); 216 void FinalizePrepareProfile(Profile* user_profile);
204 217
205 // Initializes member variables needed for session restore process via 218 // Initializes member variables needed for session restore process via
206 // OAuthLoginManager. 219 // OAuthLoginManager.
207 void InitSessionRestoreStrategy(); 220 void InitSessionRestoreStrategy();
208 221
209 // Restores GAIA auth cookies for the created user profile from OAuth2 token. 222 // Restores GAIA auth cookies for the created user profile from OAuth2 token.
210 void RestoreAuthSession(Profile* user_profile, 223 void RestoreAuthSession(Profile* user_profile,
211 bool restore_from_auth_cookies); 224 bool restore_from_auth_cookies);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 bool has_cookies, 397 bool has_cookies,
385 bool has_active_session, 398 bool has_active_session,
386 LoginUtils::Delegate* delegate) { 399 LoginUtils::Delegate* delegate) {
387 BootTimesLoader* btl = BootTimesLoader::Get(); 400 BootTimesLoader* btl = BootTimesLoader::Get();
388 401
389 VLOG(1) << "Completing login for " << user_context.username; 402 VLOG(1) << "Completing login for " << user_context.username;
390 403
391 if (!has_active_session) { 404 if (!has_active_session) {
392 btl->AddLoginTimeMarker("StartSession-Start", false); 405 btl->AddLoginTimeMarker("StartSession-Start", false);
393 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( 406 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession(
394 user_context.username); 407 user_context.username,
395 btl->AddLoginTimeMarker("StartSession-End", false); 408 base::Bind(&LoginUtilsImpl::OnSessionStarted,
409 AsWeakPtr(),
410 user_context,
411 display_email,
412 has_cookies,
413 delegate));
414 return;
396 } 415 }
416 CompletePrepareProfileWithActiveSession(
417 user_context, display_email, has_cookies, delegate);
418 }
397 419
420 void LoginUtilsImpl::OnSessionStarted(const UserContext& user_context,
421 const std::string& display_email,
422 bool has_cookies,
423 LoginUtils::Delegate* delegate,
424 bool success) {
425 BootTimesLoader* btl = BootTimesLoader::Get();
426 btl->AddLoginTimeMarker("StartSession-End", false);
427
428 if (!success) {
429 LOG(ERROR) << "StartSession failed";
430 chrome::AttemptUserExit();
431 return;
432 }
433 CompletePrepareProfileWithActiveSession(
434 user_context, display_email, has_cookies, delegate);
435 }
436
437 void LoginUtilsImpl::CompletePrepareProfileWithActiveSession(
438 const UserContext& user_context,
439 const std::string& display_email,
440 bool has_cookies,
441 LoginUtils::Delegate* delegate) {
442 BootTimesLoader* btl = BootTimesLoader::Get();
398 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); 443 btl->AddLoginTimeMarker("UserLoggedIn-Start", false);
399 UserManager* user_manager = UserManager::Get(); 444 UserManager* user_manager = UserManager::Get();
400 user_manager->UserLoggedIn(user_context.username, 445 user_manager->UserLoggedIn(user_context.username,
401 user_context.username_hash, 446 user_context.username_hash,
402 false); 447 false);
403 btl->AddLoginTimeMarker("UserLoggedIn-End", false); 448 btl->AddLoginTimeMarker("UserLoggedIn-End", false);
404 449
405 // Switch log file as soon as possible. 450 // Switch log file as soon as possible.
406 if (base::SysInfo::IsRunningOnChromeOS()) 451 if (base::SysInfo::IsRunningOnChromeOS())
407 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess())); 452 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess()));
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 CrosSettings* cros_settings = CrosSettings::Get(); 993 CrosSettings* cros_settings = CrosSettings::Get();
949 bool allow_new_user = false; 994 bool allow_new_user = false;
950 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 995 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
951 if (allow_new_user) 996 if (allow_new_user)
952 return true; 997 return true;
953 return cros_settings->FindEmailInList( 998 return cros_settings->FindEmailInList(
954 kAccountsPrefUsers, username, wildcard_match); 999 kAccountsPrefUsers, username, wildcard_match);
955 } 1000 }
956 1001
957 } // namespace chromeos 1002 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698