Commit 62126032 authored by Martin Kreichgauer's avatar Martin Kreichgauer Committed by Commit Bot

webauthn: add a UI sheet view and model for Touch ID

This is just the basic sheet; nothing wired up yet.

Bug: 849323
Change-Id: I088310de39966895dfa7d3008c631382b990f520
Reviewed-on: https://chromium-review.googlesource.com/1173347
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: default avatarKim Paulhamus <kpaulhamus@chromium.org>
Reviewed-by: default avatarDave Schuyler <dschuyler@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583471}
parent 70ef44d5
......@@ -9131,6 +9131,11 @@ Please help our engineers fix this problem. Tell us what happened right before y
To use most keys, simply press the button
</message>
</if>
<if expr="is_macosx">
<message name="IDS_WEBAUTHN_TOUCH_ID_TITLE" desc="Title of the dialog shown when the user tries to sign in with Touch ID." meaning="'Touch ID' is the fingerprint recognition feature in macOS. Try to refer Apple support documentation in the target language for the appropriate product name translation.">
Use Touch ID with <ph name="APP_NAME">$1<ex>example.com</ex></ph>
</message>
</if>
</messages>
</release>
</grit>
......@@ -82,10 +82,12 @@
<include name="IDR_WEBAUTHN_ILLUSTRATION_ERROR_BLUETOOTH_1X" file="resources\webauthn\error_bt.png" type="BINDATA" />
<include name="IDR_WEBAUTHN_ILLUSTRATION_ERROR_TIMEOUT_1X" file="resources\webauthn\error_timeout.png" type="BINDATA" />
<include name="IDR_WEBAUTHN_ILLUSTRATION_PHONE_1X" file="resources\webauthn\phone.png" type="BINDATA" />
<include name="IDR_WEBAUTHN_ILLUSTRATION_TOUCHID_1X" file="resources\webauthn\touchid.png" type="BINDATA" />
<include name="IDR_WEBAUTHN_ILLUSTRATION_USB_1X" file="resources\webauthn\usb.png" type="BINDATA" />
<include name="IDR_WEBAUTHN_ILLUSTRATION_WELCOME_1X" file="resources\webauthn\welcome.png" type="BINDATA" />
</if>
<if expr="is_macosx">
<include name="IDR_WEBAUTHN_ILLUSTRATION_TOUCHID_1X" file="resources\webauthn\touchid.png" type="BINDATA" />
</if>
<if expr="is_win">
<include name="IDR_ABOUT_CONFLICTS_HTML" file="resources\conflicts\about_conflicts.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_ABOUT_CONFLICTS_JS" file="resources\conflicts\about_conflicts.js" type="BINDATA" />
......
......@@ -90,6 +90,10 @@ std::unique_ptr<AuthenticatorRequestSheetView> CreateSheetViewForCurrentStepOf(
sheet_view = std::make_unique<AuthenticatorRequestSheetView>(
std::make_unique<AuthenticatorBleActivateSheetModel>(dialog_model));
break;
case Step::kTouchId:
sheet_view = std::make_unique<AuthenticatorRequestSheetView>(
std::make_unique<AuthenticatorTouchIdSheetModel>(dialog_model));
break;
case Step::kCompleted:
case Step::kBlePowerOnAutomatic:
sheet_view = std::make_unique<AuthenticatorRequestSheetView>(
......
......@@ -64,6 +64,8 @@ class AuthenticatorDialogTest : public DialogBrowserTest {
} else if (name == "ble_activate") {
model->SetCurrentStep(
AuthenticatorRequestDialogModel::Step::kBleActivate);
} else if (name == "touchid") {
model->SetCurrentStep(AuthenticatorRequestDialogModel::Step::kTouchId);
}
ShowAuthenticatorRequestDialog(
......@@ -129,3 +131,7 @@ IN_PROC_BROWSER_TEST_F(AuthenticatorDialogTest, InvokeUi_ble_verifying) {
IN_PROC_BROWSER_TEST_F(AuthenticatorDialogTest, InvokeUi_ble_activate) {
ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(AuthenticatorDialogTest, InvokeUi_touchid) {
ShowAndVerifyUi();
}
......@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "components/strings/grit/components_strings.h"
......@@ -354,3 +355,30 @@ base::string16 AuthenticatorBleActivateSheetModel::GetStepTitle() const {
base::string16 AuthenticatorBleActivateSheetModel::GetStepDescription() const {
return l10n_util::GetStringUTF16(IDS_WEBAUTHN_BLE_ACTIVATE_DESCRIPTION);
}
// AuthenticatorTouchIdSheetModel -----------------------------------------
gfx::ImageSkia* AuthenticatorTouchIdSheetModel::GetStepIllustration() const {
#if defined(OS_MACOSX)
return GetImage(IDR_WEBAUTHN_ILLUSTRATION_TOUCHID_1X);
#else
// Avoid bundling the PNG on platforms where it's not needed.
return nullptr;
#endif // defined(OS_MACOSX)
}
base::string16 AuthenticatorTouchIdSheetModel::GetStepTitle() const {
#if defined(OS_MACOSX)
// TODO(martinkr): Insert actual domain name from model to
// |application_name|.
base::string16 application_name = base::UTF8ToUTF16("example.com");
return l10n_util::GetStringFUTF16(IDS_WEBAUTHN_TOUCH_ID_TITLE,
application_name);
#else
return base::string16();
#endif // defined(OS_MACOSX)
}
base::string16 AuthenticatorTouchIdSheetModel::GetStepDescription() const {
return base::string16();
}
......@@ -208,4 +208,15 @@ class AuthenticatorBleActivateSheetModel : public AuthenticatorSheetModelBase {
base::string16 GetStepDescription() const override;
};
class AuthenticatorTouchIdSheetModel : public AuthenticatorSheetModelBase {
public:
using AuthenticatorSheetModelBase::AuthenticatorSheetModelBase;
private:
// AuthenticatorSheetModelBase:
gfx::ImageSkia* GetStepIllustration() const override;
base::string16 GetStepTitle() const override;
base::string16 GetStepDescription() const override;
};
#endif // CHROME_BROWSER_UI_WEBAUTHN_SHEET_MODELS_H_
......@@ -42,6 +42,9 @@ void AuthenticatorRequestDialogModel::StartGuidedFlowForTransport(
case AuthenticatorTransport::kBluetoothLowEnergy:
SetCurrentStep(Step::kBlePowerOnManual);
break;
case AuthenticatorTransport::kInternal:
SetCurrentStep(Step::kTouchId);
break;
default:
break;
}
......@@ -73,6 +76,10 @@ void AuthenticatorRequestDialogModel::TryUsbDevice() {
DCHECK_EQ(current_step(), Step::kUsbInsertAndActivateOnRegister);
}
void AuthenticatorRequestDialogModel::TryTouchId() {
DCHECK_EQ(current_step(), Step::kTouchId);
}
void AuthenticatorRequestDialogModel::Cancel() {
for (auto& observer : observers_)
observer.OnCancelRequest();
......
......@@ -44,6 +44,9 @@ class AuthenticatorRequestDialogModel {
kBleActivate,
kBleVerifying,
// Touch ID.
kTouchId,
};
// Encapsulates information about authenticators that have been found but are
......@@ -123,6 +126,12 @@ class AuthenticatorRequestDialogModel {
// Valid action when at step: kUsbInsert.
void TryUsbDevice();
// Tries to use Touch ID -- either because the request requires it or because
// the user told us to.
//
// Valid action when at step: kTouchId.
void TryTouchId();
// Cancels the flow as a result of the user clicking `Cancel` on the UI.
//
// Valid action at all steps.
......
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