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.
5 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_flow.h"
7 #include "base/logging.h"
8 #include "base/values.h"
9 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
10 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.h"
11 #include "chrome/browser/chromeos/login/wizard_controller.h"
17 LocallyManagedUserCreationScreen
* GetScreen(LoginDisplayHost
* host
) {
19 DCHECK(host
->GetWizardController());
20 DCHECK(host
->GetWizardController()->GetLocallyManagedUserCreationScreen());
21 return host
->GetWizardController()->GetLocallyManagedUserCreationScreen();
26 LocallyManagedUserCreationFlow::LocallyManagedUserCreationFlow(
27 const std::string
& manager_id
)
28 : ExtendedUserFlow(manager_id
),
29 token_validated_(false),
31 manager_profile_(NULL
) {}
33 LocallyManagedUserCreationFlow::~LocallyManagedUserCreationFlow() {}
35 bool LocallyManagedUserCreationFlow::ShouldShowSettings() {
39 bool LocallyManagedUserCreationFlow::ShouldLaunchBrowser() {
43 bool LocallyManagedUserCreationFlow::ShouldSkipPostLoginScreens() {
47 void LocallyManagedUserCreationFlow::HandleOAuthTokenStatusChange(
48 User::OAuthTokenStatus status
) {
49 if (status
== User::OAUTH_TOKEN_STATUS_UNKNOWN
)
51 if (status
== User::OAUTH2_TOKEN_STATUS_INVALID
) {
52 GetScreen(host())->ShowManagerInconsistentStateErrorScreen();
55 DCHECK(status
== User::OAUTH2_TOKEN_STATUS_VALID
);
56 // We expect that LaunchExtraSteps is called by this time (local
57 // authentication happens before oauth token validation).
58 token_validated_
= true;
60 if (token_validated_
&& logged_in_
)
61 GetScreen(host())->OnManagerFullyAuthenticated(manager_profile_
);
65 bool LocallyManagedUserCreationFlow::HandleLoginFailure(
66 const LoginFailure
& failure
) {
67 if (failure
.reason() == LoginFailure::COULD_NOT_MOUNT_CRYPTOHOME
)
68 GetScreen(host())->OnManagerLoginFailure();
70 GetScreen(host())->ShowManagerInconsistentStateErrorScreen();
74 bool LocallyManagedUserCreationFlow::HandlePasswordChangeDetected() {
75 GetScreen(host())->ShowManagerInconsistentStateErrorScreen();
79 void LocallyManagedUserCreationFlow::LaunchExtraSteps(
82 manager_profile_
= profile
;
83 if (token_validated_
&& logged_in_
)
84 GetScreen(host())->OnManagerFullyAuthenticated(manager_profile_
);
86 GetScreen(host())->OnManagerCryptohomeAuthenticated();
89 } // namespace chromeos