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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 FinalizePrepareProfile(ProfileManager::GetDefaultProfile()); | 537 FinalizePrepareProfile(ProfileManager::GetDefaultProfile()); |
538 } | 538 } |
539 | 539 |
540 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) { | 540 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) { |
541 RestoreAuthSession(user_profile, has_web_auth_cookies_); | 541 RestoreAuthSession(user_profile, has_web_auth_cookies_); |
542 FinalizePrepareProfile(user_profile); | 542 FinalizePrepareProfile(user_profile); |
543 } | 543 } |
544 | 544 |
545 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, | 545 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, |
546 bool restore_from_auth_cookies) { | 546 bool restore_from_auth_cookies) { |
547 DCHECK(authenticator_ || !restore_from_auth_cookies); | 547 CHECK((authenticator_ && authenticator_->authentication_profile()) || |
| 548 !restore_from_auth_cookies); |
| 549 if (!login_manager_.get()) |
| 550 return; |
| 551 |
548 // Remove legacy OAuth1 token if we have one. If it's valid, we should already | 552 // Remove legacy OAuth1 token if we have one. If it's valid, we should already |
549 // have OAuth2 refresh token in TokenService that could be used to retrieve | 553 // have OAuth2 refresh token in TokenService that could be used to retrieve |
550 // all other tokens and credentials. | 554 // all other tokens and credentials. |
551 login_manager_->RestoreSession( | 555 login_manager_->RestoreSession( |
552 user_profile, | 556 user_profile, |
553 authenticator_ ? | 557 authenticator_ && authenticator_->authentication_profile() ? |
554 authenticator_->authentication_profile()->GetRequestContext() : | 558 authenticator_->authentication_profile()->GetRequestContext() : |
555 NULL, | 559 NULL, |
556 restore_from_auth_cookies); | 560 restore_from_auth_cookies); |
557 } | 561 } |
558 | 562 |
559 void LoginUtilsImpl::FinalizePrepareProfile(Profile* user_profile) { | 563 void LoginUtilsImpl::FinalizePrepareProfile(Profile* user_profile) { |
560 BootTimesLoader* btl = BootTimesLoader::Get(); | 564 BootTimesLoader* btl = BootTimesLoader::Get(); |
561 // Own TPM device if, for any reason, it has not been done in EULA | 565 // Own TPM device if, for any reason, it has not been done in EULA |
562 // wizard screen. | 566 // wizard screen. |
563 CryptohomeLibrary* cryptohome = CrosLibrary::Get()->GetCryptohomeLibrary(); | 567 CryptohomeLibrary* cryptohome = CrosLibrary::Get()->GetCryptohomeLibrary(); |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1043 bool LoginUtils::IsWhitelisted(const std::string& username) { |
1040 CrosSettings* cros_settings = CrosSettings::Get(); | 1044 CrosSettings* cros_settings = CrosSettings::Get(); |
1041 bool allow_new_user = false; | 1045 bool allow_new_user = false; |
1042 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1046 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
1043 if (allow_new_user) | 1047 if (allow_new_user) |
1044 return true; | 1048 return true; |
1045 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1049 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
1046 } | 1050 } |
1047 | 1051 |
1048 } // namespace chromeos | 1052 } // namespace chromeos |
OLD | NEW |