Commit 071e5135 authored by Jun Choi's avatar Jun Choi Committed by Commit Bot

Plumb Bluetooth authenticator display name to WebAuthN UI

Currently, the only identifier for showing Bluetooth authenticators on
WebAuthN UI modals is the authenticator ID which represents the MAC id
of the device. As this is not user friendly, add human-readable
authenticator_display_name to AuthenticatorReference.

Bug: 877344
Change-Id: I2d3b35db669d8f8f61e9989870122a211d80e80f
Reviewed-on: https://chromium-review.googlesource.com/1247681
Commit-Queue: Jun Choi <hongjunchoi@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595626}
parent 2569149b
...@@ -72,8 +72,11 @@ base::Optional<device::FidoTransportProtocol> SelectMostLikelyTransport( ...@@ -72,8 +72,11 @@ base::Optional<device::FidoTransportProtocol> SelectMostLikelyTransport(
AuthenticatorRequestDialogModel::AuthenticatorReference::AuthenticatorReference( AuthenticatorRequestDialogModel::AuthenticatorReference::AuthenticatorReference(
base::StringPiece authenticator_id, base::StringPiece authenticator_id,
base::StringPiece16 authenticator_display_name,
device::FidoTransportProtocol transport) device::FidoTransportProtocol transport)
: authenticator_id(authenticator_id), transport(transport) {} : authenticator_id(authenticator_id),
authenticator_display_name(authenticator_display_name),
transport(transport) {}
AuthenticatorRequestDialogModel::AuthenticatorReference::AuthenticatorReference( AuthenticatorRequestDialogModel::AuthenticatorReference::AuthenticatorReference(
AuthenticatorReference&& data) = default; AuthenticatorReference&& data) = default;
AuthenticatorRequestDialogModel::AuthenticatorReference& AuthenticatorRequestDialogModel::AuthenticatorReference&
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "chrome/browser/webauthn/authenticator_transport.h" #include "chrome/browser/webauthn/authenticator_transport.h"
#include "chrome/browser/webauthn/transport_list_model.h" #include "chrome/browser/webauthn/transport_list_model.h"
...@@ -72,11 +73,13 @@ class AuthenticatorRequestDialogModel { ...@@ -72,11 +73,13 @@ class AuthenticatorRequestDialogModel {
kCableActivate, kCableActivate,
}; };
// Encapsulates information about authenticators that have been found but are // Encapsulates information about authenticators that have been found and
// in inactive state because we want to dispatch the requests after receiving // whose request is controlled by the UI embedder because we want to dispatch
// confirmation from the user via the WebAuthN UI flow. // the requests after receiving confirmation from the user via the WebAuthN UI
// flow.
struct AuthenticatorReference { struct AuthenticatorReference {
AuthenticatorReference(base::StringPiece device_id, AuthenticatorReference(base::StringPiece device_id,
base::StringPiece16 authenticator_display_name,
device::FidoTransportProtocol transport); device::FidoTransportProtocol transport);
AuthenticatorReference(AuthenticatorReference&& data); AuthenticatorReference(AuthenticatorReference&& data);
AuthenticatorReference& operator=(AuthenticatorReference&& other); AuthenticatorReference& operator=(AuthenticatorReference&& other);
...@@ -84,6 +87,7 @@ class AuthenticatorRequestDialogModel { ...@@ -84,6 +87,7 @@ class AuthenticatorRequestDialogModel {
~AuthenticatorReference(); ~AuthenticatorReference();
std::string authenticator_id; std::string authenticator_id;
base::string16 authenticator_display_name;
device::FidoTransportProtocol transport; device::FidoTransportProtocol transport;
bool dispatched = false; bool dispatched = false;
}; };
......
...@@ -474,7 +474,9 @@ TEST_F(AuthenticatorRequestDialogModelTest, ...@@ -474,7 +474,9 @@ TEST_F(AuthenticatorRequestDialogModelTest,
&num_called)); &num_called));
model.saved_authenticators().emplace_back( model.saved_authenticators().emplace_back(
AuthenticatorRequestDialogModel::AuthenticatorReference( AuthenticatorRequestDialogModel::AuthenticatorReference(
"authenticator", AuthenticatorTransport::kInternal)); "authenticator" /* authenticator_id */,
base::string16() /* authenticator_display_name */,
AuthenticatorTransport::kInternal));
model.StartFlow(std::move(transports_info), base::nullopt); model.StartFlow(std::move(transports_info), base::nullopt);
EXPECT_EQ(AuthenticatorRequestDialogModel::Step::kTransportSelection, EXPECT_EQ(AuthenticatorRequestDialogModel::Step::kTransportSelection,
......
...@@ -300,7 +300,8 @@ void ChromeAuthenticatorRequestDelegate::FidoAuthenticatorAdded( ...@@ -300,7 +300,8 @@ void ChromeAuthenticatorRequestDelegate::FidoAuthenticatorAdded(
return; return;
weak_dialog_model_->saved_authenticators().emplace_back( weak_dialog_model_->saved_authenticators().emplace_back(
authenticator.GetId(), authenticator.AuthenticatorTransport()); authenticator.GetId(), authenticator.GetDisplayName(),
authenticator.AuthenticatorTransport());
} }
void ChromeAuthenticatorRequestDelegate::FidoAuthenticatorRemoved( void ChromeAuthenticatorRequestDelegate::FidoAuthenticatorRemoved(
......
...@@ -67,6 +67,14 @@ std::string FidoBleDevice::GetId() const { ...@@ -67,6 +67,14 @@ std::string FidoBleDevice::GetId() const {
return GetId(connection_->address()); return GetId(connection_->address());
} }
base::string16 FidoBleDevice::GetDisplayName() const {
auto* device = connection_->GetBleDevice();
if (!device)
return base::string16();
return device->GetNameForDisplay();
}
FidoTransportProtocol FidoBleDevice::DeviceTransport() const { FidoTransportProtocol FidoBleDevice::DeviceTransport() const {
return FidoTransportProtocol::kBluetoothLowEnergy; return FidoTransportProtocol::kBluetoothLowEnergy;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "device/fido/ble/fido_ble_connection.h" #include "device/fido/ble/fido_ble_connection.h"
...@@ -42,6 +43,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoBleDevice : public FidoDevice { ...@@ -42,6 +43,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoBleDevice : public FidoDevice {
void TryWink(WinkCallback callback) override; void TryWink(WinkCallback callback) override;
void Cancel() override; void Cancel() override;
std::string GetId() const override; std::string GetId() const override;
base::string16 GetDisplayName() const override;
FidoTransportProtocol DeviceTransport() const override; FidoTransportProtocol DeviceTransport() const override;
// Returns whether or not the underlying BLE device is currently in pairing // Returns whether or not the underlying BLE device is currently in pairing
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h"
#include "device/fido/authenticator_get_assertion_response.h" #include "device/fido/authenticator_get_assertion_response.h"
#include "device/fido/authenticator_make_credential_response.h" #include "device/fido/authenticator_make_credential_response.h"
#include "device/fido/fido_transport_protocol.h" #include "device/fido/fido_transport_protocol.h"
...@@ -48,6 +49,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoAuthenticator { ...@@ -48,6 +49,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoAuthenticator {
GetAssertionCallback callback) = 0; GetAssertionCallback callback) = 0;
virtual void Cancel() = 0; virtual void Cancel() = 0;
virtual std::string GetId() const = 0; virtual std::string GetId() const = 0;
virtual base::string16 GetDisplayName() const = 0;
virtual const AuthenticatorSupportedOptions& Options() const = 0; virtual const AuthenticatorSupportedOptions& Options() const = 0;
virtual FidoTransportProtocol AuthenticatorTransport() const = 0; virtual FidoTransportProtocol AuthenticatorTransport() const = 0;
virtual base::WeakPtr<FidoAuthenticator> GetWeakPtr() = 0; virtual base::WeakPtr<FidoAuthenticator> GetWeakPtr() = 0;
......
...@@ -18,6 +18,11 @@ namespace device { ...@@ -18,6 +18,11 @@ namespace device {
FidoDevice::FidoDevice() = default; FidoDevice::FidoDevice() = default;
FidoDevice::~FidoDevice() = default; FidoDevice::~FidoDevice() = default;
base::string16 FidoDevice::GetDisplayName() const {
const auto id = GetId();
return base::string16(id.begin(), id.end());
}
void FidoDevice::DiscoverSupportedProtocolAndDeviceInfo( void FidoDevice::DiscoverSupportedProtocolAndDeviceInfo(
base::OnceClosure done) { base::OnceClosure done) {
if (base::FeatureList::IsEnabled(kNewCtap2Device)) { if (base::FeatureList::IsEnabled(kNewCtap2Device)) {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h"
#include "device/fido/authenticator_get_info_response.h" #include "device/fido/authenticator_get_info_response.h"
#include "device/fido/fido_constants.h" #include "device/fido/fido_constants.h"
#include "device/fido/fido_transport_protocol.h" #include "device/fido/fido_transport_protocol.h"
...@@ -59,6 +60,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoDevice { ...@@ -59,6 +60,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoDevice {
virtual void TryWink(WinkCallback callback) = 0; virtual void TryWink(WinkCallback callback) = 0;
virtual void Cancel() = 0; virtual void Cancel() = 0;
virtual std::string GetId() const = 0; virtual std::string GetId() const = 0;
virtual base::string16 GetDisplayName() const;
virtual FidoTransportProtocol DeviceTransport() const = 0; virtual FidoTransportProtocol DeviceTransport() const = 0;
virtual base::WeakPtr<FidoDevice> GetWeakPtr() = 0; virtual base::WeakPtr<FidoDevice> GetWeakPtr() = 0;
......
...@@ -60,6 +60,10 @@ std::string FidoDeviceAuthenticator::GetId() const { ...@@ -60,6 +60,10 @@ std::string FidoDeviceAuthenticator::GetId() const {
return device_->GetId(); return device_->GetId();
} }
base::string16 FidoDeviceAuthenticator::GetDisplayName() const {
return device_->GetDisplayName();
}
const AuthenticatorSupportedOptions& FidoDeviceAuthenticator::Options() const { const AuthenticatorSupportedOptions& FidoDeviceAuthenticator::Options() const {
static const AuthenticatorSupportedOptions default_options; static const AuthenticatorSupportedOptions default_options;
switch (device_->supported_protocol()) { switch (device_->supported_protocol()) {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h"
#include "device/fido/fido_authenticator.h" #include "device/fido/fido_authenticator.h"
namespace device { namespace device {
...@@ -40,6 +41,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoDeviceAuthenticator ...@@ -40,6 +41,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoDeviceAuthenticator
GetAssertionCallback callback) override; GetAssertionCallback callback) override;
void Cancel() override; void Cancel() override;
std::string GetId() const override; std::string GetId() const override;
base::string16 GetDisplayName() const override;
const AuthenticatorSupportedOptions& Options() const override; const AuthenticatorSupportedOptions& Options() const override;
FidoTransportProtocol AuthenticatorTransport() const override; FidoTransportProtocol AuthenticatorTransport() const override;
base::WeakPtr<FidoAuthenticator> GetWeakPtr() override; base::WeakPtr<FidoAuthenticator> GetWeakPtr() override;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/mac/availability.h" #include "base/mac/availability.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece_forward.h" #include "base/strings/string_piece_forward.h"
#include "device/fido/fido_authenticator.h" #include "device/fido/fido_authenticator.h"
#include "device/fido/fido_transport_protocol.h" #include "device/fido/fido_transport_protocol.h"
...@@ -56,6 +57,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) TouchIdAuthenticator ...@@ -56,6 +57,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) TouchIdAuthenticator
GetAssertionCallback callback) override; GetAssertionCallback callback) override;
void Cancel() override; void Cancel() override;
std::string GetId() const override; std::string GetId() const override;
base::string16 GetDisplayName() const override;
const AuthenticatorSupportedOptions& Options() const override; const AuthenticatorSupportedOptions& Options() const override;
FidoTransportProtocol AuthenticatorTransport() const override; FidoTransportProtocol AuthenticatorTransport() const override;
base::WeakPtr<FidoAuthenticator> GetWeakPtr() override; base::WeakPtr<FidoAuthenticator> GetWeakPtr() override;
......
...@@ -132,6 +132,10 @@ std::string TouchIdAuthenticator::GetId() const { ...@@ -132,6 +132,10 @@ std::string TouchIdAuthenticator::GetId() const {
return "TouchIdAuthenticator"; return "TouchIdAuthenticator";
} }
base::string16 TouchIdAuthenticator::GetDisplayName() const {
return base::string16();
}
FidoTransportProtocol TouchIdAuthenticator::AuthenticatorTransport() const { FidoTransportProtocol TouchIdAuthenticator::AuthenticatorTransport() const {
return FidoTransportProtocol::kInternal; return FidoTransportProtocol::kInternal;
} }
......
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