1 // Copyright 2013 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/app_launch_signin_screen.h"
7 #include "chrome/browser/chromeos/login/help_app_launcher.h"
8 #include "chrome/browser/chromeos/login/login_utils.h"
9 #include "chrome/browser/chromeos/login/user.h"
10 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h"
17 UserManager
* AppLaunchSigninScreen::test_user_manager_
= NULL
;
19 AppLaunchSigninScreen::AppLaunchSigninScreen(
20 OobeUI
* oobe_ui
, Delegate
* delegate
)
23 webui_handler_(NULL
) {
26 AppLaunchSigninScreen::~AppLaunchSigninScreen() {
27 oobe_ui_
->ResetSigninScreenHandlerDelegate();
30 void AppLaunchSigninScreen::Show() {
32 oobe_ui_
->ShowSigninScreen(LoginScreenContext(), this, NULL
);
35 void AppLaunchSigninScreen::InitOwnerUserList() {
36 UserManager
* user_manager
= GetUserManager();
37 const std::string
& owner_email
= user_manager
->GetOwnerEmail();
38 const UserList
& all_users
= user_manager
->GetUsers();
40 owner_user_list_
.clear();
41 for (UserList::const_iterator it
= all_users
.begin();
42 it
!= all_users
.end();
45 if (user
->email() == owner_email
) {
46 owner_user_list_
.push_back(user
);
53 void AppLaunchSigninScreen::SetUserManagerForTesting(
54 UserManager
* user_manager
) {
55 test_user_manager_
= user_manager
;
58 UserManager
* AppLaunchSigninScreen::GetUserManager() {
59 return test_user_manager_
? test_user_manager_
: UserManager::Get();
62 void AppLaunchSigninScreen::CancelPasswordChangedFlow() {
66 void AppLaunchSigninScreen::CancelUserAdding() {
70 void AppLaunchSigninScreen::CreateAccount() {
74 void AppLaunchSigninScreen::CompleteLogin(const UserContext
& user_context
) {
78 void AppLaunchSigninScreen::Login(const UserContext
& user_context
) {
79 // Note: LoginUtils::CreateAuthenticator doesn't necessarily create
80 // a new Authenticator object, and could reuse an existing one.
81 authenticator_
= LoginUtils::Get()->CreateAuthenticator(this);
82 content::BrowserThread::PostTask(
83 content::BrowserThread::UI
, FROM_HERE
,
84 base::Bind(&Authenticator::AuthenticateToUnlock
,
89 void AppLaunchSigninScreen::LoginAsRetailModeUser() {
93 void AppLaunchSigninScreen::LoginAsGuest() {
97 void AppLaunchSigninScreen::MigrateUserData(const std::string
& old_password
) {
101 void AppLaunchSigninScreen::LoginAsPublicAccount(const std::string
& username
) {
105 void AppLaunchSigninScreen::LoadWallpaper(const std::string
& username
) {
108 void AppLaunchSigninScreen::LoadSigninWallpaper() {
111 void AppLaunchSigninScreen::OnSigninScreenReady() {
114 void AppLaunchSigninScreen::RemoveUser(const std::string
& username
) {
118 void AppLaunchSigninScreen::ResyncUserData() {
122 void AppLaunchSigninScreen::ShowEnterpriseEnrollmentScreen() {
126 void AppLaunchSigninScreen::ShowKioskEnableScreen() {
130 void AppLaunchSigninScreen::ShowResetScreen() {
134 void AppLaunchSigninScreen::ShowKioskAutolaunchScreen() {
138 void AppLaunchSigninScreen::ShowWrongHWIDScreen() {
142 void AppLaunchSigninScreen::SetWebUIHandler(
143 LoginDisplayWebUIHandler
* webui_handler
) {
144 webui_handler_
= webui_handler
;
147 void AppLaunchSigninScreen::ShowSigninScreenForCreds(
148 const std::string
& username
,
149 const std::string
& password
) {
153 const UserList
& AppLaunchSigninScreen::GetUsers() const {
154 return owner_user_list_
;
157 bool AppLaunchSigninScreen::IsShowGuest() const {
161 bool AppLaunchSigninScreen::IsShowUsers() const {
165 bool AppLaunchSigninScreen::IsShowNewUser() const {
169 bool AppLaunchSigninScreen::IsSigninInProgress() const {
170 // Return true to suppress network processing in the signin screen.
174 bool AppLaunchSigninScreen::IsUserSigninCompleted() const {
178 void AppLaunchSigninScreen::SetDisplayEmail(const std::string
& email
) {
182 void AppLaunchSigninScreen::Signout() {
186 void AppLaunchSigninScreen::LoginAsKioskApp(const std::string
& app_id
) {
190 void AppLaunchSigninScreen::OnLoginFailure(const LoginFailure
& error
) {
191 LOG(ERROR
) << "Unlock failure: " << error
.reason();
192 webui_handler_
->ClearAndEnablePassword();
193 webui_handler_
->ShowError(
195 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING_KIOSK
),
197 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE
);
200 void AppLaunchSigninScreen::OnLoginSuccess(const UserContext
& user_context
) {
201 delegate_
->OnOwnerSigninSuccess();
204 } // namespace chromeos