[go: nahoru, domu]

blob: a1c241c613ac1c265e1fc831a75156ade4e000cd [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"
Sarah Hu069eea12017-09-08 01:28:4012#include "ash/public/cpp/ash_pref_names.h"
Aga Wronska16abb432018-01-11 23:49:5913#include "ash/root_window_controller.h"
Xiyuan Xiae7b19542019-05-06 23:05:1814#include "ash/session/session_controller_impl.h"
Jacob Dufault5ac266ef2018-07-18 17:30:3015#include "ash/shelf/login_shelf_view.h"
Quan Nguyend09dd112018-06-19 19:20:3216#include "ash/shelf/shelf.h"
17#include "ash/shelf/shelf_widget.h"
Sarah Hu069eea12017-09-08 01:28:4018#include "ash/shell.h"
Aga Wronska16abb432018-01-11 23:49:5919#include "ash/system/status_area_widget.h"
Quan Nguyen3d7a0f02018-09-04 23:53:5520#include "ash/system/status_area_widget_delegate.h"
Quan Nguyenb7c2ea22018-09-10 17:44:1821#include "ash/system/toast/toast_data.h"
22#include "ash/system/toast/toast_manager.h"
Jun Mukai5c7b5b42018-11-30 00:08:5023#include "ash/system/tray/system_tray_notifier.h"
Quan Nguyen92f924a2018-10-18 18:36:4624#include "base/bind.h"
Jacob Dufaultc06d6ca2018-04-24 23:49:1725#include "base/debug/alias.h"
Sarah Hu069eea12017-09-08 01:28:4026#include "base/strings/string_number_conversions.h"
Jialiu Linf99b788b2018-01-17 23:01:2127#include "base/strings/utf_string_conversions.h"
Sarah Hu069eea12017-09-08 01:28:4028#include "components/prefs/pref_registry_simple.h"
Jacob Dufault957e0922017-12-06 19:16:0929#include "components/session_manager/session_manager_types.h"
xiaoyinh2bbdd102017-05-18 23:29:4230
31namespace ash {
32
Sarah Hu069eea12017-09-08 01:28:4033namespace {
xiaoyinh2bbdd102017-05-18 23:29:4234
Aga Wronskaa844cdcd12018-01-29 16:06:4435enum class SystemTrayVisibility {
36 kNone, // Tray not visible anywhere.
37 kPrimary, // Tray visible only on primary display.
38 kAll, // Tray visible on all displays.
39};
40
41void SetSystemTrayVisibility(SystemTrayVisibility visibility) {
42 RootWindowController* primary_window_controller =
43 Shell::GetPrimaryRootWindowController();
44 for (RootWindowController* window_controller :
45 Shell::GetAllRootWindowControllers()) {
46 StatusAreaWidget* status_area = window_controller->GetStatusAreaWidget();
47 if (!status_area)
48 continue;
49 if (window_controller == primary_window_controller) {
50 status_area->SetSystemTrayVisibility(
51 visibility == SystemTrayVisibility::kPrimary ||
52 visibility == SystemTrayVisibility::kAll);
53 } else {
54 status_area->SetSystemTrayVisibility(visibility ==
55 SystemTrayVisibility::kAll);
56 }
57 }
Aga Wronska16abb432018-01-11 23:49:5958}
59
Sarah Hu069eea12017-09-08 01:28:4060} // namespace
61
Jun Mukai5c7b5b42018-11-30 00:08:5062LoginScreenController::LoginScreenController(
63 SystemTrayNotifier* system_tray_notifier)
64 : system_tray_notifier_(system_tray_notifier), weak_factory_(this) {
65 system_tray_notifier_->AddSystemTrayFocusObserver(this);
66}
James Cook8f1e6062017-11-13 23:40:5967
Jun Mukai5c7b5b42018-11-30 00:08:5068LoginScreenController::~LoginScreenController() {
69 system_tray_notifier_->RemoveSystemTrayFocusObserver(this);
70}
xiaoyinh2bbdd102017-05-18 23:29:4271
Sarah Hu069eea12017-09-08 01:28:4072// static
Jacob Dufaultffd9b0d2017-11-15 23:07:1673void LoginScreenController::RegisterProfilePrefs(PrefRegistrySimple* registry,
74 bool for_test) {
Sarah Hu069eea12017-09-08 01:28:4075 if (for_test) {
76 // There is no remote pref service, so pretend that ash owns the pref.
77 registry->RegisterStringPref(prefs::kQuickUnlockPinSalt, "");
78 return;
79 }
Sarah Hu069eea12017-09-08 01:28:4080}
81
Jacob Dufaultffd9b0d2017-11-15 23:07:1682void LoginScreenController::BindRequest(mojom::LoginScreenRequest request) {
James Cookede316a2017-12-14 22:38:4383 bindings_.AddBinding(this, std::move(request));
xiaoyinh2bbdd102017-05-18 23:29:4284}
85
Jacob Dufault2ca8c502018-06-25 19:12:1486bool LoginScreenController::IsAuthenticating() const {
87 return authentication_stage_ != AuthenticationStage::kIdle;
88}
89
Jacob Dufault2d20ae62018-09-20 22:19:5290void LoginScreenController::AuthenticateUserWithPasswordOrPin(
91 const AccountId& account_id,
92 const std::string& password,
93 bool authenticated_by_pin,
94 OnAuthenticateCallback callback) {
Jacob Dufault8876ba82018-03-27 22:55:4395 // It is an error to call this function while an authentication is in
96 // progress.
Jacob Dufault2d20ae62018-09-20 22:19:5297 LOG_IF(FATAL, IsAuthenticating())
Jacob Dufault58a1bf42018-07-10 17:44:5698 << "Duplicate authentication attempt; current authentication stage is "
99 << static_cast<int>(authentication_stage_);
Jacob Dufault8876ba82018-03-27 22:55:43100
101 if (!login_screen_client_) {
Jacob Dufaultb7a2d842017-12-01 23:21:15102 std::move(callback).Run(base::nullopt);
xiaoyinh9f6fa0e2017-06-07 19:22:32103 return;
Jacob Dufaultb7a2d842017-12-01 23:21:15104 }
xiaoyinh9f6fa0e2017-06-07 19:22:32105
Jacob Dufaulteafc6fe2017-10-11 21:16:52106 // If auth is disabled by the debug overlay bypass the mojo call entirely, as
107 // it will dismiss the lock screen if the password is correct.
Jacob Dufault0fbed9c02017-11-14 19:22:24108 switch (force_fail_auth_for_debug_overlay_) {
109 case ForceFailAuth::kOff:
110 break;
111 case ForceFailAuth::kImmediate:
Jacob Dufaultb7a2d842017-12-01 23:21:15112 OnAuthenticateComplete(std::move(callback), false /*success*/);
Jacob Dufault0fbed9c02017-11-14 19:22:24113 return;
114 case ForceFailAuth::kDelayed:
Jacob Dufault2ca8c502018-06-25 19:12:14115 // Set a dummy authentication stage so that |IsAuthenticating| returns
116 // true.
117 authentication_stage_ = AuthenticationStage::kDoAuthenticate;
Jacob Dufault0fbed9c02017-11-14 19:22:24118 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
Jacob Dufaultb7a2d842017-12-01 23:21:15119 FROM_HERE,
120 base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
121 weak_factory_.GetWeakPtr(), base::Passed(&callback),
122 false),
Jacob Dufault0fbed9c02017-11-14 19:22:24123 base::TimeDelta::FromSeconds(1));
124 return;
Jacob Dufaulteafc6fe2017-10-11 21:16:52125 }
126
Quan Nguyenf5224352018-11-06 02:03:34127 authentication_stage_ = AuthenticationStage::kDoAuthenticate;
128
129 int dummy_value;
130 bool is_pin =
131 authenticated_by_pin && base::StringToInt(password, &dummy_value);
132 login_screen_client_->AuthenticateUserWithPasswordOrPin(
133 account_id, password, is_pin,
134 base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
135 weak_factory_.GetWeakPtr(), base::Passed(&callback)));
xiaoyinh9f6fa0e2017-06-07 19:22:32136}
137
Jacob Dufault2d20ae62018-09-20 22:19:52138void LoginScreenController::AuthenticateUserWithExternalBinary(
139 const AccountId& account_id,
140 OnAuthenticateCallback callback) {
141 // It is an error to call this function while an authentication is in
142 // progress.
143 LOG_IF(FATAL, IsAuthenticating())
144 << "Duplicate authentication attempt; current authentication stage is "
145 << static_cast<int>(authentication_stage_);
146
147 if (!login_screen_client_) {
148 std::move(callback).Run(base::nullopt);
149 return;
150 }
151
152 authentication_stage_ = AuthenticationStage::kDoAuthenticate;
153 login_screen_client_->AuthenticateUserWithExternalBinary(
154 account_id,
155 base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
156 weak_factory_.GetWeakPtr(), std::move(callback)));
157}
158
Quan Nguyen92f924a2018-10-18 18:36:46159void LoginScreenController::EnrollUserWithExternalBinary(
160 OnAuthenticateCallback callback) {
161 if (!login_screen_client_) {
162 std::move(callback).Run(base::nullopt);
163 return;
164 }
165
166 login_screen_client_->EnrollUserWithExternalBinary(base::BindOnce(
167 [](OnAuthenticateCallback callback, bool success) {
168 std::move(callback).Run(base::make_optional<bool>(success));
169 },
170 std::move(callback)));
171}
172
Jacob Dufault2d20ae62018-09-20 22:19:52173void LoginScreenController::AuthenticateUserWithEasyUnlock(
174 const AccountId& account_id) {
175 // TODO(jdufault): integrate this into authenticate stage after mojom is
176 // refactored to use a callback.
Jacob Dufaultffd9b0d2017-11-15 23:07:16177 if (!login_screen_client_)
xiaoyinh9f6fa0e2017-06-07 19:22:32178 return;
Jacob Dufault2d20ae62018-09-20 22:19:52179 login_screen_client_->AuthenticateUserWithEasyUnlock(account_id);
xiaoyinh9f6fa0e2017-06-07 19:22:32180}
181
Aga Wronskaac6cf362019-02-26 21:36:55182void LoginScreenController::ValidateParentAccessCode(
Henrique Grandinetti88a6a712019-05-17 22:31:13183 const base::Optional<AccountId>& account_id,
Aga Wronskaac6cf362019-02-26 21:36:55184 const std::string& code,
185 OnParentAccessValidation callback) {
186 if (!login_screen_client_) {
187 std::move(callback).Run(base::nullopt);
188 return;
189 }
190
191 login_screen_client_->ValidateParentAccessCode(
192 account_id, code,
193 base::BindOnce(&LoginScreenController::OnParentAccessValidationComplete,
194 weak_factory_.GetWeakPtr(), std::move(callback)));
195}
196
Jacob Dufaultffd9b0d2017-11-15 23:07:16197void LoginScreenController::HardlockPod(const AccountId& account_id) {
198 if (!login_screen_client_)
xiaoyinh9f6fa0e2017-06-07 19:22:32199 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16200 login_screen_client_->HardlockPod(account_id);
xiaoyinh9f6fa0e2017-06-07 19:22:32201}
202
Jacob Dufaultffd9b0d2017-11-15 23:07:16203void LoginScreenController::OnFocusPod(const AccountId& account_id) {
204 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27205 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16206 login_screen_client_->OnFocusPod(account_id);
xiaoyinhf534c4f2017-06-13 20:50:27207}
208
Jacob Dufaultffd9b0d2017-11-15 23:07:16209void LoginScreenController::OnNoPodFocused() {
210 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27211 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16212 login_screen_client_->OnNoPodFocused();
xiaoyinhf534c4f2017-06-13 20:50:27213}
214
Jacob Dufaultffd9b0d2017-11-15 23:07:16215void LoginScreenController::LoadWallpaper(const AccountId& account_id) {
216 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27217 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16218 login_screen_client_->LoadWallpaper(account_id);
xiaoyinhf534c4f2017-06-13 20:50:27219}
220
Jacob Dufaultffd9b0d2017-11-15 23:07:16221void LoginScreenController::SignOutUser() {
222 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27223 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16224 login_screen_client_->SignOutUser();
xiaoyinhf534c4f2017-06-13 20:50:27225}
226
Jacob Dufaultffd9b0d2017-11-15 23:07:16227void LoginScreenController::CancelAddUser() {
228 if (!login_screen_client_)
Wenzhao Zang16e7ea722017-09-16 01:27:30229 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16230 login_screen_client_->CancelAddUser();
Wenzhao Zang16e7ea722017-09-16 01:27:30231}
232
Aga Wronska6a32f9872018-01-06 00:16:10233void LoginScreenController::LoginAsGuest() {
234 if (!login_screen_client_)
235 return;
236 login_screen_client_->LoginAsGuest();
237}
238
Jacob Dufaultffd9b0d2017-11-15 23:07:16239void LoginScreenController::OnMaxIncorrectPasswordAttempted(
xiaoyinhf534c4f2017-06-13 20:50:27240 const AccountId& account_id) {
Jacob Dufaultffd9b0d2017-11-15 23:07:16241 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27242 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16243 login_screen_client_->OnMaxIncorrectPasswordAttempted(account_id);
xiaoyinhf534c4f2017-06-13 20:50:27244}
245
Jacob Dufaultffd9b0d2017-11-15 23:07:16246void LoginScreenController::FocusLockScreenApps(bool reverse) {
247 if (!login_screen_client_)
Toni Barzicf61c4452017-10-05 03:57:48248 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16249 login_screen_client_->FocusLockScreenApps(reverse);
Toni Barzicf61c4452017-10-05 03:57:48250}
251
Wenzhao Zang767a9f32018-05-02 21:20:55252void LoginScreenController::ShowGaiaSignin(
Jacob Dufaultfb72607d2018-06-12 19:50:33253 bool can_close,
254 const base::Optional<AccountId>& prefilled_account) {
Sarah Hu9fba0e752018-02-07 01:41:09255 if (!login_screen_client_)
256 return;
Jacob Dufaultfb72607d2018-06-12 19:50:33257 login_screen_client_->ShowGaiaSignin(can_close, prefilled_account);
Sarah Hu9fba0e752018-02-07 01:41:09258}
259
Jacob Dufaultfc31c742018-03-20 17:32:19260void LoginScreenController::OnRemoveUserWarningShown() {
261 if (!login_screen_client_)
262 return;
263 login_screen_client_->OnRemoveUserWarningShown();
264}
265
266void LoginScreenController::RemoveUser(const AccountId& account_id) {
267 if (!login_screen_client_)
268 return;
269 login_screen_client_->RemoveUser(account_id);
270}
271
Sarah Hu3fcf9f82018-03-22 20:32:54272void LoginScreenController::LaunchPublicSession(
273 const AccountId& account_id,
274 const std::string& locale,
275 const std::string& input_method) {
276 if (!login_screen_client_)
277 return;
278 login_screen_client_->LaunchPublicSession(account_id, locale, input_method);
279}
280
Sarah Huf9affb122018-04-27 21:36:36281void LoginScreenController::RequestPublicSessionKeyboardLayouts(
282 const AccountId& account_id,
283 const std::string& locale) {
284 if (!login_screen_client_)
285 return;
286 login_screen_client_->RequestPublicSessionKeyboardLayouts(account_id, locale);
287}
288
Sarah Hu0007c932018-06-18 20:21:04289void LoginScreenController::ShowFeedback() {
290 if (!login_screen_client_)
291 return;
292 login_screen_client_->ShowFeedback();
293}
294
Jacob Dufaultffd9b0d2017-11-15 23:07:16295void LoginScreenController::FlushForTesting() {
296 login_screen_client_.FlushForTesting();
Toni Barzicf61c4452017-10-05 03:57:48297}
298
Evan Stadeb153f822019-05-23 19:14:43299LoginScreenModel* LoginScreenController::GetModel() {
Evan Stadeddde2b22019-05-24 20:51:31300 return &login_data_dispatcher_;
Evan Stadeb153f822019-05-23 19:14:43301}
302
Jacob Dufault589d9942018-03-27 20:28:47303void LoginScreenController::SetClient(mojom::LoginScreenClientPtr client) {
304 login_screen_client_ = std::move(client);
305}
306
307void LoginScreenController::ShowLockScreen(ShowLockScreenCallback on_shown) {
308 OnShow();
309 ash::LockScreen::Show(ash::LockScreen::ScreenType::kLock);
310 std::move(on_shown).Run(true);
311}
312
313void LoginScreenController::ShowLoginScreen(ShowLoginScreenCallback on_shown) {
314 // Login screen can only be used during login.
315 if (Shell::Get()->session_controller()->GetSessionState() !=
316 session_manager::SessionState::LOGIN_PRIMARY) {
317 LOG(ERROR) << "Not showing login screen since session state is "
318 << static_cast<int>(
319 Shell::Get()->session_controller()->GetSessionState());
320 std::move(on_shown).Run(false);
321 return;
322 }
323
324 OnShow();
325 // TODO(jdufault): rename ash::LockScreen to ash::LoginScreen.
326 ash::LockScreen::Show(ash::LockScreen::ScreenType::kLogin);
327 std::move(on_shown).Run(true);
328}
329
330void LoginScreenController::ShowErrorMessage(int32_t login_attempts,
331 const std::string& error_text,
332 const std::string& help_link_text,
333 int32_t help_topic_id) {
334 NOTIMPLEMENTED();
335}
336
Naoki Fukino00a14cbc2018-08-08 05:27:22337void LoginScreenController::ShowWarningBanner(const base::string16& message) {
Evan Stadeddde2b22019-05-24 20:51:31338 login_data_dispatcher_.ShowWarningBanner(message);
Naoki Fukino00a14cbc2018-08-08 05:27:22339}
340
341void LoginScreenController::HideWarningBanner() {
Evan Stadeddde2b22019-05-24 20:51:31342 login_data_dispatcher_.HideWarningBanner();
Naoki Fukino00a14cbc2018-08-08 05:27:22343}
344
Jacob Dufault589d9942018-03-27 20:28:47345void LoginScreenController::ClearErrors() {
346 NOTIMPLEMENTED();
347}
348
Jacob Dufault589d9942018-03-27 20:28:47349void LoginScreenController::SetAuthType(
350 const AccountId& account_id,
351 proximity_auth::mojom::AuthType auth_type,
352 const base::string16& initial_value) {
353 if (auth_type == proximity_auth::mojom::AuthType::USER_CLICK) {
Evan Stadeddde2b22019-05-24 20:51:31354 login_data_dispatcher_.SetTapToUnlockEnabledForUser(account_id,
355 true /*enabled*/);
Wenzhao Zang767a9f32018-05-02 21:20:55356 } else if (auth_type == proximity_auth::mojom::AuthType::ONLINE_SIGN_IN) {
Evan Stadeddde2b22019-05-24 20:51:31357 login_data_dispatcher_.SetForceOnlineSignInForUser(account_id);
Jacob Dufault589d9942018-03-27 20:28:47358 } else {
359 NOTIMPLEMENTED();
360 }
361}
362
Jacob Dufault589d9942018-03-27 20:28:47363void LoginScreenController::SetPinEnabledForUser(const AccountId& account_id,
364 bool is_enabled) {
365 // Chrome will update pin pod state every time user tries to authenticate.
366 // LockScreen is destroyed in the case of authentication success.
Evan Stadeddde2b22019-05-24 20:51:31367 login_data_dispatcher_.SetPinEnabledForUser(account_id, is_enabled);
Jacob Dufault589d9942018-03-27 20:28:47368}
369
Jacob Dufault947f2472018-10-24 21:08:16370void LoginScreenController::NotifyFingerprintAuthResult(
371 const AccountId& account_id,
372 bool successful) {
Evan Stadeddde2b22019-05-24 20:51:31373 login_data_dispatcher_.NotifyFingerprintAuthResult(account_id, successful);
Jacob Dufault947f2472018-10-24 21:08:16374}
375
Henrique Grandinettid8951be2019-03-15 21:04:05376void LoginScreenController::EnableAuthForUser(const AccountId& account_id) {
Evan Stadeddde2b22019-05-24 20:51:31377 login_data_dispatcher_.EnableAuthForUser(account_id);
Henrique Grandinettid8951be2019-03-15 21:04:05378}
379
380void LoginScreenController::DisableAuthForUser(
Wenzhao Zange0c2ab22018-05-23 17:43:46381 const AccountId& account_id,
Henrique Grandinettid8951be2019-03-15 21:04:05382 ash::mojom::AuthDisabledDataPtr auth_disabled_data) {
Evan Stadeddde2b22019-05-24 20:51:31383 login_data_dispatcher_.DisableAuthForUser(account_id,
384 std::move(auth_disabled_data));
Jacob Dufault589d9942018-03-27 20:28:47385}
386
Jacob Dufault5fc31392018-10-03 22:15:02387void LoginScreenController::SetSystemInfo(
388 bool show_if_hidden,
Jacob Dufault589d9942018-03-27 20:28:47389 const std::string& os_version_label_text,
390 const std::string& enterprise_info_text,
391 const std::string& bluetooth_name) {
Evan Stadeddde2b22019-05-24 20:51:31392 login_data_dispatcher_.SetSystemInfo(show_if_hidden, os_version_label_text,
393 enterprise_info_text, bluetooth_name);
Jacob Dufault589d9942018-03-27 20:28:47394}
395
396void LoginScreenController::IsReadyForPassword(
397 IsReadyForPasswordCallback callback) {
Jacob Dufault2ca8c502018-06-25 19:12:14398 std::move(callback).Run(LockScreen::HasInstance() && !IsAuthenticating());
Jacob Dufault589d9942018-03-27 20:28:47399}
400
401void LoginScreenController::SetPublicSessionDisplayName(
402 const AccountId& account_id,
403 const std::string& display_name) {
Evan Stadeddde2b22019-05-24 20:51:31404 login_data_dispatcher_.SetPublicSessionDisplayName(account_id, display_name);
Jacob Dufault589d9942018-03-27 20:28:47405}
406
Zakhar Voitf99f63b2018-12-04 00:37:33407void LoginScreenController::SetPublicSessionShowFullManagementDisclosure(
408 bool is_full_management_disclosure_needed) {
Evan Stadeddde2b22019-05-24 20:51:31409 login_data_dispatcher_.SetPublicSessionShowFullManagementDisclosure(
410 is_full_management_disclosure_needed);
Zakhar Voitf99f63b2018-12-04 00:37:33411}
412
Quan Nguyenb7c2ea22018-09-10 17:44:18413void LoginScreenController::ShowKioskAppError(const std::string& message) {
414 ToastData toast_data(
415 "KioskAppError", base::UTF8ToUTF16(message), -1 /*duration_ms*/,
416 base::Optional<base::string16>(base::string16()) /*dismiss_text*/,
417 true /*visible_on_lock_screen*/);
418 Shell::Get()->toast_manager()->Show(toast_data);
419}
420
Sarah Hu51d19d32018-08-27 19:41:50421void LoginScreenController::SetAllowLoginAsGuest(bool allow_guest) {
422 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
423 ->shelf_widget()
424 ->login_shelf_view()
425 ->SetAllowLoginAsGuest(allow_guest);
426}
427
Quan Nguyencb8acab2018-12-05 20:39:08428void LoginScreenController::SetShowGuestButtonInOobe(bool show) {
Sarah Hu51d19d32018-08-27 19:41:50429 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
430 ->shelf_widget()
431 ->login_shelf_view()
Quan Nguyencb8acab2018-12-05 20:39:08432 ->SetShowGuestButtonInOobe(show);
Jacob Dufault883dcf72018-06-27 22:52:32433}
434
Aga Wronska49827d32019-02-01 03:36:39435void LoginScreenController::SetShowParentAccessButton(bool show) {
Aga Wronska850597a2019-01-02 22:07:23436 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
437 ->shelf_widget()
438 ->login_shelf_view()
Aga Wronska49827d32019-02-01 03:36:39439 ->SetShowParentAccessButton(show);
Aga Wronska850597a2019-01-02 22:07:23440}
441
Aga Wronska143a18a2019-02-13 23:07:17442void LoginScreenController::SetShowParentAccessDialog(bool show) {
Evan Stadeddde2b22019-05-24 20:51:31443 login_data_dispatcher_.SetShowParentAccessDialog(show);
Aga Wronska143a18a2019-02-13 23:07:17444}
445
Quan Nguyen3d7a0f02018-09-04 23:53:55446void LoginScreenController::FocusLoginShelf(bool reverse) {
447 Shelf* shelf = Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow());
448 // Tell the focus direction to the status area or the shelf so they can focus
449 // the correct child view.
Jun Mukai103f57b2018-11-15 01:03:01450 if (reverse || !ShelfWidget::IsUsingViewsShelf()) {
451 if (!Shell::GetPrimaryRootWindowController()->IsSystemTrayVisible())
Jun Mukaid96b4d7452018-11-09 00:37:23452 return;
Quan Nguyen3d7a0f02018-09-04 23:53:55453 shelf->GetStatusAreaWidget()
454 ->status_area_widget_delegate()
455 ->set_default_last_focusable_child(reverse);
456 Shell::Get()->focus_cycler()->FocusWidget(shelf->GetStatusAreaWidget());
457 } else {
458 shelf->shelf_widget()->set_default_last_focusable_child(reverse);
459 Shell::Get()->focus_cycler()->FocusWidget(shelf->shelf_widget());
460 }
461}
462
Evan Stade9c07ab42019-05-13 21:21:56463void LoginScreenController::SetKioskApps(
464 const std::vector<KioskAppMenuEntry>& kiosk_apps,
465 const base::RepeatingCallback<void(const KioskAppMenuEntry&)>& launch_app) {
466 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
467 ->shelf_widget()
468 ->login_shelf_view()
469 ->SetKioskApps(kiosk_apps, launch_app);
470}
471
Sarah Hu4976046e2018-07-19 23:47:47472void LoginScreenController::SetAddUserButtonEnabled(bool enable) {
473 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
474 ->shelf_widget()
475 ->login_shelf_view()
476 ->SetAddUserButtonEnabled(enable);
477}
478
Bruno Santoscf9d9cc2018-12-14 13:18:45479void LoginScreenController::SetShutdownButtonEnabled(bool enable) {
480 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
481 ->shelf_widget()
482 ->login_shelf_view()
483 ->SetShutdownButtonEnabled(enable);
484}
485
Quan Nguyene3e1d252018-07-19 23:00:44486void LoginScreenController::ShowResetScreen() {
487 login_screen_client_->ShowResetScreen();
488}
489
Quan Nguyenff20e232018-08-02 21:34:11490void LoginScreenController::ShowAccountAccessHelpApp() {
491 login_screen_client_->ShowAccountAccessHelpApp();
492}
493
Quan Nguyen3d7a0f02018-09-04 23:53:55494void LoginScreenController::FocusOobeDialog() {
Tony de Luna46801932019-03-11 18:02:01495 if (!login_screen_client_)
496 return;
Quan Nguyen3d7a0f02018-09-04 23:53:55497 login_screen_client_->FocusOobeDialog();
498}
499
Quan Nguyene377eb62019-02-11 23:02:25500void LoginScreenController::NotifyUserActivity() {
Xiyuan Xia5a8c4172019-05-13 16:23:48501 if (!login_screen_client_)
502 return;
Quan Nguyene377eb62019-02-11 23:02:25503 login_screen_client_->OnUserActivity();
504}
505
Jacob Dufaultb7a2d842017-12-01 23:21:15506void LoginScreenController::OnAuthenticateComplete(
507 OnAuthenticateCallback callback,
508 bool success) {
Jacob Dufault8876ba82018-03-27 22:55:43509 authentication_stage_ = AuthenticationStage::kUserCallback;
Quan Nguyen92f924a2018-10-18 18:36:46510 std::move(callback).Run(base::make_optional<bool>(success));
Jacob Dufault8876ba82018-03-27 22:55:43511 authentication_stage_ = AuthenticationStage::kIdle;
xiaoyinh2bbdd102017-05-18 23:29:42512}
513
Aga Wronskaac6cf362019-02-26 21:36:55514void LoginScreenController::OnParentAccessValidationComplete(
515 OnParentAccessValidation callback,
516 bool success) {
517 std::move(callback).Run(base::make_optional<bool>(success));
518}
519
Jacob Dufaultcbc1ee02018-02-28 18:38:54520void LoginScreenController::OnShow() {
521 SetSystemTrayVisibility(SystemTrayVisibility::kPrimary);
Jacob Dufaultc06d6ca2018-04-24 23:49:17522 if (authentication_stage_ != AuthenticationStage::kIdle) {
523 AuthenticationStage authentication_stage = authentication_stage_;
524 base::debug::Alias(&authentication_stage);
525 LOG(FATAL) << "Unexpected authentication stage "
526 << static_cast<int>(authentication_stage_);
527 }
Jacob Dufaultcbc1ee02018-02-28 18:38:54528}
529
Jun Mukai5c7b5b42018-11-30 00:08:50530void LoginScreenController::OnFocusLeavingSystemTray(bool reverse) {
531 if (!login_screen_client_)
532 return;
533 login_screen_client_->OnFocusLeavingSystemTray(reverse);
534}
535
xiaoyinh2bbdd102017-05-18 23:29:42536} // namespace ash