1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/public/browser/authenticator_request_client_delegate.h"
6
7 #include <utility>
8
9 #include "base/callback.h"
10 #include "base/strings/string_piece.h"
11 #include "build/build_config.h"
12 #include "device/fido/features.h"
13 #include "device/fido/fido_discovery_factory.h"
14
15 #if defined(OS_WIN)
16 #include "device/fido/win/webauthn_api.h"
17 #endif // defined(OS_WIN)
18
19 namespace content {
20
21 AuthenticatorRequestClientDelegate::AuthenticatorRequestClientDelegate() =
22 default;
23 AuthenticatorRequestClientDelegate::~AuthenticatorRequestClientDelegate() =
24 default;
25
26 base::Optional<std::string>
MaybeGetRelyingPartyIdOverride(const std::string & claimed_relying_party_id,const url::Origin & caller_origin)27 AuthenticatorRequestClientDelegate::MaybeGetRelyingPartyIdOverride(
28 const std::string& claimed_relying_party_id,
29 const url::Origin& caller_origin) {
30 return base::nullopt;
31 }
32
SetRelyingPartyId(const std::string &)33 void AuthenticatorRequestClientDelegate::SetRelyingPartyId(const std::string&) {
34 }
35
DoesBlockRequestOnFailure(InterestingFailureReason reason)36 bool AuthenticatorRequestClientDelegate::DoesBlockRequestOnFailure(
37 InterestingFailureReason reason) {
38 return false;
39 }
40
RegisterActionCallbacks(base::OnceClosure cancel_callback,base::RepeatingClosure start_over_callback,device::FidoRequestHandlerBase::RequestCallback request_callback,base::RepeatingClosure bluetooth_adapter_power_on_callback)41 void AuthenticatorRequestClientDelegate::RegisterActionCallbacks(
42 base::OnceClosure cancel_callback,
43 base::RepeatingClosure start_over_callback,
44 device::FidoRequestHandlerBase::RequestCallback request_callback,
45 base::RepeatingClosure bluetooth_adapter_power_on_callback) {}
46
ShouldPermitIndividualAttestation(const std::string & relying_party_id)47 bool AuthenticatorRequestClientDelegate::ShouldPermitIndividualAttestation(
48 const std::string& relying_party_id) {
49 return false;
50 }
51
ShouldReturnAttestation(const std::string & relying_party_id,const device::FidoAuthenticator * authenticator,bool is_enterprise_attestation,base::OnceCallback<void (bool)> callback)52 void AuthenticatorRequestClientDelegate::ShouldReturnAttestation(
53 const std::string& relying_party_id,
54 const device::FidoAuthenticator* authenticator,
55 bool is_enterprise_attestation,
56 base::OnceCallback<void(bool)> callback) {
57 std::move(callback).Run(!is_enterprise_attestation);
58 }
59
SupportsResidentKeys()60 bool AuthenticatorRequestClientDelegate::SupportsResidentKeys() {
61 return false;
62 }
63
SetMightCreateResidentCredential(bool v)64 void AuthenticatorRequestClientDelegate::SetMightCreateResidentCredential(
65 bool v) {}
66
ConfigureCable(const url::Origin & origin,base::span<const device::CableDiscoveryData> pairings_from_extension,device::FidoDiscoveryFactory * fido_discovery_factory)67 void AuthenticatorRequestClientDelegate::ConfigureCable(
68 const url::Origin& origin,
69 base::span<const device::CableDiscoveryData> pairings_from_extension,
70 device::FidoDiscoveryFactory* fido_discovery_factory) {}
71
SelectAccount(std::vector<device::AuthenticatorGetAssertionResponse> responses,base::OnceCallback<void (device::AuthenticatorGetAssertionResponse)> callback)72 void AuthenticatorRequestClientDelegate::SelectAccount(
73 std::vector<device::AuthenticatorGetAssertionResponse> responses,
74 base::OnceCallback<void(device::AuthenticatorGetAssertionResponse)>
75 callback) {
76 // SupportsResidentKeys returned false so this should never be called.
77 NOTREACHED();
78 }
79
IsFocused()80 bool AuthenticatorRequestClientDelegate::IsFocused() {
81 return true;
82 }
83
84 #if defined(OS_MAC)
85 base::Optional<AuthenticatorRequestClientDelegate::TouchIdAuthenticatorConfig>
GetTouchIdAuthenticatorConfig()86 AuthenticatorRequestClientDelegate::GetTouchIdAuthenticatorConfig() {
87 return base::nullopt;
88 }
89 #endif // defined(OS_MAC)
90
91 #if defined(OS_CHROMEOS)
92 AuthenticatorRequestClientDelegate::ChromeOSGenerateRequestIdCallback
GetGenerateRequestIdCallback(RenderFrameHost * render_frame_host)93 AuthenticatorRequestClientDelegate::GetGenerateRequestIdCallback(
94 RenderFrameHost* render_frame_host) {
95 return base::NullCallback();
96 }
97 #endif
98
99 base::Optional<bool> AuthenticatorRequestClientDelegate::
IsUserVerifyingPlatformAuthenticatorAvailableOverride()100 IsUserVerifyingPlatformAuthenticatorAvailableOverride() {
101 return base::nullopt;
102 }
103
UpdateLastTransportUsed(device::FidoTransportProtocol transport)104 void AuthenticatorRequestClientDelegate::UpdateLastTransportUsed(
105 device::FidoTransportProtocol transport) {}
106
DisableUI()107 void AuthenticatorRequestClientDelegate::DisableUI() {}
108
IsWebAuthnUIEnabled()109 bool AuthenticatorRequestClientDelegate::IsWebAuthnUIEnabled() {
110 return false;
111 }
112
OnTransportAvailabilityEnumerated(device::FidoRequestHandlerBase::TransportAvailabilityInfo data)113 void AuthenticatorRequestClientDelegate::OnTransportAvailabilityEnumerated(
114 device::FidoRequestHandlerBase::TransportAvailabilityInfo data) {}
115
EmbedderControlsAuthenticatorDispatch(const device::FidoAuthenticator & authenticator)116 bool AuthenticatorRequestClientDelegate::EmbedderControlsAuthenticatorDispatch(
117 const device::FidoAuthenticator& authenticator) {
118 return false;
119 }
120
BluetoothAdapterPowerChanged(bool is_powered_on)121 void AuthenticatorRequestClientDelegate::BluetoothAdapterPowerChanged(
122 bool is_powered_on) {}
123
FidoAuthenticatorAdded(const device::FidoAuthenticator & authenticator)124 void AuthenticatorRequestClientDelegate::FidoAuthenticatorAdded(
125 const device::FidoAuthenticator& authenticator) {}
126
FidoAuthenticatorRemoved(base::StringPiece device_id)127 void AuthenticatorRequestClientDelegate::FidoAuthenticatorRemoved(
128 base::StringPiece device_id) {}
129
SupportsPIN() const130 bool AuthenticatorRequestClientDelegate::SupportsPIN() const {
131 return false;
132 }
133
CollectPIN(base::Optional<int> attempts,base::OnceCallback<void (std::string)> provide_pin_cb)134 void AuthenticatorRequestClientDelegate::CollectPIN(
135 base::Optional<int> attempts,
136 base::OnceCallback<void(std::string)> provide_pin_cb) {
137 NOTREACHED();
138 }
139
StartBioEnrollment(base::OnceClosure next_callback)140 void AuthenticatorRequestClientDelegate::StartBioEnrollment(
141 base::OnceClosure next_callback) {}
142
OnSampleCollected(int bio_samples_remaining)143 void AuthenticatorRequestClientDelegate::OnSampleCollected(
144 int bio_samples_remaining) {}
145
FinishCollectToken()146 void AuthenticatorRequestClientDelegate::FinishCollectToken() {}
147
OnRetryUserVerification(int attempts)148 void AuthenticatorRequestClientDelegate::OnRetryUserVerification(int attempts) {
149 }
150
OnInternalUserVerificationLocked()151 void AuthenticatorRequestClientDelegate::OnInternalUserVerificationLocked() {}
152
153 } // namespace content
154