Commit 90e8e718 authored by Balazs Engedy's avatar Balazs Engedy Committed by Commit Bot

Add error screen for no available transports.

Bug: 847985, 849323
Change-Id: I818ab8eabac6dbb96edceefa5d28f6d28031d15f
Reviewed-on: https://chromium-review.googlesource.com/1181574Reviewed-by: default avatarJun Choi <hongjunchoi@chromium.org>
Commit-Queue: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584611}
parent 8e5097cb
......@@ -52,6 +52,11 @@ std::unique_ptr<AuthenticatorRequestSheetView> CreateSheetViewForCurrentStepOf(
sheet_view = std::make_unique<AuthenticatorRequestSheetView>(
std::make_unique<AuthenticatorTimeoutErrorModel>(dialog_model));
break;
case Step::kErrorNoAvailableTransports:
sheet_view = std::make_unique<AuthenticatorRequestSheetView>(
std::make_unique<AuthenticatorNoAvailableTransportsErrorModel>(
dialog_model));
break;
case Step::kBlePowerOnManual:
sheet_view = std::make_unique<AuthenticatorRequestSheetView>(
std::make_unique<AuthenticatorBlePowerOnManualSheetModel>(
......
......@@ -41,6 +41,9 @@ class AuthenticatorDialogTest : public DialogBrowserTest {
} else if (name == "activate_usb") {
model->SetCurrentStep(
AuthenticatorRequestDialogModel::Step::kUsbInsertAndActivate);
} else if (name == "no_available_transports") {
model->SetCurrentStep(
AuthenticatorRequestDialogModel::Step::kErrorNoAvailableTransports);
} else if (name == "timeout") {
model->SetCurrentStep(
AuthenticatorRequestDialogModel::Step::kErrorTimedOut);
......@@ -103,6 +106,11 @@ IN_PROC_BROWSER_TEST_F(AuthenticatorDialogTest, InvokeUi_timeout) {
ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(AuthenticatorDialogTest,
InvokeUi_no_available_transports) {
ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(AuthenticatorDialogTest, InvokeUi_ble_power_on_manual) {
ShowAndVerifyUi();
}
......
......@@ -172,6 +172,33 @@ base::string16 AuthenticatorTimeoutErrorModel::GetStepDescription() const {
return l10n_util::GetStringUTF16(IDS_WEBAUTHN_ERROR_TIMEOUT_DESCRIPTION);
}
// AuthenticatorNoAvailableTransportsErrorModel -------------------------------
bool AuthenticatorNoAvailableTransportsErrorModel::IsBackButtonVisible() const {
return false;
}
base::string16
AuthenticatorNoAvailableTransportsErrorModel::GetCancelButtonLabel() const {
return l10n_util::GetStringUTF16(IDS_CLOSE);
}
gfx::ImageSkia*
AuthenticatorNoAvailableTransportsErrorModel::GetStepIllustration() const {
return GetImage(IDR_WEBAUTHN_ILLUSTRATION_ERROR_TIMEOUT_1X);
}
base::string16 AuthenticatorNoAvailableTransportsErrorModel::GetStepTitle()
const {
return l10n_util::GetStringUTF16(IDS_WEBAUTHN_ERROR_NO_TRANSPORTS_TITLE);
}
base::string16
AuthenticatorNoAvailableTransportsErrorModel::GetStepDescription() const {
return l10n_util::GetStringUTF16(
IDS_WEBAUTHN_ERROR_NO_TRANSPORTS_DESCRIPTION);
}
// AuthenticatorBlePowerOnManualSheetModel ------------------------------------
gfx::ImageSkia* AuthenticatorBlePowerOnManualSheetModel::GetStepIllustration()
......
......@@ -109,6 +109,20 @@ class AuthenticatorTimeoutErrorModel : public AuthenticatorSheetModelBase {
base::string16 GetStepDescription() const override;
};
class AuthenticatorNoAvailableTransportsErrorModel
: public AuthenticatorSheetModelBase {
public:
using AuthenticatorSheetModelBase::AuthenticatorSheetModelBase;
private:
// AuthenticatorSheetModelBase:
bool IsBackButtonVisible() const override;
base::string16 GetCancelButtonLabel() const override;
gfx::ImageSkia* GetStepIllustration() const override;
base::string16 GetStepTitle() const override;
base::string16 GetStepDescription() const override;
};
class AuthenticatorBlePowerOnManualSheetModel
: public AuthenticatorSheetModelBase {
public:
......
......@@ -116,9 +116,11 @@ void AuthenticatorRequestDialogModel::
if (most_likely_transport) {
StartGuidedFlowForTransport(
ToAuthenticatorTransport(*most_likely_transport));
} else {
// TODO(engedy): Show error screen if no transport available at all.
} else if (!transport_availability_.available_transports.empty()) {
DCHECK_GE(transport_availability_.available_transports.size(), 2u);
SetCurrentStep(Step::kTransportSelection);
} else {
SetCurrentStep(Step::kErrorNoAvailableTransports);
}
}
......
......@@ -35,6 +35,7 @@ class AuthenticatorRequestDialogModel {
kWelcomeScreen,
kTransportSelection,
kErrorTimedOut,
kErrorNoAvailableTransports,
kCompleted,
// Universal Serial Bus (USB).
......
......@@ -94,8 +94,7 @@ TEST_F(AuthenticatorRequestDialogModelTest, TransportAutoSelection) {
{{},
FidoTransportProtocol::kNearFieldCommunication,
false,
// TODO: Update this when the error screen is implemented.
Step::kTransportSelection},
Step::kErrorNoAvailableTransports},
};
for (const auto& test_case : kTestCases) {
......
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