Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / chromeos / login / app_launch_signin_screen.cc
blob37ee1f0a42008c7d38be6957c0122fdc806feb2c
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/screens/user_selection_screen.h"
10 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
11 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
12 #include "chrome/grit/generated_resources.h"
13 #include "chromeos/login/auth/user_context.h"
14 #include "components/proximity_auth/screenlock_bridge.h"
15 #include "components/user_manager/user_manager.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/web_ui.h"
18 #include "ui/base/l10n/l10n_util.h"
20 namespace chromeos {
22 user_manager::UserManager* AppLaunchSigninScreen::test_user_manager_ = NULL;
24 AppLaunchSigninScreen::AppLaunchSigninScreen(
25 OobeUI* oobe_ui, Delegate* delegate)
26 : oobe_ui_(oobe_ui),
27 delegate_(delegate),
28 webui_handler_(NULL) {
31 AppLaunchSigninScreen::~AppLaunchSigninScreen() {
32 oobe_ui_->ResetSigninScreenHandlerDelegate();
35 void AppLaunchSigninScreen::Show() {
36 InitOwnerUserList();
37 oobe_ui_->web_ui()->CallJavascriptFunction(
38 "login.AccountPickerScreen.setShouldShowApps",
39 base::FundamentalValue(false));
40 oobe_ui_->ShowSigninScreen(LoginScreenContext(), this, NULL);
43 void AppLaunchSigninScreen::InitOwnerUserList() {
44 user_manager::UserManager* user_manager = GetUserManager();
45 const std::string& owner_email = user_manager->GetOwnerEmail();
46 const user_manager::UserList& all_users = user_manager->GetUsers();
48 owner_user_list_.clear();
49 for (user_manager::UserList::const_iterator it = all_users.begin();
50 it != all_users.end();
51 ++it) {
52 user_manager::User* user = *it;
53 if (user->email() == owner_email) {
54 owner_user_list_.push_back(user);
55 break;
60 // static
61 void AppLaunchSigninScreen::SetUserManagerForTesting(
62 user_manager::UserManager* user_manager) {
63 test_user_manager_ = user_manager;
66 user_manager::UserManager* AppLaunchSigninScreen::GetUserManager() {
67 return test_user_manager_ ? test_user_manager_
68 : user_manager::UserManager::Get();
71 void AppLaunchSigninScreen::CancelPasswordChangedFlow() {
72 NOTREACHED();
75 void AppLaunchSigninScreen::CancelUserAdding() {
76 NOTREACHED();
79 void AppLaunchSigninScreen::CreateAccount() {
80 NOTREACHED();
83 void AppLaunchSigninScreen::CompleteLogin(const UserContext& user_context) {
84 NOTREACHED();
87 void AppLaunchSigninScreen::Login(const UserContext& user_context,
88 const SigninSpecifics& specifics) {
89 // Note: CreateAuthenticator doesn't necessarily create
90 // a new Authenticator object, and could reuse an existing one.
91 authenticator_ = UserSessionManager::GetInstance()->CreateAuthenticator(this);
92 content::BrowserThread::PostTask(
93 content::BrowserThread::UI, FROM_HERE,
94 base::Bind(&Authenticator::AuthenticateToUnlock,
95 authenticator_.get(),
96 user_context));
99 void AppLaunchSigninScreen::MigrateUserData(const std::string& old_password) {
100 NOTREACHED();
103 void AppLaunchSigninScreen::LoadWallpaper(const std::string& username) {
106 void AppLaunchSigninScreen::LoadSigninWallpaper() {
109 void AppLaunchSigninScreen::OnSigninScreenReady() {
112 void AppLaunchSigninScreen::RemoveUser(const std::string& username) {
113 NOTREACHED();
116 void AppLaunchSigninScreen::ResyncUserData() {
117 NOTREACHED();
120 void AppLaunchSigninScreen::ShowEnterpriseEnrollmentScreen() {
121 NOTREACHED();
124 void AppLaunchSigninScreen::ShowEnableDebuggingScreen() {
125 NOTREACHED();
128 void AppLaunchSigninScreen::ShowKioskEnableScreen() {
129 NOTREACHED();
132 void AppLaunchSigninScreen::ShowKioskAutolaunchScreen() {
133 NOTREACHED();
136 void AppLaunchSigninScreen::ShowWrongHWIDScreen() {
137 NOTREACHED();
140 void AppLaunchSigninScreen::SetWebUIHandler(
141 LoginDisplayWebUIHandler* webui_handler) {
142 webui_handler_ = webui_handler;
145 void AppLaunchSigninScreen::ShowSigninScreenForCreds(
146 const std::string& username,
147 const std::string& password) {
148 NOTREACHED();
151 const user_manager::UserList& AppLaunchSigninScreen::GetUsers() const {
152 if (test_user_manager_) {
153 return test_user_manager_->GetUsers();
155 return owner_user_list_;
158 bool AppLaunchSigninScreen::IsShowGuest() const {
159 return false;
162 bool AppLaunchSigninScreen::IsShowUsers() const {
163 return true;
166 bool AppLaunchSigninScreen::IsSigninInProgress() const {
167 // Return true to suppress network processing in the signin screen.
168 return true;
171 bool AppLaunchSigninScreen::IsUserSigninCompleted() const {
172 return false;
175 void AppLaunchSigninScreen::SetDisplayEmail(const std::string& email) {
176 return;
179 void AppLaunchSigninScreen::Signout() {
180 NOTREACHED();
183 void AppLaunchSigninScreen::OnAuthFailure(const AuthFailure& error) {
184 LOG(ERROR) << "Unlock failure: " << error.reason();
185 webui_handler_->ClearAndEnablePassword();
186 webui_handler_->ShowError(
187 0, l10n_util::GetStringUTF8(IDS_LOGIN_ERROR_AUTHENTICATING_KIOSK),
188 std::string(), HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
191 void AppLaunchSigninScreen::OnAuthSuccess(const UserContext& user_context) {
192 delegate_->OnOwnerSigninSuccess();
195 void AppLaunchSigninScreen::HandleGetUsers() {
196 base::ListValue users_list;
197 const user_manager::UserList& users = GetUsers();
199 for (user_manager::UserList::const_iterator it = users.begin();
200 it != users.end();
201 ++it) {
202 proximity_auth::ScreenlockBridge::LockHandler::AuthType initial_auth_type =
203 UserSelectionScreen::ShouldForceOnlineSignIn(*it)
204 ? proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN
205 : proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD;
206 base::DictionaryValue* user_dict = new base::DictionaryValue();
207 UserSelectionScreen::FillUserDictionary(
208 *it,
209 true, /* is_owner */
210 false, /* is_signin_to_add */
211 initial_auth_type,
212 NULL, /* public_session_recommended_locales */
213 user_dict);
214 users_list.Append(user_dict);
217 webui_handler_->LoadUsers(users_list, false);
220 void AppLaunchSigninScreen::CheckUserStatus(const std::string& user_id) {
223 bool AppLaunchSigninScreen::IsUserWhitelisted(const std::string& user_id) {
224 NOTREACHED();
225 return true;
228 } // namespace chromeos