Introduce authentication stage changed event.
Bug: b:307846218
Change-Id: Ic338cd6f9a5bd17fe2d0879ac5a2d7de439d3a71
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5028397
Commit-Queue: Istvan Nagy <iscsi@google.com>
Reviewed-by: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1228820}
diff --git a/ash/login/login_screen_controller.cc b/ash/login/login_screen_controller.cc
index 485a96b..845fdb6 100644
--- a/ash/login/login_screen_controller.cc
+++ b/ash/login/login_screen_controller.cc
@@ -125,7 +125,7 @@
// Set a dummy authentication stage so that |IsAuthenticating| returns
// true.
LOG(WARNING) << "crbug.com/1339004 : Dummy auth state";
- authentication_stage_ = AuthenticationStage::kDoAuthenticate;
+ SetAuthenticationStage(AuthenticationStage::kDoAuthenticate);
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
@@ -136,7 +136,7 @@
}
LOG(WARNING) << "crbug.com/1339004 : started authentication";
- authentication_stage_ = AuthenticationStage::kDoAuthenticate;
+ SetAuthenticationStage(AuthenticationStage::kDoAuthenticate);
if (authenticated_by_pin) {
DCHECK(base::ContainsOnlyChars(password, "0123456789"));
@@ -170,7 +170,7 @@
return;
}
- authentication_stage_ = AuthenticationStage::kDoAuthenticate;
+ SetAuthenticationStage(AuthenticationStage::kDoAuthenticate);
client_->AuthenticateUserWithChallengeResponse(
account_id,
base::BindOnce(&LoginScreenController::OnAuthenticateComplete,
@@ -446,6 +446,15 @@
->ConfigureKioskCallbacks(launch_app, on_show_menu);
}
+void LoginScreenController::SetAuthenticationStage(
+ AuthenticationStage authentication_stage) {
+ if (authentication_stage == authentication_stage_) {
+ return;
+ }
+ authentication_stage_ = authentication_stage;
+ login_data_dispatcher_.AuthenticationStageChange(authentication_stage);
+}
+
void LoginScreenController::HandleAccelerator(
ash::LoginAcceleratorAction action) {
if (!client_) {
@@ -478,10 +487,10 @@
OnAuthenticateCallback callback,
bool success) {
LOG(WARNING) << "crbug.com/1339004 : authentication complete";
- authentication_stage_ = AuthenticationStage::kUserCallback;
+ SetAuthenticationStage(AuthenticationStage::kUserCallback);
std::move(callback).Run(absl::make_optional<bool>(success));
LOG(WARNING) << "crbug.com/1339004 : triggered callback";
- authentication_stage_ = AuthenticationStage::kIdle;
+ SetAuthenticationStage(AuthenticationStage::kIdle);
// During smart card login flow, multiple security token requests can be made.
// If the user cancels one, all others should also be canceled.
@@ -523,7 +532,7 @@
}
// Still handle it to avoid crashes during Login/Lock/Unlock flows.
- authentication_stage_ = AuthenticationStage::kIdle;
+ SetAuthenticationStage(AuthenticationStage::kIdle);
SetSystemTrayVisibility(SystemTrayVisibility::kAll);
}
@@ -534,14 +543,13 @@
client_->OnLoginScreenShown();
}
-std::ostream& operator<<(std::ostream& ostream,
- LoginScreenController::AuthenticationStage stage) {
+std::ostream& operator<<(std::ostream& ostream, AuthenticationStage stage) {
switch (stage) {
- case LoginScreenController::AuthenticationStage::kIdle:
+ case AuthenticationStage::kIdle:
return ostream << "kIdle";
- case LoginScreenController::AuthenticationStage::kDoAuthenticate:
+ case AuthenticationStage::kDoAuthenticate:
return ostream << "kDoAuthenticate";
- case LoginScreenController::AuthenticationStage::kUserCallback:
+ case AuthenticationStage::kUserCallback:
return ostream << "kUserCallback";
}
}