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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; | 222 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; |
223 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; | 223 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; |
224 virtual scoped_refptr<Authenticator> CreateAuthenticator( | 224 virtual scoped_refptr<Authenticator> CreateAuthenticator( |
225 LoginStatusConsumer* consumer) OVERRIDE; | 225 LoginStatusConsumer* consumer) OVERRIDE; |
226 virtual void PrewarmAuthentication() OVERRIDE; | 226 virtual void PrewarmAuthentication() OVERRIDE; |
227 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; | 227 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; |
228 virtual void StopBackgroundFetchers() OVERRIDE; | 228 virtual void StopBackgroundFetchers() OVERRIDE; |
229 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; | 229 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; |
230 | 230 |
231 // OAuthLoginManager::Delegate overrides. | 231 // OAuthLoginManager::Delegate overrides. |
| 232 virtual void OnCompletedMergeSession() OVERRIDE; |
232 virtual void OnCompletedAuthentication(Profile* user_profile) OVERRIDE; | 233 virtual void OnCompletedAuthentication(Profile* user_profile) OVERRIDE; |
233 virtual void OnFoundStoredTokens() OVERRIDE; | 234 virtual void OnFoundStoredTokens() OVERRIDE; |
234 | 235 |
235 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. | 236 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. |
236 virtual void OnConnectionTypeChanged( | 237 virtual void OnConnectionTypeChanged( |
237 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 238 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
238 | 239 |
239 // content::NotificationObserver overrides. | 240 // content::NotificationObserver overrides. |
240 virtual void Observe(int type, | 241 virtual void Observe(int type, |
241 const content::NotificationSource& source, | 242 const content::NotificationSource& source, |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 FinalizePrepareProfile(user_profile); | 555 FinalizePrepareProfile(user_profile); |
555 } | 556 } |
556 | 557 |
557 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, | 558 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, |
558 bool restore_from_auth_cookies) { | 559 bool restore_from_auth_cookies) { |
559 CHECK((authenticator_ && authenticator_->authentication_profile()) || | 560 CHECK((authenticator_ && authenticator_->authentication_profile()) || |
560 !restore_from_auth_cookies); | 561 !restore_from_auth_cookies); |
561 if (!login_manager_.get()) | 562 if (!login_manager_.get()) |
562 return; | 563 return; |
563 | 564 |
| 565 UserManager::Get()->SetMergeSessionState( |
| 566 UserManager::MERGE_STATUS_IN_PROCESS); |
564 // Remove legacy OAuth1 token if we have one. If it's valid, we should already | 567 // Remove legacy OAuth1 token if we have one. If it's valid, we should already |
565 // have OAuth2 refresh token in TokenService that could be used to retrieve | 568 // have OAuth2 refresh token in TokenService that could be used to retrieve |
566 // all other tokens and credentials. | 569 // all other tokens and credentials. |
567 login_manager_->RestoreSession( | 570 login_manager_->RestoreSession( |
568 user_profile, | 571 user_profile, |
569 authenticator_ && authenticator_->authentication_profile() ? | 572 authenticator_ && authenticator_->authentication_profile() ? |
570 authenticator_->authentication_profile()->GetRequestContext() : | 573 authenticator_->authentication_profile()->GetRequestContext() : |
571 NULL, | 574 NULL, |
572 restore_from_auth_cookies); | 575 restore_from_auth_cookies); |
573 } | 576 } |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 } | 993 } |
991 | 994 |
992 void LoginUtilsImpl::StopBackgroundFetchers() { | 995 void LoginUtilsImpl::StopBackgroundFetchers() { |
993 login_manager_.reset(); | 996 login_manager_.reset(); |
994 } | 997 } |
995 | 998 |
996 void LoginUtilsImpl::OnCompletedAuthentication(Profile* user_profile) { | 999 void LoginUtilsImpl::OnCompletedAuthentication(Profile* user_profile) { |
997 StartSignedInServices(user_profile); | 1000 StartSignedInServices(user_profile); |
998 } | 1001 } |
999 | 1002 |
| 1003 void LoginUtilsImpl::OnCompletedMergeSession() { |
| 1004 UserManager::Get()->SetMergeSessionState(UserManager::MERGE_STATUS_DONE); |
| 1005 } |
| 1006 |
1000 void LoginUtilsImpl::OnFoundStoredTokens() { | 1007 void LoginUtilsImpl::OnFoundStoredTokens() { |
1001 // We don't need authenticator instance any more since its cookie jar | 1008 // We don't need authenticator instance any more since its cookie jar |
1002 // is not going to needed to mint OAuth tokens. Reset it so that | 1009 // is not going to needed to mint OAuth tokens. Reset it so that |
1003 // ScreenLocker would create a separate instance. | 1010 // ScreenLocker would create a separate instance. |
1004 authenticator_ = NULL; | 1011 authenticator_ = NULL; |
1005 } | 1012 } |
1006 | 1013 |
1007 void LoginUtilsImpl::OnConnectionTypeChanged( | 1014 void LoginUtilsImpl::OnConnectionTypeChanged( |
1008 net::NetworkChangeNotifier::ConnectionType type) { | 1015 net::NetworkChangeNotifier::ConnectionType type) { |
1009 if (!login_manager_.get()) | 1016 if (!login_manager_.get()) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1063 bool LoginUtils::IsWhitelisted(const std::string& username) { |
1057 CrosSettings* cros_settings = CrosSettings::Get(); | 1064 CrosSettings* cros_settings = CrosSettings::Get(); |
1058 bool allow_new_user = false; | 1065 bool allow_new_user = false; |
1059 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1066 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
1060 if (allow_new_user) | 1067 if (allow_new_user) |
1061 return true; | 1068 return true; |
1062 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1069 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
1063 } | 1070 } |
1064 | 1071 |
1065 } // namespace chromeos | 1072 } // namespace chromeos |
OLD | NEW |