| 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 "base/chromeos/chromeos_version.h" | 10 #include "base/chromeos/chromeos_version.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/about_flags.h" | 30 #include "chrome/browser/about_flags.h" |
| 31 #include "chrome/browser/app_mode/app_mode_utils.h" | 31 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 32 #include "chrome/browser/browser_process.h" | 32 #include "chrome/browser/browser_process.h" |
| 33 #include "chrome/browser/browser_shutdown.h" | 33 #include "chrome/browser/browser_shutdown.h" |
| 34 #include "chrome/browser/chrome_notification_types.h" | 34 #include "chrome/browser/chrome_notification_types.h" |
| 35 #include "chrome/browser/chromeos/boot_times_loader.h" | 35 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 36 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 36 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 37 #include "chrome/browser/chromeos/login/chrome_restart_request.h" | 37 #include "chrome/browser/chromeos/login/chrome_restart_request.h" |
| 38 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 38 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
| 39 #include "chrome/browser/chromeos/login/login_display_host.h" | 39 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 40 #include "chrome/browser/chromeos/login/oauth_login_manager.h" | 40 #include "chrome/browser/chromeos/login/oauth2_login_manager.h" |
| 41 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h" |
| 41 #include "chrome/browser/chromeos/login/parallel_authenticator.h" | 42 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
| 42 #include "chrome/browser/chromeos/login/profile_auth_data.h" | 43 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
| 43 #include "chrome/browser/chromeos/login/screen_locker.h" | 44 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 44 #include "chrome/browser/chromeos/login/user_manager.h" | 45 #include "chrome/browser/chromeos/login/user_manager.h" |
| 45 #include "chrome/browser/chromeos/settings/cros_settings.h" | 46 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 46 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 47 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 47 #include "chrome/browser/extensions/extension_service.h" | 48 #include "chrome/browser/extensions/extension_service.h" |
| 48 #include "chrome/browser/first_run/first_run.h" | 49 #include "chrome/browser/first_run/first_run.h" |
| 49 #include "chrome/browser/google/google_util_chromeos.h" | 50 #include "chrome/browser/google/google_util_chromeos.h" |
| 50 #include "chrome/browser/lifetime/application_lifetime.h" | 51 #include "chrome/browser/lifetime/application_lifetime.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 90 |
| 90 base::FilePath GetRlzDisabledFlagPath() { | 91 base::FilePath GetRlzDisabledFlagPath() { |
| 91 return file_util::GetHomeDir().Append(kRLZDisabledFlagName); | 92 return file_util::GetHomeDir().Append(kRLZDisabledFlagName); |
| 92 } | 93 } |
| 93 #endif | 94 #endif |
| 94 | 95 |
| 95 } // namespace | 96 } // namespace |
| 96 | 97 |
| 97 class LoginUtilsImpl | 98 class LoginUtilsImpl |
| 98 : public LoginUtils, | 99 : public LoginUtils, |
| 99 public OAuthLoginManager::Delegate, | 100 public OAuth2LoginManager::Observer, |
| 100 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 101 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
| 101 public base::SupportsWeakPtr<LoginUtilsImpl> { | 102 public base::SupportsWeakPtr<LoginUtilsImpl> { |
| 102 public: | 103 public: |
| 103 LoginUtilsImpl() | 104 LoginUtilsImpl() |
| 104 : using_oauth_(false), | 105 : using_oauth_(false), |
| 105 has_web_auth_cookies_(false), | 106 has_web_auth_cookies_(false), |
| 106 login_manager_(OAuthLoginManager::Create(this)), | |
| 107 delegate_(NULL), | 107 delegate_(NULL), |
| 108 should_restore_auth_session_(false), | 108 should_restore_auth_session_(false), |
| 109 session_restore_strategy_( | 109 session_restore_strategy_( |
| 110 OAuthLoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN) { | 110 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN) { |
| 111 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 111 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 112 } | 112 } |
| 113 | 113 |
| 114 virtual ~LoginUtilsImpl() { | 114 virtual ~LoginUtilsImpl() { |
| 115 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 115 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // LoginUtils implementation: | 118 // LoginUtils implementation: |
| 119 virtual void DoBrowserLaunch(Profile* profile, | 119 virtual void DoBrowserLaunch(Profile* profile, |
| 120 LoginDisplayHost* login_host) OVERRIDE; | 120 LoginDisplayHost* login_host) OVERRIDE; |
| 121 virtual void PrepareProfile( | 121 virtual void PrepareProfile( |
| 122 const UserContext& user_context, | 122 const UserContext& user_context, |
| 123 const std::string& display_email, | 123 const std::string& display_email, |
| 124 bool using_oauth, | 124 bool using_oauth, |
| 125 bool has_cookies, | 125 bool has_cookies, |
| 126 bool has_active_session, | 126 bool has_active_session, |
| 127 LoginUtils::Delegate* delegate) OVERRIDE; | 127 LoginUtils::Delegate* delegate) OVERRIDE; |
| 128 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE; | 128 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE; |
| 129 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; | 129 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; |
| 130 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; | 130 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; |
| 131 virtual scoped_refptr<Authenticator> CreateAuthenticator( | 131 virtual scoped_refptr<Authenticator> CreateAuthenticator( |
| 132 LoginStatusConsumer* consumer) OVERRIDE; | 132 LoginStatusConsumer* consumer) OVERRIDE; |
| 133 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; | 133 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; |
| 134 virtual void StopBackgroundFetchers() OVERRIDE; | |
| 135 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; | 134 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; |
| 136 | 135 |
| 137 // OAuthLoginManager::Delegate overrides. | 136 // OAuth2LoginManager::Delegate overrides. |
| 138 virtual void OnCompletedMergeSession() OVERRIDE; | 137 virtual void OnSessionRestoreStateChanged( |
| 139 virtual void OnCompletedAuthentication(Profile* user_profile) OVERRIDE; | 138 Profile* user_profile, |
| 140 virtual void OnFoundStoredTokens() OVERRIDE; | 139 OAuth2LoginManager::SessionRestoreState state) OVERRIDE; |
| 140 virtual void OnSessionAuthenticated(Profile* user_profile) OVERRIDE; |
| 141 | 141 |
| 142 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. | 142 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. |
| 143 virtual void OnConnectionTypeChanged( | 143 virtual void OnConnectionTypeChanged( |
| 144 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 144 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 // Restarts OAuth session authentication check. | 147 // Restarts OAuth session authentication check. |
| 148 void KickStartAuthentication(Profile* profile); | 148 void KickStartAuthentication(Profile* profile); |
| 149 | 149 |
| 150 // Check user's profile for kApplicationLocale setting. | 150 // Check user's profile for kApplicationLocale setting. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 180 bool restore_from_auth_cookies); | 180 bool restore_from_auth_cookies); |
| 181 | 181 |
| 182 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. | 182 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. |
| 183 void InitRlz(Profile* user_profile, bool disabled); | 183 void InitRlz(Profile* user_profile, bool disabled); |
| 184 | 184 |
| 185 // Starts signing related services. Initiates TokenService token retrieval. | 185 // Starts signing related services. Initiates TokenService token retrieval. |
| 186 void StartSignedInServices(Profile* profile); | 186 void StartSignedInServices(Profile* profile); |
| 187 | 187 |
| 188 UserContext user_context_; | 188 UserContext user_context_; |
| 189 bool using_oauth_; | 189 bool using_oauth_; |
| 190 |
| 190 // True if the authentication profile's cookie jar should contain | 191 // True if the authentication profile's cookie jar should contain |
| 191 // authentication cookies from the authentication extension log in flow. | 192 // authentication cookies from the authentication extension log in flow. |
| 192 bool has_web_auth_cookies_; | 193 bool has_web_auth_cookies_; |
| 193 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). | 194 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). |
| 194 scoped_refptr<Authenticator> authenticator_; | 195 scoped_refptr<Authenticator> authenticator_; |
| 195 scoped_ptr<OAuthLoginManager> login_manager_; | |
| 196 | 196 |
| 197 // Delegate to be fired when the profile will be prepared. | 197 // Delegate to be fired when the profile will be prepared. |
| 198 LoginUtils::Delegate* delegate_; | 198 LoginUtils::Delegate* delegate_; |
| 199 | 199 |
| 200 // True if should restore authentication session when notified about | 200 // True if should restore authentication session when notified about |
| 201 // online state change. | 201 // online state change. |
| 202 bool should_restore_auth_session_; | 202 bool should_restore_auth_session_; |
| 203 | 203 |
| 204 // Sesion restore strategy. | 204 // Sesion restore strategy. |
| 205 OAuthLoginManager::SessionRestoreStrategy session_restore_strategy_; | 205 OAuth2LoginManager::SessionRestoreStrategy session_restore_strategy_; |
| 206 // OAuth2 refresh token for session restore. | 206 // OAuth2 refresh token for session restore. |
| 207 std::string oauth2_refresh_token_; | 207 std::string oauth2_refresh_token_; |
| 208 | 208 |
| 209 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); | 209 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 class LoginUtilsWrapper { | 212 class LoginUtilsWrapper { |
| 213 public: | 213 public: |
| 214 static LoginUtilsWrapper* GetInstance() { | 214 static LoginUtilsWrapper* GetInstance() { |
| 215 return Singleton<LoginUtilsWrapper>::get(); | 215 return Singleton<LoginUtilsWrapper>::get(); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 ::switches::kAppModeOAuth2Token); | 387 ::switches::kAppModeOAuth2Token); |
| 388 } | 388 } |
| 389 | 389 |
| 390 if (command_line->HasSwitch(::switches::kAppModeAuthCode)) { | 390 if (command_line->HasSwitch(::switches::kAppModeAuthCode)) { |
| 391 user_context_.auth_code = command_line->GetSwitchValueASCII( | 391 user_context_.auth_code = command_line->GetSwitchValueASCII( |
| 392 ::switches::kAppModeAuthCode); | 392 ::switches::kAppModeAuthCode); |
| 393 } | 393 } |
| 394 | 394 |
| 395 DCHECK(!has_web_auth_cookies_); | 395 DCHECK(!has_web_auth_cookies_); |
| 396 if (!user_context_.auth_code.empty()) { | 396 if (!user_context_.auth_code.empty()) { |
| 397 session_restore_strategy_ = OAuthLoginManager::RESTORE_FROM_AUTH_CODE; | 397 session_restore_strategy_ = OAuth2LoginManager::RESTORE_FROM_AUTH_CODE; |
| 398 } else if (!oauth2_refresh_token_.empty()) { | 398 } else if (!oauth2_refresh_token_.empty()) { |
| 399 session_restore_strategy_ = | 399 session_restore_strategy_ = |
| 400 OAuthLoginManager::RESTORE_FROM_PASSED_OAUTH2_REFRESH_TOKEN; | 400 OAuth2LoginManager::RESTORE_FROM_PASSED_OAUTH2_REFRESH_TOKEN; |
| 401 } else { | 401 } else { |
| 402 session_restore_strategy_ = | 402 session_restore_strategy_ = |
| 403 OAuthLoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN; | 403 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN; |
| 404 } | 404 } |
| 405 return; | 405 return; |
| 406 } | 406 } |
| 407 | 407 |
| 408 if (has_web_auth_cookies_) { | 408 if (has_web_auth_cookies_) { |
| 409 session_restore_strategy_ = OAuthLoginManager::RESTORE_FROM_COOKIE_JAR; | 409 session_restore_strategy_ = OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR; |
| 410 } else if (!user_context_.auth_code.empty()) { | 410 } else if (!user_context_.auth_code.empty()) { |
| 411 session_restore_strategy_ = OAuthLoginManager::RESTORE_FROM_AUTH_CODE; | 411 session_restore_strategy_ = OAuth2LoginManager::RESTORE_FROM_AUTH_CODE; |
| 412 } else { | 412 } else { |
| 413 session_restore_strategy_ = | 413 session_restore_strategy_ = |
| 414 OAuthLoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN; | 414 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN; |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 | 417 |
| 418 | 418 |
| 419 void LoginUtilsImpl::OnProfileCreated( | 419 void LoginUtilsImpl::OnProfileCreated( |
| 420 Profile* user_profile, | 420 Profile* user_profile, |
| 421 Profile::CreateStatus status) { | 421 Profile::CreateStatus status) { |
| 422 CHECK(user_profile); | 422 CHECK(user_profile); |
| 423 | 423 |
| 424 switch (status) { | 424 switch (status) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 462 |
| 463 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) { | 463 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) { |
| 464 RestoreAuthSession(user_profile, has_web_auth_cookies_); | 464 RestoreAuthSession(user_profile, has_web_auth_cookies_); |
| 465 FinalizePrepareProfile(user_profile); | 465 FinalizePrepareProfile(user_profile); |
| 466 } | 466 } |
| 467 | 467 |
| 468 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, | 468 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, |
| 469 bool restore_from_auth_cookies) { | 469 bool restore_from_auth_cookies) { |
| 470 CHECK((authenticator_.get() && authenticator_->authentication_profile()) || | 470 CHECK((authenticator_.get() && authenticator_->authentication_profile()) || |
| 471 !restore_from_auth_cookies); | 471 !restore_from_auth_cookies); |
| 472 if (!login_manager_.get()) | |
| 473 return; | |
| 474 | 472 |
| 475 if (chrome::IsRunningInForcedAppMode() || | 473 if (chrome::IsRunningInForcedAppMode() || |
| 476 CommandLine::ForCurrentProcess()->HasSwitch( | 474 CommandLine::ForCurrentProcess()->HasSwitch( |
| 477 chromeos::switches::kOobeSkipPostLogin)) | 475 chromeos::switches::kOobeSkipPostLogin)) |
| 478 return; | 476 return; |
| 479 | 477 |
| 480 UserManager::Get()->SetMergeSessionState( | |
| 481 UserManager::MERGE_STATUS_IN_PROCESS); | |
| 482 | |
| 483 // Remove legacy OAuth1 token if we have one. If it's valid, we should already | 478 // Remove legacy OAuth1 token if we have one. If it's valid, we should already |
| 484 // have OAuth2 refresh token in TokenService that could be used to retrieve | 479 // have OAuth2 refresh token in TokenService that could be used to retrieve |
| 485 // all other tokens and user_context. | 480 // all other tokens and user_context. |
| 486 login_manager_->RestoreSession( | 481 OAuth2LoginManager* login_manager = |
| 487 user_profile, | 482 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); |
| 483 login_manager->AddObserver(this); |
| 484 login_manager->RestoreSession( |
| 488 authenticator_.get() && authenticator_->authentication_profile() | 485 authenticator_.get() && authenticator_->authentication_profile() |
| 489 ? authenticator_->authentication_profile()->GetRequestContext() | 486 ? authenticator_->authentication_profile()->GetRequestContext() |
| 490 : NULL, | 487 : NULL, |
| 491 session_restore_strategy_, | 488 session_restore_strategy_, |
| 492 oauth2_refresh_token_, | 489 oauth2_refresh_token_, |
| 493 user_context_.auth_code); | 490 user_context_.auth_code); |
| 494 } | 491 } |
| 495 | 492 |
| 496 void LoginUtilsImpl::FinalizePrepareProfile(Profile* user_profile) { | 493 void LoginUtilsImpl::FinalizePrepareProfile(Profile* user_profile) { |
| 497 BootTimesLoader* btl = BootTimesLoader::Get(); | 494 BootTimesLoader* btl = BootTimesLoader::Get(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 UserManager::Get()->IsLoggedInAsStub()) { | 713 UserManager::Get()->IsLoggedInAsStub()) { |
| 717 return; | 714 return; |
| 718 } | 715 } |
| 719 | 716 |
| 720 if (!net::NetworkChangeNotifier::IsOffline()) { | 717 if (!net::NetworkChangeNotifier::IsOffline()) { |
| 721 should_restore_auth_session_ = false; | 718 should_restore_auth_session_ = false; |
| 722 RestoreAuthSession(user_profile, false); | 719 RestoreAuthSession(user_profile, false); |
| 723 } else { | 720 } else { |
| 724 // Even if we're online we should wait till initial | 721 // Even if we're online we should wait till initial |
| 725 // OnConnectionTypeChanged() call. Otherwise starting fetchers too early may | 722 // OnConnectionTypeChanged() call. Otherwise starting fetchers too early may |
| 726 // end up cancelling all request when initial network connection type is | 723 // end up canceling all request when initial network connection type is |
| 727 // processed. See http://crbug.com/121643. | 724 // processed. See http://crbug.com/121643. |
| 728 should_restore_auth_session_ = true; | 725 should_restore_auth_session_ = true; |
| 729 } | 726 } |
| 730 } | 727 } |
| 731 | 728 |
| 732 void LoginUtilsImpl::StopBackgroundFetchers() { | 729 void LoginUtilsImpl::OnSessionRestoreStateChanged( |
| 733 login_manager_.reset(); | 730 Profile* user_profile, |
| 731 OAuth2LoginManager::SessionRestoreState state) { |
| 732 OAuth2LoginManager* login_manager = |
| 733 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); |
| 734 switch (state) { |
| 735 case OAuth2LoginManager::SESSION_RESTORE_NOT_STARTED: |
| 736 break; |
| 737 case OAuth2LoginManager::SESSION_RESTORE_PREPARING: |
| 738 break; |
| 739 case OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: |
| 740 break; |
| 741 case OAuth2LoginManager::SESSION_RESTORE_DONE: |
| 742 UserManager::Get()->SaveUserOAuthStatus( |
| 743 UserManager::Get()->GetLoggedInUser()->email(), |
| 744 User::OAUTH2_TOKEN_STATUS_VALID); |
| 745 login_manager->RemoveObserver(this); |
| 746 break; |
| 747 case OAuth2LoginManager::SESSION_RESTORE_FAILED: |
| 748 UserManager::Get()->SaveUserOAuthStatus( |
| 749 UserManager::Get()->GetLoggedInUser()->email(), |
| 750 User::OAUTH2_TOKEN_STATUS_INVALID); |
| 751 login_manager->RemoveObserver(this); |
| 752 break; |
| 753 } |
| 734 } | 754 } |
| 735 | 755 |
| 736 void LoginUtilsImpl::OnCompletedAuthentication(Profile* user_profile) { | 756 void LoginUtilsImpl::OnSessionAuthenticated(Profile* user_profile) { |
| 737 StartSignedInServices(user_profile); | 757 StartSignedInServices(user_profile); |
| 738 } | 758 } |
| 739 | 759 |
| 740 void LoginUtilsImpl::OnCompletedMergeSession() { | |
| 741 UserManager::Get()->SetMergeSessionState(UserManager::MERGE_STATUS_DONE); | |
| 742 } | |
| 743 | |
| 744 void LoginUtilsImpl::OnFoundStoredTokens() { | |
| 745 // We don't need authenticator instance any more since its cookie jar | |
| 746 // is not going to needed to mint OAuth tokens. Reset it so that | |
| 747 // ScreenLocker would create a separate instance. | |
| 748 authenticator_ = NULL; | |
| 749 } | |
| 750 | |
| 751 void LoginUtilsImpl::OnConnectionTypeChanged( | 760 void LoginUtilsImpl::OnConnectionTypeChanged( |
| 752 net::NetworkChangeNotifier::ConnectionType type) { | 761 net::NetworkChangeNotifier::ConnectionType type) { |
| 753 if (!login_manager_.get()) | 762 Profile* user_profile = ProfileManager::GetDefaultProfile(); |
| 754 return; | 763 OAuth2LoginManager* login_manager = |
| 764 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); |
| 755 | 765 |
| 756 if (type != net::NetworkChangeNotifier::CONNECTION_NONE && | 766 if (type != net::NetworkChangeNotifier::CONNECTION_NONE && |
| 757 UserManager::Get()->IsUserLoggedIn()) { | 767 UserManager::Get()->IsUserLoggedIn()) { |
| 758 if (login_manager_->state() == | 768 if (login_manager->state() == |
| 759 OAuthLoginManager::SESSION_RESTORE_IN_PROGRESS) { | 769 OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS) { |
| 760 // If we come online for the first time after successful offline login, | 770 // If we come online for the first time after successful offline login, |
| 761 // we need to kick off OAuth token verification process again. | 771 // we need to kick off OAuth token verification process again. |
| 762 login_manager_->ContinueSessionRestore(); | 772 login_manager->ContinueSessionRestore(); |
| 763 } else if (should_restore_auth_session_) { | 773 } else if (should_restore_auth_session_) { |
| 764 should_restore_auth_session_ = false; | 774 should_restore_auth_session_ = false; |
| 765 Profile* user_profile = ProfileManager::GetDefaultProfile(); | |
| 766 RestoreAuthSession(user_profile, has_web_auth_cookies_); | 775 RestoreAuthSession(user_profile, has_web_auth_cookies_); |
| 767 } | 776 } |
| 768 } | 777 } |
| 769 } | 778 } |
| 770 | 779 |
| 771 // static | 780 // static |
| 772 void LoginUtils::RegisterPrefs(PrefRegistrySimple* registry) { | 781 void LoginUtils::RegisterPrefs(PrefRegistrySimple* registry) { |
| 773 registry->RegisterBooleanPref(prefs::kFactoryResetRequested, false); | 782 registry->RegisterBooleanPref(prefs::kFactoryResetRequested, false); |
| 774 registry->RegisterStringPref(prefs::kRLZBrand, std::string()); | 783 registry->RegisterStringPref(prefs::kRLZBrand, std::string()); |
| 775 registry->RegisterBooleanPref(prefs::kRLZDisabled, false); | 784 registry->RegisterBooleanPref(prefs::kRLZDisabled, false); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 789 bool LoginUtils::IsWhitelisted(const std::string& username) { | 798 bool LoginUtils::IsWhitelisted(const std::string& username) { |
| 790 CrosSettings* cros_settings = CrosSettings::Get(); | 799 CrosSettings* cros_settings = CrosSettings::Get(); |
| 791 bool allow_new_user = false; | 800 bool allow_new_user = false; |
| 792 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 801 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 793 if (allow_new_user) | 802 if (allow_new_user) |
| 794 return true; | 803 return true; |
| 795 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 804 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
| 796 } | 805 } |
| 797 | 806 |
| 798 } // namespace chromeos | 807 } // namespace chromeos |
| OLD | NEW |