| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_fl
ow.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/values.h" | |
| 9 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_sc
reen.h" | |
| 10 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | |
| 11 #include "chrome/browser/chromeos/login/wizard_controller.h" | |
| 12 #include "chrome/browser/chromeos/profiles/profile_helper.h" | |
| 13 | |
| 14 namespace chromeos { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 LocallyManagedUserCreationScreen* GetScreen(LoginDisplayHost* host) { | |
| 19 DCHECK(host); | |
| 20 DCHECK(host->GetWizardController()); | |
| 21 DCHECK(host->GetWizardController()->GetLocallyManagedUserCreationScreen()); | |
| 22 return host->GetWizardController()->GetLocallyManagedUserCreationScreen(); | |
| 23 } | |
| 24 | |
| 25 } // namespace | |
| 26 | |
| 27 LocallyManagedUserCreationFlow::LocallyManagedUserCreationFlow( | |
| 28 const std::string& manager_id) | |
| 29 : ExtendedUserFlow(manager_id), | |
| 30 token_validated_(false), | |
| 31 logged_in_(false), | |
| 32 session_started_(false), | |
| 33 manager_profile_(NULL) {} | |
| 34 | |
| 35 LocallyManagedUserCreationFlow::~LocallyManagedUserCreationFlow() {} | |
| 36 | |
| 37 bool LocallyManagedUserCreationFlow::CanLockScreen() { | |
| 38 return false; | |
| 39 } | |
| 40 | |
| 41 bool LocallyManagedUserCreationFlow::ShouldShowSettings() { | |
| 42 return false; | |
| 43 } | |
| 44 | |
| 45 bool LocallyManagedUserCreationFlow::ShouldLaunchBrowser() { | |
| 46 return false; | |
| 47 } | |
| 48 | |
| 49 bool LocallyManagedUserCreationFlow::ShouldSkipPostLoginScreens() { | |
| 50 return true; | |
| 51 } | |
| 52 | |
| 53 void LocallyManagedUserCreationFlow::HandleOAuthTokenStatusChange( | |
| 54 User::OAuthTokenStatus status) { | |
| 55 if (status == User::OAUTH_TOKEN_STATUS_UNKNOWN) | |
| 56 return; | |
| 57 if (status == User::OAUTH2_TOKEN_STATUS_INVALID) { | |
| 58 GetScreen(host())->ShowManagerInconsistentStateErrorScreen(); | |
| 59 return; | |
| 60 } | |
| 61 DCHECK(status == User::OAUTH2_TOKEN_STATUS_VALID); | |
| 62 // We expect that LaunchExtraSteps is called by this time (local | |
| 63 // authentication happens before oauth token validation). | |
| 64 token_validated_ = true; | |
| 65 | |
| 66 if (token_validated_ && logged_in_) { | |
| 67 if (!session_started_) | |
| 68 GetScreen(host())->OnManagerFullyAuthenticated(manager_profile_); | |
| 69 session_started_ = true; | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 bool LocallyManagedUserCreationFlow::HandleLoginFailure( | |
| 74 const AuthFailure& failure) { | |
| 75 if (failure.reason() == AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME) | |
| 76 GetScreen(host())->OnManagerLoginFailure(); | |
| 77 else | |
| 78 GetScreen(host())->ShowManagerInconsistentStateErrorScreen(); | |
| 79 return true; | |
| 80 } | |
| 81 | |
| 82 void LocallyManagedUserCreationFlow::HandleLoginSuccess( | |
| 83 const UserContext& context) {} | |
| 84 | |
| 85 bool LocallyManagedUserCreationFlow::HandlePasswordChangeDetected() { | |
| 86 GetScreen(host())->ShowManagerInconsistentStateErrorScreen(); | |
| 87 return true; | |
| 88 } | |
| 89 | |
| 90 void LocallyManagedUserCreationFlow::LaunchExtraSteps( | |
| 91 Profile* profile) { | |
| 92 logged_in_ = true; | |
| 93 manager_profile_ = profile; | |
| 94 ProfileHelper::Get()->ProfileStartup(profile, true); | |
| 95 | |
| 96 if (token_validated_ && logged_in_) { | |
| 97 if (!session_started_) | |
| 98 GetScreen(host())->OnManagerFullyAuthenticated(manager_profile_); | |
| 99 session_started_ = true; | |
| 100 } else { | |
| 101 GetScreen(host())->OnManagerCryptohomeAuthenticated(); | |
| 102 } | |
| 103 } | |
| 104 | |
| 105 } // namespace chromeos | |
| OLD | NEW |