Commit 7ff35562 authored by Quan Nguyen's avatar Quan Nguyen Committed by Commit Bot

cros: Add a debug button for cycling through the different types of auth error bubbles.

Bug: 863620
Change-Id: I2d9cef017c3c8c4c2feee99bc4f6913baf11c320
Reviewed-on: https://chromium-review.googlesource.com/1145686
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577675}
parent 6c529359
...@@ -868,6 +868,11 @@ void LockContentsView::SuspendImminent( ...@@ -868,6 +868,11 @@ void LockContentsView::SuspendImminent(
auth_user->password_view()->Clear(); auth_user->password_view()->Clear();
} }
void LockContentsView::ShowAuthErrorMessageForDebug(int unlock_attempt) {
unlock_attempt_ = unlock_attempt;
ShowAuthErrorMessage();
}
void LockContentsView::FocusNextWidget(bool reverse) { void LockContentsView::FocusNextWidget(bool reverse) {
Shelf* shelf = Shelf::ForWindow(GetWidget()->GetNativeWindow()); Shelf* shelf = Shelf::ForWindow(GetWidget()->GetNativeWindow());
// Tell the focus direction to the status area or the shelf so they can focus // Tell the focus direction to the status area or the shelf so they can focus
......
...@@ -192,6 +192,8 @@ class ASH_EXPORT LockContentsView ...@@ -192,6 +192,8 @@ class ASH_EXPORT LockContentsView
// chromeos::PowerManagerClient::Observer: // chromeos::PowerManagerClient::Observer:
void SuspendImminent(power_manager::SuspendImminent::Reason reason) override; void SuspendImminent(power_manager::SuspendImminent::Reason reason) override;
void ShowAuthErrorMessageForDebug(int unlock_attempt);
private: private:
class UserState { class UserState {
public: public:
......
...@@ -49,6 +49,7 @@ enum { ...@@ -49,6 +49,7 @@ enum {
kGlobalToggleDebugDetachableBase, kGlobalToggleDebugDetachableBase,
kGlobalCycleDetachableBaseStatus, kGlobalCycleDetachableBaseStatus,
kGlobalCycleDetachableBaseId, kGlobalCycleDetachableBaseId,
kGlobalCycleAuthErrorMessage,
kPerUserTogglePin, kPerUserTogglePin,
kPerUserCycleEasyUnlockState, kPerUserCycleEasyUnlockState,
...@@ -630,6 +631,8 @@ LockDebugView::LockDebugView(mojom::TrayActionState initial_note_action_state, ...@@ -630,6 +631,8 @@ LockDebugView::LockDebugView(mojom::TrayActionState initial_note_action_state,
toggle_container); toggle_container);
global_action_toggle_auth_ = AddButton( global_action_toggle_auth_ = AddButton(
"Auth (allowed)", ButtonId::kGlobalToggleAuth, toggle_container); "Auth (allowed)", ButtonId::kGlobalToggleAuth, toggle_container);
AddButton("Cycle auth error", ButtonId::kGlobalCycleAuthErrorMessage,
toggle_container);
auto* kiosk_container = add_horizontal_container(); auto* kiosk_container = add_horizontal_container();
AddButton("Add kiosk app", ButtonId::kGlobalAddKioskApp, kiosk_container); AddButton("Add kiosk app", ButtonId::kGlobalAddKioskApp, kiosk_container);
...@@ -676,6 +679,46 @@ void LockDebugView::Layout() { ...@@ -676,6 +679,46 @@ void LockDebugView::Layout() {
container_->SizeToPreferredSize(); container_->SizeToPreferredSize();
} }
void LockDebugView::CycleAuthErrorMessage() {
switch (next_auth_error_type_) {
case AuthErrorType::kFirstUnlockFailed:
next_auth_error_type_ = AuthErrorType::kFirstUnlockFailedCapsLockOn;
Shell::Get()->ime_controller()->UpdateCapsLockState(
false /*caps_enabled*/);
debug_detachable_base_model_->SetPairingState(
DetachableBasePairingStatus::kNone,
DebugLoginDetachableBaseModel::kNullBaseId);
lock_->ShowAuthErrorMessageForDebug(1 /*unlock_attempt*/);
return;
case AuthErrorType::kFirstUnlockFailedCapsLockOn:
next_auth_error_type_ = AuthErrorType::kSecondUnlockFailed;
Shell::Get()->ime_controller()->UpdateCapsLockState(
true /*caps_enabled*/);
lock_->ShowAuthErrorMessageForDebug(1 /*unlock_attempt*/);
return;
case AuthErrorType::kSecondUnlockFailed:
next_auth_error_type_ = AuthErrorType::kSecondUnlockFailedCapsLockOn;
Shell::Get()->ime_controller()->UpdateCapsLockState(
false /*caps_enabled*/);
lock_->ShowAuthErrorMessageForDebug(2 /*unlock_attempt*/);
return;
case AuthErrorType::kSecondUnlockFailedCapsLockOn:
next_auth_error_type_ = AuthErrorType::kDetachableBaseFailed;
Shell::Get()->ime_controller()->UpdateCapsLockState(
true /*caps_enabled*/);
lock_->ShowAuthErrorMessageForDebug(2 /*unlock_attempt*/);
return;
case AuthErrorType::kDetachableBaseFailed:
next_auth_error_type_ = AuthErrorType::kFirstUnlockFailed;
debug_detachable_base_model_->SetPairingState(
DetachableBasePairingStatus::kNotAuthenticated,
DebugLoginDetachableBaseModel::kNullBaseId);
return;
default:
NOTREACHED();
}
}
void LockDebugView::ButtonPressed(views::Button* sender, void LockDebugView::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
// Add or remove a user. // Add or remove a user.
...@@ -817,6 +860,11 @@ void LockDebugView::ButtonPressed(views::Button* sender, ...@@ -817,6 +860,11 @@ void LockDebugView::ButtonPressed(views::Button* sender,
return; return;
} }
if (sender->id() == ButtonId::kGlobalCycleAuthErrorMessage) {
CycleAuthErrorMessage();
return;
}
// Enable or disable PIN. // Enable or disable PIN.
if (sender->id() == ButtonId::kPerUserTogglePin) if (sender->id() == ButtonId::kPerUserTogglePin)
debug_data_dispatcher_->TogglePinStateForUserIndex(sender->tag()); debug_data_dispatcher_->TogglePinStateForUserIndex(sender->tag());
......
...@@ -47,6 +47,17 @@ class LockDebugView : public views::View, public views::ButtonListener { ...@@ -47,6 +47,17 @@ class LockDebugView : public views::View, public views::ButtonListener {
private: private:
class DebugDataDispatcherTransformer; class DebugDataDispatcherTransformer;
class DebugLoginDetachableBaseModel; class DebugLoginDetachableBaseModel;
enum class AuthErrorType {
kFirstUnlockFailed,
kFirstUnlockFailedCapsLockOn,
kSecondUnlockFailed,
kSecondUnlockFailedCapsLockOn,
kDetachableBaseFailed,
};
// Cycle through the various types of auth error bubbles that can be shown on
// the login screen.
void CycleAuthErrorMessage();
// Rebuilds the debug user column which contains per-user actions. // Rebuilds the debug user column which contains per-user actions.
void UpdatePerUserActionContainer(); void UpdatePerUserActionContainer();
...@@ -89,6 +100,10 @@ class LockDebugView : public views::View, public views::ButtonListener { ...@@ -89,6 +100,10 @@ class LockDebugView : public views::View, public views::ButtonListener {
LoginScreenController::ForceFailAuth force_fail_auth_ = LoginScreenController::ForceFailAuth force_fail_auth_ =
LoginScreenController::ForceFailAuth::kOff; LoginScreenController::ForceFailAuth::kOff;
// The next type of authentication error bubble to show when the "Cycle auth
// error" button is clicked.
AuthErrorType next_auth_error_type_ = AuthErrorType::kFirstUnlockFailed;
DISALLOW_COPY_AND_ASSIGN(LockDebugView); DISALLOW_COPY_AND_ASSIGN(LockDebugView);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment