[go: nahoru, domu]

blob: eda11a8ceb79a2f745f8346c8bf4138a12c497b2 [file] [log] [blame]
xiaoyinh2bbdd102017-05-18 23:29:421// Copyright 2017 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.
4
Jacob Dufaultffd9b0d2017-11-15 23:07:165#include "ash/login/login_screen_controller.h"
xiaoyinh2bbdd102017-05-18 23:29:426
Quan Nguyen92f924a2018-10-18 18:36:467#include <utility>
8
Quan Nguyen3d7a0f02018-09-04 23:53:559#include "ash/focus_cycler.h"
jdufaulteb4c9f1e2017-06-08 23:08:3010#include "ash/login/ui/lock_screen.h"
Jacob Dufault40623d52017-09-15 17:22:5311#include "ash/login/ui/login_data_dispatcher.h"
Henrique Grandinetti4eb2eae2019-05-31 16:31:1712#include "ash/login/ui/parent_access_widget.h"
Sarah Hu069eea12017-09-08 01:28:4013#include "ash/public/cpp/ash_pref_names.h"
Evan Stade2e4c22e2019-06-07 02:13:5514#include "ash/public/cpp/login_screen_client.h"
Anastasiia Nikolaienko94f9f7d2019-06-11 08:12:0715#include "ash/public/cpp/toast_data.h"
Aga Wronska16abb432018-01-11 23:49:5916#include "ash/root_window_controller.h"
Xiyuan Xiae7b19542019-05-06 23:05:1817#include "ash/session/session_controller_impl.h"
Jacob Dufault5ac266ef2018-07-18 17:30:3018#include "ash/shelf/login_shelf_view.h"
Quan Nguyend09dd112018-06-19 19:20:3219#include "ash/shelf/shelf.h"
20#include "ash/shelf/shelf_widget.h"
Sarah Hu069eea12017-09-08 01:28:4021#include "ash/shell.h"
Aga Wronska16abb432018-01-11 23:49:5922#include "ash/system/status_area_widget.h"
Quan Nguyen3d7a0f02018-09-04 23:53:5523#include "ash/system/status_area_widget_delegate.h"
Anastasiia Nikolaienko8cdd7e62019-06-12 12:16:2424#include "ash/system/toast/toast_manager_impl.h"
Jun Mukai5c7b5b42018-11-30 00:08:5025#include "ash/system/tray/system_tray_notifier.h"
Quan Nguyen92f924a2018-10-18 18:36:4626#include "base/bind.h"
Jacob Dufaultc06d6ca2018-04-24 23:49:1727#include "base/debug/alias.h"
Sarah Hu069eea12017-09-08 01:28:4028#include "base/strings/string_number_conversions.h"
Jialiu Linf99b788b2018-01-17 23:01:2129#include "base/strings/utf_string_conversions.h"
Sarah Hu069eea12017-09-08 01:28:4030#include "components/prefs/pref_registry_simple.h"
Jacob Dufault957e0922017-12-06 19:16:0931#include "components/session_manager/session_manager_types.h"
xiaoyinh2bbdd102017-05-18 23:29:4232
33namespace ash {
34
Sarah Hu069eea12017-09-08 01:28:4035namespace {
xiaoyinh2bbdd102017-05-18 23:29:4236
Aga Wronskaa844cdcd12018-01-29 16:06:4437enum class SystemTrayVisibility {
38 kNone, // Tray not visible anywhere.
39 kPrimary, // Tray visible only on primary display.
40 kAll, // Tray visible on all displays.
41};
42
43void SetSystemTrayVisibility(SystemTrayVisibility visibility) {
44 RootWindowController* primary_window_controller =
45 Shell::GetPrimaryRootWindowController();
46 for (RootWindowController* window_controller :
47 Shell::GetAllRootWindowControllers()) {
48 StatusAreaWidget* status_area = window_controller->GetStatusAreaWidget();
49 if (!status_area)
50 continue;
51 if (window_controller == primary_window_controller) {
52 status_area->SetSystemTrayVisibility(
53 visibility == SystemTrayVisibility::kPrimary ||
54 visibility == SystemTrayVisibility::kAll);
55 } else {
56 status_area->SetSystemTrayVisibility(visibility ==
57 SystemTrayVisibility::kAll);
58 }
59 }
Aga Wronska16abb432018-01-11 23:49:5960}
61
Sarah Hu069eea12017-09-08 01:28:4062} // namespace
63
Jun Mukai5c7b5b42018-11-30 00:08:5064LoginScreenController::LoginScreenController(
65 SystemTrayNotifier* system_tray_notifier)
66 : system_tray_notifier_(system_tray_notifier), weak_factory_(this) {
67 system_tray_notifier_->AddSystemTrayFocusObserver(this);
68}
James Cook8f1e6062017-11-13 23:40:5969
Jun Mukai5c7b5b42018-11-30 00:08:5070LoginScreenController::~LoginScreenController() {
71 system_tray_notifier_->RemoveSystemTrayFocusObserver(this);
72}
xiaoyinh2bbdd102017-05-18 23:29:4273
Sarah Hu069eea12017-09-08 01:28:4074// static
Jacob Dufaultffd9b0d2017-11-15 23:07:1675void LoginScreenController::RegisterProfilePrefs(PrefRegistrySimple* registry,
76 bool for_test) {
Sarah Hu069eea12017-09-08 01:28:4077 if (for_test) {
78 // There is no remote pref service, so pretend that ash owns the pref.
79 registry->RegisterStringPref(prefs::kQuickUnlockPinSalt, "");
80 return;
81 }
Sarah Hu069eea12017-09-08 01:28:4082}
83
Jacob Dufault2ca8c502018-06-25 19:12:1484bool LoginScreenController::IsAuthenticating() const {
85 return authentication_stage_ != AuthenticationStage::kIdle;
86}
87
Jacob Dufault2d20ae62018-09-20 22:19:5288void LoginScreenController::AuthenticateUserWithPasswordOrPin(
89 const AccountId& account_id,
90 const std::string& password,
91 bool authenticated_by_pin,
92 OnAuthenticateCallback callback) {
Jacob Dufault8876ba82018-03-27 22:55:4393 // It is an error to call this function while an authentication is in
94 // progress.
Jacob Dufault2d20ae62018-09-20 22:19:5295 LOG_IF(FATAL, IsAuthenticating())
Jacob Dufault58a1bf42018-07-10 17:44:5696 << "Duplicate authentication attempt; current authentication stage is "
97 << static_cast<int>(authentication_stage_);
Jacob Dufault8876ba82018-03-27 22:55:4398
Evan Stade2e4c22e2019-06-07 02:13:5599 if (!client_) {
Jacob Dufaultb7a2d842017-12-01 23:21:15100 std::move(callback).Run(base::nullopt);
xiaoyinh9f6fa0e2017-06-07 19:22:32101 return;
Jacob Dufaultb7a2d842017-12-01 23:21:15102 }
xiaoyinh9f6fa0e2017-06-07 19:22:32103
Jacob Dufaulteafc6fe2017-10-11 21:16:52104 // If auth is disabled by the debug overlay bypass the mojo call entirely, as
105 // it will dismiss the lock screen if the password is correct.
Jacob Dufault0fbed9c02017-11-14 19:22:24106 switch (force_fail_auth_for_debug_overlay_) {
107 case ForceFailAuth::kOff:
108 break;
109 case ForceFailAuth::kImmediate:
Jacob Dufaultb7a2d842017-12-01 23:21:15110 OnAuthenticateComplete(std::move(callback), false /*success*/);
Jacob Dufault0fbed9c02017-11-14 19:22:24111 return;
112 case ForceFailAuth::kDelayed:
Jacob Dufault2ca8c502018-06-25 19:12:14113 // Set a dummy authentication stage so that |IsAuthenticating| returns
114 // true.
115 authentication_stage_ = AuthenticationStage::kDoAuthenticate;
Jacob Dufault0fbed9c02017-11-14 19:22:24116 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
Jacob Dufaultb7a2d842017-12-01 23:21:15117 FROM_HERE,
118 base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
119 weak_factory_.GetWeakPtr(), base::Passed(&callback),
120 false),
Jacob Dufault0fbed9c02017-11-14 19:22:24121 base::TimeDelta::FromSeconds(1));
122 return;
Jacob Dufaulteafc6fe2017-10-11 21:16:52123 }
124
Quan Nguyenf5224352018-11-06 02:03:34125 authentication_stage_ = AuthenticationStage::kDoAuthenticate;
126
127 int dummy_value;
128 bool is_pin =
129 authenticated_by_pin && base::StringToInt(password, &dummy_value);
Evan Stade2e4c22e2019-06-07 02:13:55130 client_->AuthenticateUserWithPasswordOrPin(
Quan Nguyenf5224352018-11-06 02:03:34131 account_id, password, is_pin,
132 base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
133 weak_factory_.GetWeakPtr(), base::Passed(&callback)));
xiaoyinh9f6fa0e2017-06-07 19:22:32134}
135
Jacob Dufault2d20ae62018-09-20 22:19:52136void LoginScreenController::AuthenticateUserWithExternalBinary(
137 const AccountId& account_id,
138 OnAuthenticateCallback callback) {
139 // It is an error to call this function while an authentication is in
140 // progress.
141 LOG_IF(FATAL, IsAuthenticating())
142 << "Duplicate authentication attempt; current authentication stage is "
143 << static_cast<int>(authentication_stage_);
144
Evan Stade2e4c22e2019-06-07 02:13:55145 if (!client_) {
Jacob Dufault2d20ae62018-09-20 22:19:52146 std::move(callback).Run(base::nullopt);
147 return;
148 }
149
150 authentication_stage_ = AuthenticationStage::kDoAuthenticate;
Evan Stade2e4c22e2019-06-07 02:13:55151 client_->AuthenticateUserWithExternalBinary(
Jacob Dufault2d20ae62018-09-20 22:19:52152 account_id,
153 base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
154 weak_factory_.GetWeakPtr(), std::move(callback)));
155}
156
Quan Nguyen92f924a2018-10-18 18:36:46157void LoginScreenController::EnrollUserWithExternalBinary(
158 OnAuthenticateCallback callback) {
Evan Stade2e4c22e2019-06-07 02:13:55159 if (!client_) {
Quan Nguyen92f924a2018-10-18 18:36:46160 std::move(callback).Run(base::nullopt);
161 return;
162 }
163
Evan Stade2e4c22e2019-06-07 02:13:55164 client_->EnrollUserWithExternalBinary(base::BindOnce(
Quan Nguyen92f924a2018-10-18 18:36:46165 [](OnAuthenticateCallback callback, bool success) {
166 std::move(callback).Run(base::make_optional<bool>(success));
167 },
168 std::move(callback)));
169}
170
Jacob Dufault2d20ae62018-09-20 22:19:52171void LoginScreenController::AuthenticateUserWithEasyUnlock(
172 const AccountId& account_id) {
173 // TODO(jdufault): integrate this into authenticate stage after mojom is
174 // refactored to use a callback.
Evan Stade2e4c22e2019-06-07 02:13:55175 if (!client_)
xiaoyinh9f6fa0e2017-06-07 19:22:32176 return;
Evan Stade2e4c22e2019-06-07 02:13:55177 client_->AuthenticateUserWithEasyUnlock(account_id);
xiaoyinh9f6fa0e2017-06-07 19:22:32178}
179
Maksim Ivanov675dd762019-07-29 18:31:10180void LoginScreenController::AuthenticateUserWithChallengeResponse(
181 const AccountId& account_id,
182 OnAuthenticateCallback callback) {
183 LOG_IF(FATAL, IsAuthenticating())
184 << "Duplicate authentication attempt; current authentication stage is "
185 << static_cast<int>(authentication_stage_);
186
187 if (!client_) {
188 std::move(callback).Run(/*success=*/base::nullopt);
189 return;
190 }
191
192 authentication_stage_ = AuthenticationStage::kDoAuthenticate;
193 client_->AuthenticateUserWithChallengeResponse(
194 account_id,
195 base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
196 weak_factory_.GetWeakPtr(), std::move(callback)));
197}
198
Evan Stade2e4c22e2019-06-07 02:13:55199bool LoginScreenController::ValidateParentAccessCode(
Henrique Grandinetti4eb2eae2019-05-31 16:31:17200 const AccountId& account_id,
Evan Stade2e4c22e2019-06-07 02:13:55201 const std::string& code) {
202 if (!client_)
203 return false;
Aga Wronskaac6cf362019-02-26 21:36:55204
Evan Stade2e4c22e2019-06-07 02:13:55205 return client_->ValidateParentAccessCode(account_id, code);
Aga Wronskaac6cf362019-02-26 21:36:55206}
207
Jacob Dufaultffd9b0d2017-11-15 23:07:16208void LoginScreenController::HardlockPod(const AccountId& account_id) {
Evan Stade2e4c22e2019-06-07 02:13:55209 if (!client_)
xiaoyinh9f6fa0e2017-06-07 19:22:32210 return;
Evan Stade2e4c22e2019-06-07 02:13:55211 client_->HardlockPod(account_id);
xiaoyinh9f6fa0e2017-06-07 19:22:32212}
213
Jacob Dufaultffd9b0d2017-11-15 23:07:16214void LoginScreenController::OnFocusPod(const AccountId& account_id) {
Evan Stade2e4c22e2019-06-07 02:13:55215 if (!client_)
xiaoyinhf534c4f2017-06-13 20:50:27216 return;
Evan Stade2e4c22e2019-06-07 02:13:55217 client_->OnFocusPod(account_id);
xiaoyinhf534c4f2017-06-13 20:50:27218}
219
Jacob Dufaultffd9b0d2017-11-15 23:07:16220void LoginScreenController::OnNoPodFocused() {
Evan Stade2e4c22e2019-06-07 02:13:55221 if (!client_)
xiaoyinhf534c4f2017-06-13 20:50:27222 return;
Evan Stade2e4c22e2019-06-07 02:13:55223 client_->OnNoPodFocused();
xiaoyinhf534c4f2017-06-13 20:50:27224}
225
Jacob Dufaultffd9b0d2017-11-15 23:07:16226void LoginScreenController::LoadWallpaper(const AccountId& account_id) {
Evan Stade2e4c22e2019-06-07 02:13:55227 if (!client_)
xiaoyinhf534c4f2017-06-13 20:50:27228 return;
Evan Stade2e4c22e2019-06-07 02:13:55229 client_->LoadWallpaper(account_id);
xiaoyinhf534c4f2017-06-13 20:50:27230}
231
Jacob Dufaultffd9b0d2017-11-15 23:07:16232void LoginScreenController::SignOutUser() {
Evan Stade2e4c22e2019-06-07 02:13:55233 if (!client_)
xiaoyinhf534c4f2017-06-13 20:50:27234 return;
Evan Stade2e4c22e2019-06-07 02:13:55235 client_->SignOutUser();
xiaoyinhf534c4f2017-06-13 20:50:27236}
237
Jacob Dufaultffd9b0d2017-11-15 23:07:16238void LoginScreenController::CancelAddUser() {
Evan Stade2e4c22e2019-06-07 02:13:55239 if (!client_)
Wenzhao Zang16e7ea722017-09-16 01:27:30240 return;
Evan Stade2e4c22e2019-06-07 02:13:55241 client_->CancelAddUser();
Wenzhao Zang16e7ea722017-09-16 01:27:30242}
243
Aga Wronska6a32f9872018-01-06 00:16:10244void LoginScreenController::LoginAsGuest() {
Evan Stade2e4c22e2019-06-07 02:13:55245 if (!client_)
Aga Wronska6a32f9872018-01-06 00:16:10246 return;
Evan Stade2e4c22e2019-06-07 02:13:55247 client_->LoginAsGuest();
Aga Wronska6a32f9872018-01-06 00:16:10248}
249
Jacob Dufaultffd9b0d2017-11-15 23:07:16250void LoginScreenController::OnMaxIncorrectPasswordAttempted(
xiaoyinhf534c4f2017-06-13 20:50:27251 const AccountId& account_id) {
Evan Stade2e4c22e2019-06-07 02:13:55252 if (!client_)
xiaoyinhf534c4f2017-06-13 20:50:27253 return;
Evan Stade2e4c22e2019-06-07 02:13:55254 client_->OnMaxIncorrectPasswordAttempted(account_id);
xiaoyinhf534c4f2017-06-13 20:50:27255}
256
Jacob Dufaultffd9b0d2017-11-15 23:07:16257void LoginScreenController::FocusLockScreenApps(bool reverse) {
Evan Stade2e4c22e2019-06-07 02:13:55258 if (!client_)
Toni Barzicf61c4452017-10-05 03:57:48259 return;
Evan Stade2e4c22e2019-06-07 02:13:55260 client_->FocusLockScreenApps(reverse);
Toni Barzicf61c4452017-10-05 03:57:48261}
262
Evan Stade2e4c22e2019-06-07 02:13:55263void LoginScreenController::ShowGaiaSignin(bool can_close,
264 const AccountId& prefilled_account) {
265 if (!client_)
Sarah Hu9fba0e752018-02-07 01:41:09266 return;
Evan Stade2e4c22e2019-06-07 02:13:55267 client_->ShowGaiaSignin(can_close, prefilled_account);
Sarah Hu9fba0e752018-02-07 01:41:09268}
269
Jacob Dufaultfc31c742018-03-20 17:32:19270void LoginScreenController::OnRemoveUserWarningShown() {
Evan Stade2e4c22e2019-06-07 02:13:55271 if (!client_)
Jacob Dufaultfc31c742018-03-20 17:32:19272 return;
Evan Stade2e4c22e2019-06-07 02:13:55273 client_->OnRemoveUserWarningShown();
Jacob Dufaultfc31c742018-03-20 17:32:19274}
275
276void LoginScreenController::RemoveUser(const AccountId& account_id) {
Evan Stade2e4c22e2019-06-07 02:13:55277 if (!client_)
Jacob Dufaultfc31c742018-03-20 17:32:19278 return;
Evan Stade2e4c22e2019-06-07 02:13:55279 client_->RemoveUser(account_id);
Jacob Dufaultfc31c742018-03-20 17:32:19280}
281
Sarah Hu3fcf9f82018-03-22 20:32:54282void LoginScreenController::LaunchPublicSession(
283 const AccountId& account_id,
284 const std::string& locale,
285 const std::string& input_method) {
Evan Stade2e4c22e2019-06-07 02:13:55286 if (!client_)
Sarah Hu3fcf9f82018-03-22 20:32:54287 return;
Evan Stade2e4c22e2019-06-07 02:13:55288 client_->LaunchPublicSession(account_id, locale, input_method);
Sarah Hu3fcf9f82018-03-22 20:32:54289}
290
Sarah Huf9affb122018-04-27 21:36:36291void LoginScreenController::RequestPublicSessionKeyboardLayouts(
292 const AccountId& account_id,
293 const std::string& locale) {
Evan Stade2e4c22e2019-06-07 02:13:55294 if (!client_)
Sarah Huf9affb122018-04-27 21:36:36295 return;
Evan Stade2e4c22e2019-06-07 02:13:55296 client_->RequestPublicSessionKeyboardLayouts(account_id, locale);
Sarah Huf9affb122018-04-27 21:36:36297}
298
Sarah Hu0007c932018-06-18 20:21:04299void LoginScreenController::ShowFeedback() {
Evan Stade2e4c22e2019-06-07 02:13:55300 if (!client_)
Sarah Hu0007c932018-06-18 20:21:04301 return;
Evan Stade2e4c22e2019-06-07 02:13:55302 client_->ShowFeedback();
Sarah Hu0007c932018-06-18 20:21:04303}
304
Evan Stade2e4c22e2019-06-07 02:13:55305void LoginScreenController::SetClient(LoginScreenClient* client) {
306 client_ = client;
Toni Barzicf61c4452017-10-05 03:57:48307}
308
Evan Stadeb153f822019-05-23 19:14:43309LoginScreenModel* LoginScreenController::GetModel() {
Evan Stadeddde2b22019-05-24 20:51:31310 return &login_data_dispatcher_;
Evan Stadeb153f822019-05-23 19:14:43311}
312
Evan Stade9fe9cbe2019-06-03 23:05:55313void LoginScreenController::ShowKioskAppError(const std::string& message) {
314 ToastData toast_data(
315 "KioskAppError", base::UTF8ToUTF16(message), -1 /*duration_ms*/,
316 base::Optional<base::string16>(base::string16()) /*dismiss_text*/,
317 true /*visible_on_lock_screen*/);
318 Shell::Get()->toast_manager()->Show(toast_data);
319}
320
321void LoginScreenController::FocusLoginShelf(bool reverse) {
322 Shelf* shelf = Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow());
323 // Tell the focus direction to the status area or the shelf so they can focus
324 // the correct child view.
325 if (reverse || !ShelfWidget::IsUsingViewsShelf()) {
326 if (!Shell::GetPrimaryRootWindowController()->IsSystemTrayVisible())
327 return;
328 shelf->GetStatusAreaWidget()
329 ->status_area_widget_delegate()
330 ->set_default_last_focusable_child(reverse);
331 Shell::Get()->focus_cycler()->FocusWidget(shelf->GetStatusAreaWidget());
332 } else {
333 shelf->shelf_widget()->set_default_last_focusable_child(reverse);
334 Shell::Get()->focus_cycler()->FocusWidget(shelf->shelf_widget());
335 }
336}
337
338bool LoginScreenController::IsReadyForPassword() {
339 return LockScreen::HasInstance() && !IsAuthenticating();
340}
341
342void LoginScreenController::EnableAddUserButton(bool enable) {
343 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
344 ->shelf_widget()
345 ->login_shelf_view()
346 ->SetAddUserButtonEnabled(enable);
347}
348
349void LoginScreenController::EnableShutdownButton(bool enable) {
350 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
351 ->shelf_widget()
352 ->login_shelf_view()
353 ->SetShutdownButtonEnabled(enable);
354}
355
Evan Stade98b718e2019-06-03 17:15:34356void LoginScreenController::ShowGuestButtonInOobe(bool show) {
357 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
358 ->shelf_widget()
359 ->login_shelf_view()
360 ->ShowGuestButtonInOobe(show);
361}
362
363void LoginScreenController::ShowParentAccessButton(bool show) {
364 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
365 ->shelf_widget()
366 ->login_shelf_view()
367 ->ShowParentAccessButton(show);
368}
369
Henrique Grandinetti4eb2eae2019-05-31 16:31:17370void LoginScreenController::ShowParentAccessWidget(
371 const AccountId& child_account_id,
Henrique Grandinetti98b31502019-06-11 18:06:09372 base::RepeatingCallback<void(bool success)> callback,
Henrique Grandinetti91da2552019-06-24 14:25:56373 ParentAccessRequestReason reason,
374 bool extra_dimmer) {
Henrique Grandinetti98b31502019-06-11 18:06:09375 parent_access_widget_ = std::make_unique<ash::ParentAccessWidget>(
Henrique Grandinetti91da2552019-06-24 14:25:56376 child_account_id, callback, reason, extra_dimmer);
Henrique Grandinetti4eb2eae2019-05-31 16:31:17377}
378
Evan Stade9fe9cbe2019-06-03 23:05:55379void LoginScreenController::SetAllowLoginAsGuest(bool allow_guest) {
380 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
381 ->shelf_widget()
382 ->login_shelf_view()
383 ->SetAllowLoginAsGuest(allow_guest);
384}
385
Alexander Alekseev7020c6b52019-07-25 03:25:48386std::unique_ptr<ScopedGuestButtonBlocker>
387LoginScreenController::GetScopedGuestButtonBlocker() {
388 return Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
389 ->shelf_widget()
390 ->login_shelf_view()
391 ->GetScopedGuestButtonBlocker();
392}
393
Evan Stade2e4c22e2019-06-07 02:13:55394void LoginScreenController::ShowLockScreen() {
Jacob Dufault589d9942018-03-27 20:28:47395 OnShow();
Evan Stade98b718e2019-06-03 17:15:34396 LockScreen::Show(LockScreen::ScreenType::kLock);
Jacob Dufault589d9942018-03-27 20:28:47397}
398
Evan Stade2e4c22e2019-06-07 02:13:55399void LoginScreenController::ShowLoginScreen() {
Jacob Dufault589d9942018-03-27 20:28:47400 // Login screen can only be used during login.
Evan Stade2e4c22e2019-06-07 02:13:55401 CHECK_EQ(session_manager::SessionState::LOGIN_PRIMARY,
402 Shell::Get()->session_controller()->GetSessionState())
403 << "Not showing login screen since session state is "
404 << static_cast<int>(
405 Shell::Get()->session_controller()->GetSessionState());
Jacob Dufault589d9942018-03-27 20:28:47406
407 OnShow();
Evan Stade98b718e2019-06-03 17:15:34408 // TODO(jdufault): rename LockScreen to LoginScreen.
409 LockScreen::Show(LockScreen::ScreenType::kLogin);
Jacob Dufault589d9942018-03-27 20:28:47410}
411
Evan Stade9c07ab42019-05-13 21:21:56412void LoginScreenController::SetKioskApps(
413 const std::vector<KioskAppMenuEntry>& kiosk_apps,
414 const base::RepeatingCallback<void(const KioskAppMenuEntry&)>& launch_app) {
415 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
416 ->shelf_widget()
417 ->login_shelf_view()
418 ->SetKioskApps(kiosk_apps, launch_app);
419}
420
Quan Nguyene3e1d252018-07-19 23:00:44421void LoginScreenController::ShowResetScreen() {
Evan Stade2e4c22e2019-06-07 02:13:55422 client_->ShowResetScreen();
Quan Nguyene3e1d252018-07-19 23:00:44423}
424
Quan Nguyenff20e232018-08-02 21:34:11425void LoginScreenController::ShowAccountAccessHelpApp() {
Evan Stade2e4c22e2019-06-07 02:13:55426 client_->ShowAccountAccessHelpApp();
Quan Nguyenff20e232018-08-02 21:34:11427}
428
Evan Stade3c971bc2019-06-11 22:12:44429void LoginScreenController::ShowLockScreenNotificationSettings() {
430 client_->ShowLockScreenNotificationSettings();
431}
432
Quan Nguyen3d7a0f02018-09-04 23:53:55433void LoginScreenController::FocusOobeDialog() {
Evan Stade2e4c22e2019-06-07 02:13:55434 if (!client_)
Tony de Luna46801932019-03-11 18:02:01435 return;
Evan Stade2e4c22e2019-06-07 02:13:55436 client_->FocusOobeDialog();
Quan Nguyen3d7a0f02018-09-04 23:53:55437}
438
Quan Nguyene377eb62019-02-11 23:02:25439void LoginScreenController::NotifyUserActivity() {
Evan Stade2e4c22e2019-06-07 02:13:55440 if (!client_)
Xiyuan Xia5a8c4172019-05-13 16:23:48441 return;
Evan Stade2e4c22e2019-06-07 02:13:55442 client_->OnUserActivity();
Quan Nguyene377eb62019-02-11 23:02:25443}
444
Jacob Dufaultb7a2d842017-12-01 23:21:15445void LoginScreenController::OnAuthenticateComplete(
446 OnAuthenticateCallback callback,
447 bool success) {
Jacob Dufault8876ba82018-03-27 22:55:43448 authentication_stage_ = AuthenticationStage::kUserCallback;
Quan Nguyen92f924a2018-10-18 18:36:46449 std::move(callback).Run(base::make_optional<bool>(success));
Jacob Dufault8876ba82018-03-27 22:55:43450 authentication_stage_ = AuthenticationStage::kIdle;
xiaoyinh2bbdd102017-05-18 23:29:42451}
452
Jacob Dufaultcbc1ee02018-02-28 18:38:54453void LoginScreenController::OnShow() {
454 SetSystemTrayVisibility(SystemTrayVisibility::kPrimary);
Jacob Dufaultc06d6ca2018-04-24 23:49:17455 if (authentication_stage_ != AuthenticationStage::kIdle) {
456 AuthenticationStage authentication_stage = authentication_stage_;
457 base::debug::Alias(&authentication_stage);
458 LOG(FATAL) << "Unexpected authentication stage "
459 << static_cast<int>(authentication_stage_);
460 }
Jacob Dufaultcbc1ee02018-02-28 18:38:54461}
462
Jun Mukai5c7b5b42018-11-30 00:08:50463void LoginScreenController::OnFocusLeavingSystemTray(bool reverse) {
Evan Stade2e4c22e2019-06-07 02:13:55464 if (!client_)
Jun Mukai5c7b5b42018-11-30 00:08:50465 return;
Evan Stade2e4c22e2019-06-07 02:13:55466 client_->OnFocusLeavingSystemTray(reverse);
Jun Mukai5c7b5b42018-11-30 00:08:50467}
468
xiaoyinh2bbdd102017-05-18 23:29:42469} // namespace ash