OLD | NEW |
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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 const CommandLine& base_command_line, | 246 const CommandLine& base_command_line, |
247 CommandLine *command_line) OVERRIDE; | 247 CommandLine *command_line) OVERRIDE; |
248 | 248 |
249 private: | 249 private: |
250 // Restarts OAuth session authentication check. | 250 // Restarts OAuth session authentication check. |
251 void KickStartAuthentication(Profile* profile); | 251 void KickStartAuthentication(Profile* profile); |
252 | 252 |
253 // Check user's profile for kApplicationLocale setting. | 253 // Check user's profile for kApplicationLocale setting. |
254 void RespectLocalePreference(Profile* pref); | 254 void RespectLocalePreference(Profile* pref); |
255 | 255 |
256 // Initializes basic preferences for newly created profile. | 256 // Callback for Profile::CREATE_STATUS_CREATED profile state. |
| 257 // Initializes basic preferences for newly created profile. Any other |
| 258 // early profile initialization that needs to happen before |
| 259 // ProfileManager::DoFinalInit() gets called is done here. |
257 void InitProfilePreferences(Profile* user_profile); | 260 void InitProfilePreferences(Profile* user_profile); |
258 | 261 |
259 // Callback for asynchronous profile creation. | 262 // Callback for asynchronous profile creation. |
260 void OnProfileCreated(Profile* profile, | 263 void OnProfileCreated(Profile* profile, |
261 Profile::CreateStatus status); | 264 Profile::CreateStatus status); |
262 | 265 |
| 266 // Callback for Profile::CREATE_STATUS_INITIALIZED profile state. |
| 267 // Profile is created, extensions and promo resources are initialized. |
| 268 void UserProfileInitialized(Profile* user_profile); |
| 269 |
263 // Callback to resume profile creation after transferring auth data from | 270 // Callback to resume profile creation after transferring auth data from |
264 // the authentication profile. | 271 // the authentication profile. |
265 void CompleteProfileCreate(Profile* user_profile); | 272 void CompleteProfileCreate(Profile* user_profile); |
266 | 273 |
267 // Finalized profile preparation. | 274 // Finalized profile preparation. |
268 void FinalizePrepareProfile(Profile* user_profile); | 275 void FinalizePrepareProfile(Profile* user_profile); |
269 | 276 |
270 // Restores GAIA auth cookies for the created user profile from OAuth2 token. | 277 // Restores GAIA auth cookies for the created user profile from OAuth2 token. |
271 void RestoreAuthSession(Profile* user_profile, | 278 void RestoreAuthSession(Profile* user_profile, |
272 bool restore_from_auth_cookies); | 279 bool restore_from_auth_cookies); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 | 455 |
449 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { | 456 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { |
450 if (delegate_ == delegate) | 457 if (delegate_ == delegate) |
451 delegate_ = NULL; | 458 delegate_ = NULL; |
452 } | 459 } |
453 | 460 |
454 void LoginUtilsImpl::InitProfilePreferences(Profile* user_profile) { | 461 void LoginUtilsImpl::InitProfilePreferences(Profile* user_profile) { |
455 if (UserManager::Get()->IsCurrentUserNew()) | 462 if (UserManager::Get()->IsCurrentUserNew()) |
456 SetFirstLoginPrefs(user_profile->GetPrefs()); | 463 SetFirstLoginPrefs(user_profile->GetPrefs()); |
457 | 464 |
458 if (!UserManager::Get()->IsLoggedInAsLocallyManagedUser()) { | 465 if (UserManager::Get()->IsLoggedInAsLocallyManagedUser()) { |
| 466 user_profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true); |
| 467 } else { |
459 // Make sure that the google service username is properly set (we do this | 468 // Make sure that the google service username is properly set (we do this |
460 // on every sign in, not just the first login, to deal with existing | 469 // on every sign in, not just the first login, to deal with existing |
461 // profiles that might not have it set yet). | 470 // profiles that might not have it set yet). |
462 StringPrefMember google_services_username; | 471 StringPrefMember google_services_username; |
463 google_services_username.Init(prefs::kGoogleServicesUsername, | 472 google_services_username.Init(prefs::kGoogleServicesUsername, |
464 user_profile->GetPrefs()); | 473 user_profile->GetPrefs()); |
465 google_services_username.SetValue( | 474 google_services_username.SetValue( |
466 UserManager::Get()->GetLoggedInUser()->display_email()); | 475 UserManager::Get()->GetLoggedInUser()->display_email()); |
467 } | 476 } |
468 | 477 |
(...skipping 16 matching lines...) Expand all Loading... |
485 RespectLocalePreference(user_profile); | 494 RespectLocalePreference(user_profile); |
486 } | 495 } |
487 | 496 |
488 void LoginUtilsImpl::OnProfileCreated( | 497 void LoginUtilsImpl::OnProfileCreated( |
489 Profile* user_profile, | 498 Profile* user_profile, |
490 Profile::CreateStatus status) { | 499 Profile::CreateStatus status) { |
491 CHECK(user_profile); | 500 CHECK(user_profile); |
492 | 501 |
493 switch (status) { | 502 switch (status) { |
494 case Profile::CREATE_STATUS_INITIALIZED: | 503 case Profile::CREATE_STATUS_INITIALIZED: |
| 504 UserProfileInitialized(user_profile); |
495 break; | 505 break; |
496 case Profile::CREATE_STATUS_CREATED: { | 506 case Profile::CREATE_STATUS_CREATED: |
497 InitProfilePreferences(user_profile); | 507 InitProfilePreferences(user_profile); |
498 return; | 508 break; |
499 } | |
500 case Profile::CREATE_STATUS_FAIL: | 509 case Profile::CREATE_STATUS_FAIL: |
501 default: | 510 default: |
502 NOTREACHED(); | 511 NOTREACHED(); |
503 return; | 512 break; |
504 } | 513 } |
| 514 } |
505 | 515 |
| 516 void LoginUtilsImpl::UserProfileInitialized(Profile* user_profile) { |
506 BootTimesLoader* btl = BootTimesLoader::Get(); | 517 BootTimesLoader* btl = BootTimesLoader::Get(); |
507 btl->AddLoginTimeMarker("UserProfileGotten", false); | 518 btl->AddLoginTimeMarker("UserProfileGotten", false); |
508 | 519 |
509 if (using_oauth_) { | 520 if (using_oauth_) { |
510 // Transfer proxy authentication cache, cookies (optionally) and server | 521 // Transfer proxy authentication cache, cookies (optionally) and server |
511 // bound certs from the profile that was used for authentication. This | 522 // bound certs from the profile that was used for authentication. This |
512 // profile contains cookies that auth extension should have already put in | 523 // profile contains cookies that auth extension should have already put in |
513 // place that will ensure that the newly created session is authenticated | 524 // place that will ensure that the newly created session is authenticated |
514 // for the websites that work with the used authentication schema. | 525 // for the websites that work with the used authentication schema. |
515 ProfileAuthData::Transfer(authenticator_->authentication_profile(), | 526 ProfileAuthData::Transfer(authenticator_->authentication_profile(), |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1055 bool LoginUtils::IsWhitelisted(const std::string& username) { |
1045 CrosSettings* cros_settings = CrosSettings::Get(); | 1056 CrosSettings* cros_settings = CrosSettings::Get(); |
1046 bool allow_new_user = false; | 1057 bool allow_new_user = false; |
1047 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1058 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
1048 if (allow_new_user) | 1059 if (allow_new_user) |
1049 return true; | 1060 return true; |
1050 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1061 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
1051 } | 1062 } |
1052 | 1063 |
1053 } // namespace chromeos | 1064 } // namespace chromeos |
OLD | NEW |