Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / login / supervised / supervised_user_creation_flow.cc
blobc116b68c6291f67bb812c1834fa0fa62b44ce25f
1 // Copyright 2014 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/supervised/supervised_user_creation_flow.h"
7 #include "base/logging.h"
8 #include "base/values.h"
9 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_screen.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"
14 namespace chromeos {
16 namespace {
18 SupervisedUserCreationScreen* GetScreen(LoginDisplayHost* host) {
19 DCHECK(host);
20 DCHECK(host->GetWizardController());
21 SupervisedUserCreationScreen* result =
22 SupervisedUserCreationScreen::Get(host->GetWizardController());
23 DCHECK(result);
24 return result;
27 } // namespace
29 SupervisedUserCreationFlow::SupervisedUserCreationFlow(
30 const std::string& manager_id)
31 : ExtendedUserFlow(manager_id),
32 token_validated_(false),
33 logged_in_(false),
34 session_started_(false),
35 manager_profile_(NULL) {}
37 SupervisedUserCreationFlow::~SupervisedUserCreationFlow() {
38 LOG(ERROR) << "Destroyed " << this;
41 bool SupervisedUserCreationFlow::CanLockScreen() {
42 return false;
45 bool SupervisedUserCreationFlow::ShouldShowSettings() {
46 return false;
49 bool SupervisedUserCreationFlow::ShouldLaunchBrowser() {
50 return false;
53 bool SupervisedUserCreationFlow::ShouldSkipPostLoginScreens() {
54 return true;
57 bool SupervisedUserCreationFlow::SupportsEarlyRestartToApplyFlags() {
58 return false;
61 void SupervisedUserCreationFlow::HandleOAuthTokenStatusChange(
62 user_manager::User::OAuthTokenStatus status) {
63 if (status == user_manager::User::OAUTH_TOKEN_STATUS_UNKNOWN)
64 return;
65 if (status == user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) {
66 GetScreen(host())->ShowManagerInconsistentStateErrorScreen();
67 return;
69 DCHECK(status == user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
70 // We expect that LaunchExtraSteps is called by this time (local
71 // authentication happens before oauth token validation).
72 token_validated_ = true;
74 if (token_validated_ && logged_in_) {
75 if (!session_started_)
76 GetScreen(host())->OnManagerFullyAuthenticated(manager_profile_);
77 session_started_ = true;
81 bool SupervisedUserCreationFlow::HandleLoginFailure(
82 const AuthFailure& failure) {
83 if (failure.reason() == AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME)
84 GetScreen(host())->OnManagerLoginFailure();
85 else
86 GetScreen(host())->ShowManagerInconsistentStateErrorScreen();
87 return true;
90 void SupervisedUserCreationFlow::HandleLoginSuccess(
91 const UserContext& context) {}
93 bool SupervisedUserCreationFlow::HandlePasswordChangeDetected() {
94 GetScreen(host())->ShowManagerInconsistentStateErrorScreen();
95 return true;
98 void SupervisedUserCreationFlow::LaunchExtraSteps(
99 Profile* profile) {
100 // TODO(antrim): remove this output once crash is found.
101 LOG(ERROR) << "LaunchExtraSteps for " << this << " host is " << host();
102 logged_in_ = true;
103 manager_profile_ = profile;
104 ProfileHelper::Get()->ProfileStartup(profile, true);
106 if (token_validated_ && logged_in_) {
107 if (!session_started_)
108 GetScreen(host())->OnManagerFullyAuthenticated(manager_profile_);
109 session_started_ = true;
110 } else {
111 GetScreen(host())->OnManagerCryptohomeAuthenticated();
115 } // namespace chromeos