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 "base/values.h"
8 #include "chrome/browser/chromeos/login/help_app_launcher.h"
9 #include "chrome/browser/chromeos/login/login_utils.h"
10 #include "chrome/browser/chromeos/login/user.h"
11 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/web_ui.h"
14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h"
19 UserManager
* AppLaunchSigninScreen::test_user_manager_
= NULL
;
21 AppLaunchSigninScreen::AppLaunchSigninScreen(
22 OobeUI
* oobe_ui
, Delegate
* delegate
)
25 webui_handler_(NULL
) {
28 AppLaunchSigninScreen::~AppLaunchSigninScreen() {
29 oobe_ui_
->ResetSigninScreenHandlerDelegate();
32 void AppLaunchSigninScreen::Show() {
34 oobe_ui_
->web_ui()->CallJavascriptFunction(
35 "login.AccountPickerScreen.setShouldShowApps",
36 base::FundamentalValue(false));
37 oobe_ui_
->ShowSigninScreen(LoginScreenContext(), this, NULL
);
40 void AppLaunchSigninScreen::InitOwnerUserList() {
41 UserManager
* user_manager
= GetUserManager();
42 const std::string
& owner_email
= user_manager
->GetOwnerEmail();
43 const UserList
& all_users
= user_manager
->GetUsers();
45 owner_user_list_
.clear();
46 for (UserList::const_iterator it
= all_users
.begin();
47 it
!= all_users
.end();
50 if (user
->email() == owner_email
) {
51 owner_user_list_
.push_back(user
);
58 void AppLaunchSigninScreen::SetUserManagerForTesting(
59 UserManager
* user_manager
) {
60 test_user_manager_
= user_manager
;
63 UserManager
* AppLaunchSigninScreen::GetUserManager() {
64 return test_user_manager_
? test_user_manager_
: UserManager::Get();
67 void AppLaunchSigninScreen::CancelPasswordChangedFlow() {
71 void AppLaunchSigninScreen::CancelUserAdding() {
75 void AppLaunchSigninScreen::CreateAccount() {
79 void AppLaunchSigninScreen::CompleteLogin(const UserContext
& user_context
) {
83 void AppLaunchSigninScreen::Login(const UserContext
& user_context
) {
84 // Note: LoginUtils::CreateAuthenticator doesn't necessarily create
85 // a new Authenticator object, and could reuse an existing one.
86 authenticator_
= LoginUtils::Get()->CreateAuthenticator(this);
87 content::BrowserThread::PostTask(
88 content::BrowserThread::UI
, FROM_HERE
,
89 base::Bind(&Authenticator::AuthenticateToUnlock
,
94 void AppLaunchSigninScreen::LoginAsRetailModeUser() {
98 void AppLaunchSigninScreen::LoginAsGuest() {
102 void AppLaunchSigninScreen::MigrateUserData(const std::string
& old_password
) {
106 void AppLaunchSigninScreen::LoginAsPublicAccount(const std::string
& username
) {
110 void AppLaunchSigninScreen::LoadWallpaper(const std::string
& username
) {
113 void AppLaunchSigninScreen::LoadSigninWallpaper() {
116 void AppLaunchSigninScreen::OnSigninScreenReady() {
119 void AppLaunchSigninScreen::RemoveUser(const std::string
& username
) {
123 void AppLaunchSigninScreen::ResyncUserData() {
127 void AppLaunchSigninScreen::ShowEnterpriseEnrollmentScreen() {
131 void AppLaunchSigninScreen::ShowKioskEnableScreen() {
135 void AppLaunchSigninScreen::ShowKioskAutolaunchScreen() {
139 void AppLaunchSigninScreen::ShowWrongHWIDScreen() {
143 void AppLaunchSigninScreen::SetWebUIHandler(
144 LoginDisplayWebUIHandler
* webui_handler
) {
145 webui_handler_
= webui_handler
;
148 void AppLaunchSigninScreen::ShowSigninScreenForCreds(
149 const std::string
& username
,
150 const std::string
& password
) {
154 const UserList
& AppLaunchSigninScreen::GetUsers() const {
155 return owner_user_list_
;
158 bool AppLaunchSigninScreen::IsShowGuest() const {
162 bool AppLaunchSigninScreen::IsShowUsers() const {
166 bool AppLaunchSigninScreen::IsShowNewUser() const {
170 bool AppLaunchSigninScreen::IsSigninInProgress() const {
171 // Return true to suppress network processing in the signin screen.
175 bool AppLaunchSigninScreen::IsUserSigninCompleted() const {
179 void AppLaunchSigninScreen::SetDisplayEmail(const std::string
& email
) {
183 void AppLaunchSigninScreen::Signout() {
187 void AppLaunchSigninScreen::LoginAsKioskApp(const std::string
& app_id
,
188 bool diagnostic_mode
) {
192 void AppLaunchSigninScreen::OnLoginFailure(const LoginFailure
& error
) {
193 LOG(ERROR
) << "Unlock failure: " << error
.reason();
194 webui_handler_
->ClearAndEnablePassword();
195 webui_handler_
->ShowError(
197 l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING_KIOSK
),
199 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE
);
202 void AppLaunchSigninScreen::OnLoginSuccess(const UserContext
& user_context
) {
203 delegate_
->OnOwnerSigninSuccess();
206 } // namespace chromeos