[go: nahoru, domu]

blob: eb5d40d399ed82cf0be1f6fd24a2b28a6eaf2bb5 [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
jdufaulteb4c9f1e2017-06-08 23:08:307#include "ash/login/ui/lock_screen.h"
Quan Nguyend09dd112018-06-19 19:20:328#include "ash/login/ui/lock_window.h"
Jacob Dufault40623d52017-09-15 17:22:539#include "ash/login/ui/login_data_dispatcher.h"
Sarah Hu069eea12017-09-08 01:28:4010#include "ash/public/cpp/ash_pref_names.h"
Aga Wronska16abb432018-01-11 23:49:5911#include "ash/root_window_controller.h"
Sarah Hu069eea12017-09-08 01:28:4012#include "ash/session/session_controller.h"
Jacob Dufault5ac266ef2018-07-18 17:30:3013#include "ash/shelf/login_shelf_view.h"
Quan Nguyend09dd112018-06-19 19:20:3214#include "ash/shelf/shelf.h"
15#include "ash/shelf/shelf_widget.h"
Sarah Hu069eea12017-09-08 01:28:4016#include "ash/shell.h"
Aga Wronska16abb432018-01-11 23:49:5917#include "ash/system/status_area_widget.h"
Jacob Dufaultc06d6ca2018-04-24 23:49:1718#include "base/debug/alias.h"
Sarah Hu069eea12017-09-08 01:28:4019#include "base/strings/string_number_conversions.h"
Jialiu Linf99b788b2018-01-17 23:01:2120#include "base/strings/utf_string_conversions.h"
xiaoyinh2bbdd102017-05-18 23:29:4221#include "chromeos/cryptohome/system_salt_getter.h"
Sarah Hu069eea12017-09-08 01:28:4022#include "components/prefs/pref_registry_simple.h"
Jacob Dufault957e0922017-12-06 19:16:0923#include "components/session_manager/session_manager_types.h"
xiaoyinh2bbdd102017-05-18 23:29:4224
25namespace ash {
26
Sarah Hu069eea12017-09-08 01:28:4027namespace {
xiaoyinh2bbdd102017-05-18 23:29:4228
Aga Wronskaa844cdcd12018-01-29 16:06:4429enum class SystemTrayVisibility {
30 kNone, // Tray not visible anywhere.
31 kPrimary, // Tray visible only on primary display.
32 kAll, // Tray visible on all displays.
33};
34
35void SetSystemTrayVisibility(SystemTrayVisibility visibility) {
36 RootWindowController* primary_window_controller =
37 Shell::GetPrimaryRootWindowController();
38 for (RootWindowController* window_controller :
39 Shell::GetAllRootWindowControllers()) {
40 StatusAreaWidget* status_area = window_controller->GetStatusAreaWidget();
41 if (!status_area)
42 continue;
43 if (window_controller == primary_window_controller) {
44 status_area->SetSystemTrayVisibility(
45 visibility == SystemTrayVisibility::kPrimary ||
46 visibility == SystemTrayVisibility::kAll);
47 } else {
48 status_area->SetSystemTrayVisibility(visibility ==
49 SystemTrayVisibility::kAll);
50 }
51 }
Aga Wronska16abb432018-01-11 23:49:5952}
53
Sarah Hu069eea12017-09-08 01:28:4054} // namespace
55
James Cookede316a2017-12-14 22:38:4356LoginScreenController::LoginScreenController() : weak_factory_(this) {}
James Cook8f1e6062017-11-13 23:40:5957
Jacob Dufaultffd9b0d2017-11-15 23:07:1658LoginScreenController::~LoginScreenController() = default;
xiaoyinh2bbdd102017-05-18 23:29:4259
Sarah Hu069eea12017-09-08 01:28:4060// static
Jacob Dufaultffd9b0d2017-11-15 23:07:1661void LoginScreenController::RegisterProfilePrefs(PrefRegistrySimple* registry,
62 bool for_test) {
Sarah Hu069eea12017-09-08 01:28:4063 if (for_test) {
64 // There is no remote pref service, so pretend that ash owns the pref.
65 registry->RegisterStringPref(prefs::kQuickUnlockPinSalt, "");
66 return;
67 }
68
69 // Pref is owned by chrome and flagged as PUBLIC.
70 registry->RegisterForeignPref(prefs::kQuickUnlockPinSalt);
71}
72
Jacob Dufaultffd9b0d2017-11-15 23:07:1673void LoginScreenController::BindRequest(mojom::LoginScreenRequest request) {
James Cookede316a2017-12-14 22:38:4374 bindings_.AddBinding(this, std::move(request));
xiaoyinh2bbdd102017-05-18 23:29:4275}
76
Jacob Dufault2ca8c502018-06-25 19:12:1477bool LoginScreenController::IsAuthenticating() const {
78 return authentication_stage_ != AuthenticationStage::kIdle;
79}
80
Jacob Dufaultb7a2d842017-12-01 23:21:1581void LoginScreenController::AuthenticateUser(const AccountId& account_id,
82 const std::string& password,
83 bool authenticated_by_pin,
84 OnAuthenticateCallback callback) {
Jacob Dufault8876ba82018-03-27 22:55:4385 // It is an error to call this function while an authentication is in
86 // progress.
Jacob Dufault58a1bf42018-07-10 17:44:5687 LOG_IF(ERROR, IsAuthenticating())
88 << "Duplicate authentication attempt; current authentication stage is "
89 << static_cast<int>(authentication_stage_);
Jacob Dufault2ca8c502018-06-25 19:12:1490 CHECK(!IsAuthenticating());
Jacob Dufault8876ba82018-03-27 22:55:4391
92 if (!login_screen_client_) {
Jacob Dufaultb7a2d842017-12-01 23:21:1593 std::move(callback).Run(base::nullopt);
xiaoyinh9f6fa0e2017-06-07 19:22:3294 return;
Jacob Dufaultb7a2d842017-12-01 23:21:1595 }
xiaoyinh9f6fa0e2017-06-07 19:22:3296
Jacob Dufaulteafc6fe2017-10-11 21:16:5297 // If auth is disabled by the debug overlay bypass the mojo call entirely, as
98 // it will dismiss the lock screen if the password is correct.
Jacob Dufault0fbed9c02017-11-14 19:22:2499 switch (force_fail_auth_for_debug_overlay_) {
100 case ForceFailAuth::kOff:
101 break;
102 case ForceFailAuth::kImmediate:
Jacob Dufaultb7a2d842017-12-01 23:21:15103 OnAuthenticateComplete(std::move(callback), false /*success*/);
Jacob Dufault0fbed9c02017-11-14 19:22:24104 return;
105 case ForceFailAuth::kDelayed:
Jacob Dufault2ca8c502018-06-25 19:12:14106 // Set a dummy authentication stage so that |IsAuthenticating| returns
107 // true.
108 authentication_stage_ = AuthenticationStage::kDoAuthenticate;
Jacob Dufault0fbed9c02017-11-14 19:22:24109 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
Jacob Dufaultb7a2d842017-12-01 23:21:15110 FROM_HERE,
111 base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
112 weak_factory_.GetWeakPtr(), base::Passed(&callback),
113 false),
Jacob Dufault0fbed9c02017-11-14 19:22:24114 base::TimeDelta::FromSeconds(1));
115 return;
Jacob Dufaulteafc6fe2017-10-11 21:16:52116 }
117
Jacob Dufault8876ba82018-03-27 22:55:43118 // |DoAuthenticateUser| requires the system salt.
119 authentication_stage_ = AuthenticationStage::kGetSystemSalt;
120 chromeos::SystemSaltGetter::Get()->GetSystemSalt(
121 base::AdaptCallbackForRepeating(
122 base::BindOnce(&LoginScreenController::DoAuthenticateUser,
123 weak_factory_.GetWeakPtr(), account_id, password,
124 authenticated_by_pin, std::move(callback))));
xiaoyinh9f6fa0e2017-06-07 19:22:32125}
126
Jacob Dufaultffd9b0d2017-11-15 23:07:16127void LoginScreenController::AttemptUnlock(const AccountId& account_id) {
128 if (!login_screen_client_)
xiaoyinh9f6fa0e2017-06-07 19:22:32129 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16130 login_screen_client_->AttemptUnlock(account_id);
Sarah Hue0e01a52017-10-25 20:29:30131
132 Shell::Get()->metrics()->login_metrics_recorder()->SetAuthMethod(
133 LoginMetricsRecorder::AuthMethod::kSmartlock);
xiaoyinh9f6fa0e2017-06-07 19:22:32134}
135
Jacob Dufaultffd9b0d2017-11-15 23:07:16136void LoginScreenController::HardlockPod(const AccountId& account_id) {
137 if (!login_screen_client_)
xiaoyinh9f6fa0e2017-06-07 19:22:32138 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16139 login_screen_client_->HardlockPod(account_id);
xiaoyinh9f6fa0e2017-06-07 19:22:32140}
141
Jacob Dufaultffd9b0d2017-11-15 23:07:16142void LoginScreenController::RecordClickOnLockIcon(const AccountId& account_id) {
143 if (!login_screen_client_)
xiaoyinh9f6fa0e2017-06-07 19:22:32144 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16145 login_screen_client_->RecordClickOnLockIcon(account_id);
xiaoyinh9f6fa0e2017-06-07 19:22:32146}
147
Jacob Dufaultffd9b0d2017-11-15 23:07:16148void LoginScreenController::OnFocusPod(const AccountId& account_id) {
149 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27150 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16151 login_screen_client_->OnFocusPod(account_id);
xiaoyinhf534c4f2017-06-13 20:50:27152}
153
Jacob Dufaultffd9b0d2017-11-15 23:07:16154void LoginScreenController::OnNoPodFocused() {
155 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27156 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16157 login_screen_client_->OnNoPodFocused();
xiaoyinhf534c4f2017-06-13 20:50:27158}
159
Jacob Dufaultffd9b0d2017-11-15 23:07:16160void LoginScreenController::LoadWallpaper(const AccountId& account_id) {
161 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27162 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16163 login_screen_client_->LoadWallpaper(account_id);
xiaoyinhf534c4f2017-06-13 20:50:27164}
165
Jacob Dufaultffd9b0d2017-11-15 23:07:16166void LoginScreenController::SignOutUser() {
167 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27168 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16169 login_screen_client_->SignOutUser();
xiaoyinhf534c4f2017-06-13 20:50:27170}
171
Jacob Dufaultffd9b0d2017-11-15 23:07:16172void LoginScreenController::CancelAddUser() {
173 if (!login_screen_client_)
Wenzhao Zang16e7ea722017-09-16 01:27:30174 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16175 login_screen_client_->CancelAddUser();
Wenzhao Zang16e7ea722017-09-16 01:27:30176}
177
Aga Wronska6a32f9872018-01-06 00:16:10178void LoginScreenController::LoginAsGuest() {
179 if (!login_screen_client_)
180 return;
181 login_screen_client_->LoginAsGuest();
182}
183
Jacob Dufaultffd9b0d2017-11-15 23:07:16184void LoginScreenController::OnMaxIncorrectPasswordAttempted(
xiaoyinhf534c4f2017-06-13 20:50:27185 const AccountId& account_id) {
Jacob Dufaultffd9b0d2017-11-15 23:07:16186 if (!login_screen_client_)
xiaoyinhf534c4f2017-06-13 20:50:27187 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16188 login_screen_client_->OnMaxIncorrectPasswordAttempted(account_id);
xiaoyinhf534c4f2017-06-13 20:50:27189}
190
Jacob Dufaultffd9b0d2017-11-15 23:07:16191void LoginScreenController::FocusLockScreenApps(bool reverse) {
192 if (!login_screen_client_)
Toni Barzicf61c4452017-10-05 03:57:48193 return;
Jacob Dufaultffd9b0d2017-11-15 23:07:16194 login_screen_client_->FocusLockScreenApps(reverse);
Toni Barzicf61c4452017-10-05 03:57:48195}
196
Wenzhao Zang767a9f32018-05-02 21:20:55197void LoginScreenController::ShowGaiaSignin(
Jacob Dufaultfb72607d2018-06-12 19:50:33198 bool can_close,
199 const base::Optional<AccountId>& prefilled_account) {
Sarah Hu9fba0e752018-02-07 01:41:09200 if (!login_screen_client_)
201 return;
Jacob Dufaultfb72607d2018-06-12 19:50:33202 login_screen_client_->ShowGaiaSignin(can_close, prefilled_account);
Sarah Hu9fba0e752018-02-07 01:41:09203}
204
Jacob Dufaultfc31c742018-03-20 17:32:19205void LoginScreenController::OnRemoveUserWarningShown() {
206 if (!login_screen_client_)
207 return;
208 login_screen_client_->OnRemoveUserWarningShown();
209}
210
211void LoginScreenController::RemoveUser(const AccountId& account_id) {
212 if (!login_screen_client_)
213 return;
214 login_screen_client_->RemoveUser(account_id);
215}
216
Sarah Hu3fcf9f82018-03-22 20:32:54217void LoginScreenController::LaunchPublicSession(
218 const AccountId& account_id,
219 const std::string& locale,
220 const std::string& input_method) {
221 if (!login_screen_client_)
222 return;
223 login_screen_client_->LaunchPublicSession(account_id, locale, input_method);
224}
225
Sarah Huf9affb122018-04-27 21:36:36226void LoginScreenController::RequestPublicSessionKeyboardLayouts(
227 const AccountId& account_id,
228 const std::string& locale) {
229 if (!login_screen_client_)
230 return;
231 login_screen_client_->RequestPublicSessionKeyboardLayouts(account_id, locale);
232}
233
Sarah Hu0007c932018-06-18 20:21:04234void LoginScreenController::ShowFeedback() {
235 if (!login_screen_client_)
236 return;
237 login_screen_client_->ShowFeedback();
238}
239
Jacob Dufault589d9942018-03-27 20:28:47240void LoginScreenController::AddObserver(
241 LoginScreenControllerObserver* observer) {
242 observers_.AddObserver(observer);
Toni Barzicf61c4452017-10-05 03:57:48243}
244
Jacob Dufault589d9942018-03-27 20:28:47245void LoginScreenController::RemoveObserver(
246 LoginScreenControllerObserver* observer) {
247 observers_.RemoveObserver(observer);
Toni Barzicf61c4452017-10-05 03:57:48248}
249
Jacob Dufaultffd9b0d2017-11-15 23:07:16250void LoginScreenController::FlushForTesting() {
251 login_screen_client_.FlushForTesting();
Toni Barzicf61c4452017-10-05 03:57:48252}
253
Jacob Dufault589d9942018-03-27 20:28:47254void LoginScreenController::SetClient(mojom::LoginScreenClientPtr client) {
255 login_screen_client_ = std::move(client);
256}
257
258void LoginScreenController::ShowLockScreen(ShowLockScreenCallback on_shown) {
259 OnShow();
260 ash::LockScreen::Show(ash::LockScreen::ScreenType::kLock);
261 std::move(on_shown).Run(true);
262}
263
264void LoginScreenController::ShowLoginScreen(ShowLoginScreenCallback on_shown) {
265 // Login screen can only be used during login.
266 if (Shell::Get()->session_controller()->GetSessionState() !=
267 session_manager::SessionState::LOGIN_PRIMARY) {
268 LOG(ERROR) << "Not showing login screen since session state is "
269 << static_cast<int>(
270 Shell::Get()->session_controller()->GetSessionState());
271 std::move(on_shown).Run(false);
272 return;
273 }
274
275 OnShow();
276 // TODO(jdufault): rename ash::LockScreen to ash::LoginScreen.
277 ash::LockScreen::Show(ash::LockScreen::ScreenType::kLogin);
278 std::move(on_shown).Run(true);
279}
280
281void LoginScreenController::ShowErrorMessage(int32_t login_attempts,
282 const std::string& error_text,
283 const std::string& help_link_text,
284 int32_t help_topic_id) {
285 NOTIMPLEMENTED();
286}
287
288void LoginScreenController::ClearErrors() {
289 NOTIMPLEMENTED();
290}
291
292void LoginScreenController::ShowUserPodCustomIcon(
293 const AccountId& account_id,
294 mojom::EasyUnlockIconOptionsPtr icon) {
295 DataDispatcher()->ShowEasyUnlockIcon(account_id, icon);
296}
297
298void LoginScreenController::HideUserPodCustomIcon(const AccountId& account_id) {
299 auto icon_options = mojom::EasyUnlockIconOptions::New();
300 icon_options->icon = mojom::EasyUnlockIconId::NONE;
301 DataDispatcher()->ShowEasyUnlockIcon(account_id, icon_options);
302}
303
304void LoginScreenController::SetAuthType(
305 const AccountId& account_id,
306 proximity_auth::mojom::AuthType auth_type,
307 const base::string16& initial_value) {
308 if (auth_type == proximity_auth::mojom::AuthType::USER_CLICK) {
309 DataDispatcher()->SetClickToUnlockEnabledForUser(account_id,
310 true /*enabled*/);
Wenzhao Zang767a9f32018-05-02 21:20:55311 } else if (auth_type == proximity_auth::mojom::AuthType::ONLINE_SIGN_IN) {
312 DataDispatcher()->SetForceOnlineSignInForUser(account_id);
Jacob Dufault589d9942018-03-27 20:28:47313 } else {
314 NOTIMPLEMENTED();
315 }
316}
317
318void LoginScreenController::LoadUsers(
319 std::vector<mojom::LoginUserInfoPtr> users,
320 bool show_guest) {
321 DCHECK(DataDispatcher());
322
323 DataDispatcher()->NotifyUsers(users);
Jacob Dufault5ac266ef2018-07-18 17:30:30324 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
325 ->shelf_widget()
326 ->login_shelf_view()
327 ->SetAllowLoginAsGuest(show_guest);
Jacob Dufault589d9942018-03-27 20:28:47328}
329
330void LoginScreenController::SetPinEnabledForUser(const AccountId& account_id,
331 bool is_enabled) {
332 // Chrome will update pin pod state every time user tries to authenticate.
333 // LockScreen is destroyed in the case of authentication success.
334 if (DataDispatcher())
335 DataDispatcher()->SetPinEnabledForUser(account_id, is_enabled);
336}
337
Jacob Dufault77d75ce92018-04-13 18:20:09338void LoginScreenController::SetAvatarForUser(const AccountId& account_id,
339 mojom::UserAvatarPtr avatar) {
340 for (auto& observer : observers_)
341 observer.SetAvatarForUser(account_id, avatar);
342}
343
Wenzhao Zange0c2ab22018-05-23 17:43:46344void LoginScreenController::SetAuthEnabledForUser(
345 const AccountId& account_id,
346 bool is_enabled,
347 base::Optional<base::Time> auth_reenabled_time) {
348 if (DataDispatcher()) {
349 DataDispatcher()->SetAuthEnabledForUser(account_id, is_enabled,
350 auth_reenabled_time);
351 }
352}
353
Jacob Dufault589d9942018-03-27 20:28:47354void LoginScreenController::HandleFocusLeavingLockScreenApps(bool reverse) {
355 for (auto& observer : observers_)
356 observer.OnFocusLeavingLockScreenApps(reverse);
357}
358
359void LoginScreenController::SetDevChannelInfo(
360 const std::string& os_version_label_text,
361 const std::string& enterprise_info_text,
362 const std::string& bluetooth_name) {
363 if (DataDispatcher()) {
364 DataDispatcher()->SetDevChannelInfo(os_version_label_text,
365 enterprise_info_text, bluetooth_name);
366 }
367}
368
369void LoginScreenController::IsReadyForPassword(
370 IsReadyForPasswordCallback callback) {
Jacob Dufault2ca8c502018-06-25 19:12:14371 std::move(callback).Run(LockScreen::HasInstance() && !IsAuthenticating());
Jacob Dufault589d9942018-03-27 20:28:47372}
373
374void LoginScreenController::SetPublicSessionDisplayName(
375 const AccountId& account_id,
376 const std::string& display_name) {
377 if (DataDispatcher())
378 DataDispatcher()->SetPublicSessionDisplayName(account_id, display_name);
379}
380
381void LoginScreenController::SetPublicSessionLocales(
382 const AccountId& account_id,
Sarah Hue9cd6132018-05-17 17:25:56383 std::vector<mojom::LocaleItemPtr> locales,
Jacob Dufault589d9942018-03-27 20:28:47384 const std::string& default_locale,
385 bool show_advanced_view) {
386 if (DataDispatcher()) {
387 DataDispatcher()->SetPublicSessionLocales(
Sarah Hue9cd6132018-05-17 17:25:56388 account_id, locales, default_locale, show_advanced_view);
Jacob Dufault589d9942018-03-27 20:28:47389 }
390}
391
Sarah Huf9affb122018-04-27 21:36:36392void LoginScreenController::SetPublicSessionKeyboardLayouts(
393 const AccountId& account_id,
394 const std::string& locale,
395 std::vector<mojom::InputMethodItemPtr> keyboard_layouts) {
396 if (DataDispatcher()) {
397 DataDispatcher()->SetPublicSessionKeyboardLayouts(account_id, locale,
398 keyboard_layouts);
399 }
400}
401
Sarah Hu1a7de562018-05-14 17:18:22402void LoginScreenController::SetFingerprintUnlockState(
403 const AccountId& account_id,
404 mojom::FingerprintUnlockState state) {
405 if (DataDispatcher())
406 DataDispatcher()->SetFingerprintUnlockState(account_id, state);
407}
408
Quan Nguyend09dd112018-06-19 19:20:32409void LoginScreenController::SetKioskApps(
410 std::vector<mojom::KioskAppInfoPtr> kiosk_apps) {
411 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
412 ->shelf_widget()
Jacob Dufault5ac266ef2018-07-18 17:30:30413 ->login_shelf_view()
414 ->SetKioskApps(std::move(kiosk_apps));
Quan Nguyend09dd112018-06-19 19:20:32415}
416
Jacob Dufault883dcf72018-06-27 22:52:32417void LoginScreenController::NotifyOobeDialogVisibility(bool visible) {
418 Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow())
419 ->shelf_widget()
Jacob Dufault5ac266ef2018-07-18 17:30:30420 ->login_shelf_view()
Jacob Dufault883dcf72018-06-27 22:52:32421 ->SetLoginDialogVisible(visible);
422}
423
Quan Nguyend09dd112018-06-19 19:20:32424void LoginScreenController::LaunchKioskApp(const std::string& app_id) {
425 login_screen_client_->LaunchKioskApp(app_id);
426}
427
Quan Nguyena3c54cf2018-07-03 17:56:50428void LoginScreenController::LaunchArcKioskApp(const AccountId& account_id) {
429 login_screen_client_->LaunchArcKioskApp(account_id);
430}
431
Jacob Dufaultb7a2d842017-12-01 23:21:15432void LoginScreenController::DoAuthenticateUser(const AccountId& account_id,
433 const std::string& password,
434 bool authenticated_by_pin,
435 OnAuthenticateCallback callback,
436 const std::string& system_salt) {
Jacob Dufault8876ba82018-03-27 22:55:43437 authentication_stage_ = AuthenticationStage::kDoAuthenticate;
438
Sarah Hu069eea12017-09-08 01:28:40439 int dummy_value;
440 bool is_pin =
441 authenticated_by_pin && base::StringToInt(password, &dummy_value);
Roman Sorokinc5590012017-09-28 00:48:29442
Sarah Hue0e01a52017-10-25 20:29:30443 Shell::Get()->metrics()->login_metrics_recorder()->SetAuthMethod(
444 is_pin ? LoginMetricsRecorder::AuthMethod::kPin
445 : LoginMetricsRecorder::AuthMethod::kPassword);
Jacob Dufault2be71002018-05-16 17:07:43446
Jacob Dufaultb7a2d842017-12-01 23:21:15447 login_screen_client_->AuthenticateUser(
Jacob Dufault2be71002018-05-16 17:07:43448 account_id, password, is_pin,
Jacob Dufaultb7a2d842017-12-01 23:21:15449 base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
450 weak_factory_.GetWeakPtr(), base::Passed(&callback)));
jdufaulteb4c9f1e2017-06-08 23:08:30451}
452
Jacob Dufaultb7a2d842017-12-01 23:21:15453void LoginScreenController::OnAuthenticateComplete(
454 OnAuthenticateCallback callback,
455 bool success) {
Jacob Dufault8876ba82018-03-27 22:55:43456 authentication_stage_ = AuthenticationStage::kUserCallback;
Jacob Dufaultb7a2d842017-12-01 23:21:15457 std::move(callback).Run(success);
Jacob Dufault8876ba82018-03-27 22:55:43458 authentication_stage_ = AuthenticationStage::kIdle;
xiaoyinh2bbdd102017-05-18 23:29:42459}
460
Jacob Dufaultffd9b0d2017-11-15 23:07:16461LoginDataDispatcher* LoginScreenController::DataDispatcher() const {
Wenzhao Zang733497282018-06-12 16:53:10462 if (!ash::LockScreen::HasInstance())
Jacob Dufault40623d52017-09-15 17:22:53463 return nullptr;
464 return ash::LockScreen::Get()->data_dispatcher();
465}
466
Jacob Dufaultcbc1ee02018-02-28 18:38:54467void LoginScreenController::OnShow() {
468 SetSystemTrayVisibility(SystemTrayVisibility::kPrimary);
Jacob Dufaultc06d6ca2018-04-24 23:49:17469 if (authentication_stage_ != AuthenticationStage::kIdle) {
470 AuthenticationStage authentication_stage = authentication_stage_;
471 base::debug::Alias(&authentication_stage);
472 LOG(FATAL) << "Unexpected authentication stage "
473 << static_cast<int>(authentication_stage_);
474 }
Jacob Dufaultcbc1ee02018-02-28 18:38:54475}
476
xiaoyinh2bbdd102017-05-18 23:29:42477} // namespace ash