1 // Copyright 2019 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/browser/webauth/virtual_authenticator_request_delegate.h"
6 
7 #include <vector>
8 
9 #include "base/callback.h"
10 #include "content/browser/webauth/authenticator_environment_impl.h"
11 #include "device/fido/authenticator_get_assertion_response.h"
12 #include "device/fido/fido_transport_protocol.h"
13 
14 namespace content {
15 
VirtualAuthenticatorRequestDelegate(FrameTreeNode * frame_tree_node)16 VirtualAuthenticatorRequestDelegate::VirtualAuthenticatorRequestDelegate(
17     FrameTreeNode* frame_tree_node)
18     : frame_tree_node_(frame_tree_node) {}
19 
20 VirtualAuthenticatorRequestDelegate::~VirtualAuthenticatorRequestDelegate() =
21     default;
22 
SupportsResidentKeys()23 bool VirtualAuthenticatorRequestDelegate::SupportsResidentKeys() {
24   return true;
25 }
26 
SelectAccount(std::vector<device::AuthenticatorGetAssertionResponse> responses,base::OnceCallback<void (device::AuthenticatorGetAssertionResponse)> callback)27 void VirtualAuthenticatorRequestDelegate::SelectAccount(
28     std::vector<device::AuthenticatorGetAssertionResponse> responses,
29     base::OnceCallback<void(device::AuthenticatorGetAssertionResponse)>
30         callback) {
31   // TODO(crbug.com/991666): Provide a way to determine which account gets
32   // picked.
33   std::move(callback).Run(std::move(responses[0]));
34 }
35 
36 base::Optional<bool> VirtualAuthenticatorRequestDelegate::
IsUserVerifyingPlatformAuthenticatorAvailableOverride()37     IsUserVerifyingPlatformAuthenticatorAvailableOverride() {
38   return AuthenticatorEnvironmentImpl::GetInstance()
39       ->HasVirtualUserVerifyingPlatformAuthenticator(frame_tree_node_);
40 }
41 
42 }  // namespace content
43