Commit bb195df3 authored by Nina Satragno's avatar Nina Satragno Committed by Commit Bot

[webauthn] Fix esc key breaking some dialogs

When tapping escape on an authenticator dialog with an "interesting"
OnCancel() behaviour (i.e. not immediately terminating the request), the
dialog is closed without calling OnCancel(). This can leave requests
hanging in the background. This patch handles the press of the escape
key on the dialog's contents to call OnCancel() on the model instead.

Fixed: 1145724
Change-Id: I019c614cd0b40f7384944c56eab0afe45d76c8b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2530795
Commit-Queue: Nina Satragno <nsatragno@chromium.org>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: default avatarMartin Kreichgauer <martinkr@google.com>
Cr-Commit-Position: refs/heads/master@{#826523}
parent 8076c45d
......@@ -25,7 +25,14 @@ double CalculateProgressFor(double samples_remaining, double max_samples) {
AuthenticatorBioEnrollmentSheetView::AuthenticatorBioEnrollmentSheetView(
std::unique_ptr<AuthenticatorBioEnrollmentSheetModel> sheet_model)
: AuthenticatorRequestSheetView(std::move(sheet_model)) {}
: AuthenticatorRequestSheetView(std::move(sheet_model)) {
// Override the DialogClientView (i.e. this view's parent) handling of the
// escape key to avoid closing the dialog when we want to cancel instead,
// since cancelling might do something different.
// This is a workaround to fix crbug.com/1145724.
// TODO(nsatragno): remove this workaround once crbug.com/1147927 is fixed.
AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
}
AuthenticatorBioEnrollmentSheetView::~AuthenticatorBioEnrollmentSheetView() =
default;
......@@ -66,3 +73,10 @@ AuthenticatorBioEnrollmentSheetView::BuildStepSpecificContent() {
return animation_container;
}
bool AuthenticatorBioEnrollmentSheetView::AcceleratorPressed(
const ui::Accelerator& accelerator) {
DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code());
model()->OnCancel();
return true;
}
......@@ -26,6 +26,9 @@ class AuthenticatorBioEnrollmentSheetView
// AuthenticatorRequestSheetView:
std::unique_ptr<views::View> BuildStepSpecificContent() override;
// views::View:
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
RingProgressBar* ring_progress_bar_;
DISALLOW_COPY_AND_ASSIGN(AuthenticatorBioEnrollmentSheetView);
......
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