| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; | 220 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; |
| 221 virtual scoped_refptr<Authenticator> CreateAuthenticator( | 221 virtual scoped_refptr<Authenticator> CreateAuthenticator( |
| 222 LoginStatusConsumer* consumer) OVERRIDE; | 222 LoginStatusConsumer* consumer) OVERRIDE; |
| 223 virtual void PrewarmAuthentication() OVERRIDE; | 223 virtual void PrewarmAuthentication() OVERRIDE; |
| 224 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; | 224 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; |
| 225 virtual void StopBackgroundFetchers() OVERRIDE; | 225 virtual void StopBackgroundFetchers() OVERRIDE; |
| 226 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; | 226 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; |
| 227 virtual void CompleteProfileCreate(Profile* user_profile) OVERRIDE; | 227 virtual void CompleteProfileCreate(Profile* user_profile) OVERRIDE; |
| 228 | 228 |
| 229 // OAuthLoginManager::Delegate overrides. | 229 // OAuthLoginManager::Delegate overrides. |
| 230 virtual void OnCompletedMergeSession() OVERRIDE; |
| 230 virtual void OnCompletedAuthentication(Profile* user_profile) OVERRIDE; | 231 virtual void OnCompletedAuthentication(Profile* user_profile) OVERRIDE; |
| 231 virtual void OnFoundStoredTokens() OVERRIDE; | 232 virtual void OnFoundStoredTokens() OVERRIDE; |
| 232 | 233 |
| 233 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. | 234 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. |
| 234 virtual void OnConnectionTypeChanged( | 235 virtual void OnConnectionTypeChanged( |
| 235 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 236 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 236 | 237 |
| 237 // content::NotificationObserver overrides. | 238 // content::NotificationObserver overrides. |
| 238 virtual void Observe(int type, | 239 virtual void Observe(int type, |
| 239 const content::NotificationSource& source, | 240 const content::NotificationSource& source, |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 } | 513 } |
| 513 | 514 |
| 514 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) { | 515 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) { |
| 515 RestoreAuthSession(user_profile, has_web_auth_cookies_); | 516 RestoreAuthSession(user_profile, has_web_auth_cookies_); |
| 516 FinalizePrepareProfile(user_profile); | 517 FinalizePrepareProfile(user_profile); |
| 517 } | 518 } |
| 518 | 519 |
| 519 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, | 520 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, |
| 520 bool restore_from_auth_cookies) { | 521 bool restore_from_auth_cookies) { |
| 521 DCHECK(authenticator_ || !restore_from_auth_cookies); | 522 DCHECK(authenticator_ || !restore_from_auth_cookies); |
| 523 UserManager::Get()->SetMergeSessionState( |
| 524 UserManager::MERGE_STATUS_IN_PROCESS); |
| 522 // Remove legacy OAuth1 token if we have one. If it's valid, we should already | 525 // Remove legacy OAuth1 token if we have one. If it's valid, we should already |
| 523 // have OAuth2 refresh token in TokenService that could be used to retrieve | 526 // have OAuth2 refresh token in TokenService that could be used to retrieve |
| 524 // all other tokens and credentials. | 527 // all other tokens and credentials. |
| 525 login_manager_->RestoreSession( | 528 login_manager_->RestoreSession( |
| 526 user_profile, | 529 user_profile, |
| 527 authenticator_ ? | 530 authenticator_ ? |
| 528 authenticator_->authentication_profile()->GetRequestContext() : | 531 authenticator_->authentication_profile()->GetRequestContext() : |
| 529 NULL, | 532 NULL, |
| 530 restore_from_auth_cookies); | 533 restore_from_auth_cookies); |
| 531 } | 534 } |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 } | 950 } |
| 948 | 951 |
| 949 void LoginUtilsImpl::StopBackgroundFetchers() { | 952 void LoginUtilsImpl::StopBackgroundFetchers() { |
| 950 login_manager_.reset(); | 953 login_manager_.reset(); |
| 951 } | 954 } |
| 952 | 955 |
| 953 void LoginUtilsImpl::OnCompletedAuthentication(Profile* user_profile) { | 956 void LoginUtilsImpl::OnCompletedAuthentication(Profile* user_profile) { |
| 954 StartSignedInServices(user_profile); | 957 StartSignedInServices(user_profile); |
| 955 } | 958 } |
| 956 | 959 |
| 960 void LoginUtilsImpl::OnCompletedMergeSession() { |
| 961 UserManager::Get()->SetMergeSessionState(UserManager::MERGE_STATUS_DONE); |
| 962 } |
| 963 |
| 957 void LoginUtilsImpl::OnFoundStoredTokens() { | 964 void LoginUtilsImpl::OnFoundStoredTokens() { |
| 958 // We don't need authenticator instance any more since its cookie jar | 965 // We don't need authenticator instance any more since its cookie jar |
| 959 // is not going to needed to mint OAuth tokens. Reset it so that | 966 // is not going to needed to mint OAuth tokens. Reset it so that |
| 960 // ScreenLocker would create a separate instance. | 967 // ScreenLocker would create a separate instance. |
| 961 authenticator_ = NULL; | 968 authenticator_ = NULL; |
| 962 } | 969 } |
| 963 | 970 |
| 964 void LoginUtilsImpl::OnConnectionTypeChanged( | 971 void LoginUtilsImpl::OnConnectionTypeChanged( |
| 965 net::NetworkChangeNotifier::ConnectionType type) { | 972 net::NetworkChangeNotifier::ConnectionType type) { |
| 966 if (!login_manager_.get()) | 973 if (!login_manager_.get()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1020 bool LoginUtils::IsWhitelisted(const std::string& username) { |
| 1014 CrosSettings* cros_settings = CrosSettings::Get(); | 1021 CrosSettings* cros_settings = CrosSettings::Get(); |
| 1015 bool allow_new_user = false; | 1022 bool allow_new_user = false; |
| 1016 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1023 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 1017 if (allow_new_user) | 1024 if (allow_new_user) |
| 1018 return true; | 1025 return true; |
| 1019 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1026 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
| 1020 } | 1027 } |
| 1021 | 1028 |
| 1022 } // namespace chromeos | 1029 } // namespace chromeos |
| OLD | NEW |