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