Migrate absl variant.h and utility.h in device
Since https://crrev.com/c/6330348, some utils in third_party/abseil-cpp/absl/types/variant.h and and third_party/abseil-cpp/absl/utility/utility.h are only aliases for their std counterparts. This CL migrates code to use std:: directly. Bug: 40242126 Change-Id: Icc6dcd8f2b4623dddcb34df689d154dad9a02e52 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6343310 Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Victor Vianna <victorvianna@google.com> Cr-Commit-Position: refs/heads/main@{#1434177}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
351a0d625e
commit
21512f1765
device
bluetooth
fido
cable
cable_discovery_data.hfido_tunnel_device.ccfido_tunnel_device.hv2_authenticator.ccv2_authenticator.hv2_handshake.ccv2_handshake.h
enclave
vr
android
@ -4,6 +4,8 @@
|
||||
|
||||
#include "device/bluetooth/floss/floss_sdp_types.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
|
||||
namespace floss {
|
||||
@ -55,22 +57,22 @@ constexpr char kSdpDipRecordPropPrimaryRecord[] = "primary_record";
|
||||
|
||||
std::optional<floss::BtSdpHeaderOverlay> GetHeaderOverlayFromSdpRecord(
|
||||
const floss::BtSdpRecord& record) {
|
||||
if (absl::holds_alternative<floss::BtSdpHeaderOverlay>(record)) {
|
||||
return absl::get<floss::BtSdpHeaderOverlay>(record);
|
||||
} else if (absl::holds_alternative<floss::BtSdpMasRecord>(record)) {
|
||||
return absl::get<floss::BtSdpMasRecord>(record).hdr;
|
||||
} else if (absl::holds_alternative<floss::BtSdpMnsRecord>(record)) {
|
||||
return absl::get<floss::BtSdpMnsRecord>(record).hdr;
|
||||
} else if (absl::holds_alternative<floss::BtSdpPseRecord>(record)) {
|
||||
return absl::get<floss::BtSdpPseRecord>(record).hdr;
|
||||
} else if (absl::holds_alternative<floss::BtSdpPceRecord>(record)) {
|
||||
return absl::get<floss::BtSdpPceRecord>(record).hdr;
|
||||
} else if (absl::holds_alternative<floss::BtSdpOpsRecord>(record)) {
|
||||
return absl::get<floss::BtSdpOpsRecord>(record).hdr;
|
||||
} else if (absl::holds_alternative<floss::BtSdpSapRecord>(record)) {
|
||||
return absl::get<floss::BtSdpSapRecord>(record).hdr;
|
||||
} else if (absl::holds_alternative<floss::BtSdpDipRecord>(record)) {
|
||||
return absl::get<floss::BtSdpDipRecord>(record).hdr;
|
||||
if (std::holds_alternative<floss::BtSdpHeaderOverlay>(record)) {
|
||||
return std::get<floss::BtSdpHeaderOverlay>(record);
|
||||
} else if (std::holds_alternative<floss::BtSdpMasRecord>(record)) {
|
||||
return std::get<floss::BtSdpMasRecord>(record).hdr;
|
||||
} else if (std::holds_alternative<floss::BtSdpMnsRecord>(record)) {
|
||||
return std::get<floss::BtSdpMnsRecord>(record).hdr;
|
||||
} else if (std::holds_alternative<floss::BtSdpPseRecord>(record)) {
|
||||
return std::get<floss::BtSdpPseRecord>(record).hdr;
|
||||
} else if (std::holds_alternative<floss::BtSdpPceRecord>(record)) {
|
||||
return std::get<floss::BtSdpPceRecord>(record).hdr;
|
||||
} else if (std::holds_alternative<floss::BtSdpOpsRecord>(record)) {
|
||||
return std::get<floss::BtSdpOpsRecord>(record).hdr;
|
||||
} else if (std::holds_alternative<floss::BtSdpSapRecord>(record)) {
|
||||
return std::get<floss::BtSdpSapRecord>(record).hdr;
|
||||
} else if (std::holds_alternative<floss::BtSdpDipRecord>(record)) {
|
||||
return std::get<floss::BtSdpDipRecord>(record).hdr;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -526,46 +528,46 @@ void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
|
||||
dbus::MessageWriter array_writer(nullptr);
|
||||
writer->OpenArray("{sv}", &array_writer);
|
||||
|
||||
if (absl::holds_alternative<BtSdpHeaderOverlay>(record)) {
|
||||
if (std::holds_alternative<BtSdpHeaderOverlay>(record)) {
|
||||
WriteDictEntry(&array_writer, kTypeKey,
|
||||
static_cast<uint32_t>(BtSdpType::kRaw));
|
||||
WriteDictEntry(&array_writer, kVariantValueKey,
|
||||
absl::get<BtSdpHeaderOverlay>(record));
|
||||
} else if (absl::holds_alternative<BtSdpMasRecord>(record)) {
|
||||
std::get<BtSdpHeaderOverlay>(record));
|
||||
} else if (std::holds_alternative<BtSdpMasRecord>(record)) {
|
||||
WriteDictEntry(&array_writer, kTypeKey,
|
||||
static_cast<uint32_t>(BtSdpType::kMapMas));
|
||||
WriteDictEntry(&array_writer, kVariantValueKey,
|
||||
absl::get<BtSdpMasRecord>(record));
|
||||
} else if (absl::holds_alternative<BtSdpMnsRecord>(record)) {
|
||||
std::get<BtSdpMasRecord>(record));
|
||||
} else if (std::holds_alternative<BtSdpMnsRecord>(record)) {
|
||||
WriteDictEntry(&array_writer, kTypeKey,
|
||||
static_cast<uint32_t>(BtSdpType::kMapMns));
|
||||
WriteDictEntry(&array_writer, kVariantValueKey,
|
||||
absl::get<BtSdpMnsRecord>(record));
|
||||
} else if (absl::holds_alternative<BtSdpPseRecord>(record)) {
|
||||
std::get<BtSdpMnsRecord>(record));
|
||||
} else if (std::holds_alternative<BtSdpPseRecord>(record)) {
|
||||
WriteDictEntry(&array_writer, kTypeKey,
|
||||
static_cast<uint32_t>(BtSdpType::kPbapPse));
|
||||
WriteDictEntry(&array_writer, kVariantValueKey,
|
||||
absl::get<BtSdpPseRecord>(record));
|
||||
} else if (absl::holds_alternative<BtSdpPceRecord>(record)) {
|
||||
std::get<BtSdpPseRecord>(record));
|
||||
} else if (std::holds_alternative<BtSdpPceRecord>(record)) {
|
||||
WriteDictEntry(&array_writer, kTypeKey,
|
||||
static_cast<uint32_t>(BtSdpType::kPbapPce));
|
||||
WriteDictEntry(&array_writer, kVariantValueKey,
|
||||
absl::get<BtSdpPceRecord>(record));
|
||||
} else if (absl::holds_alternative<BtSdpOpsRecord>(record)) {
|
||||
std::get<BtSdpPceRecord>(record));
|
||||
} else if (std::holds_alternative<BtSdpOpsRecord>(record)) {
|
||||
WriteDictEntry(&array_writer, kTypeKey,
|
||||
static_cast<uint32_t>(BtSdpType::kOppServer));
|
||||
WriteDictEntry(&array_writer, kVariantValueKey,
|
||||
absl::get<BtSdpOpsRecord>(record));
|
||||
} else if (absl::holds_alternative<BtSdpSapRecord>(record)) {
|
||||
std::get<BtSdpOpsRecord>(record));
|
||||
} else if (std::holds_alternative<BtSdpSapRecord>(record)) {
|
||||
WriteDictEntry(&array_writer, kTypeKey,
|
||||
static_cast<uint32_t>(BtSdpType::kSapServer));
|
||||
WriteDictEntry(&array_writer, kVariantValueKey,
|
||||
absl::get<BtSdpSapRecord>(record));
|
||||
} else if (absl::holds_alternative<BtSdpDipRecord>(record)) {
|
||||
std::get<BtSdpSapRecord>(record));
|
||||
} else if (std::holds_alternative<BtSdpDipRecord>(record)) {
|
||||
WriteDictEntry(&array_writer, kTypeKey,
|
||||
static_cast<uint32_t>(BtSdpType::kDip));
|
||||
WriteDictEntry(&array_writer, kVariantValueKey,
|
||||
absl::get<BtSdpDipRecord>(record));
|
||||
std::get<BtSdpDipRecord>(record));
|
||||
}
|
||||
|
||||
writer->CloseContainer(&array_writer);
|
||||
|
@ -5,11 +5,11 @@
|
||||
#define DEVICE_BLUETOOTH_FLOSS_FLOSS_SDP_TYPES_H_
|
||||
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
#include "device/bluetooth/bluetooth_device.h"
|
||||
#include "device/bluetooth/bluetooth_export.h"
|
||||
#include "device/bluetooth/floss/floss_dbus_client.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
|
||||
namespace floss {
|
||||
|
||||
@ -85,14 +85,14 @@ struct DEVICE_BLUETOOTH_EXPORT BtSdpDipRecord {
|
||||
bool primary_record;
|
||||
};
|
||||
|
||||
using BtSdpRecord = absl::variant<BtSdpHeaderOverlay,
|
||||
BtSdpMasRecord,
|
||||
BtSdpMnsRecord,
|
||||
BtSdpPseRecord,
|
||||
BtSdpPceRecord,
|
||||
BtSdpOpsRecord,
|
||||
BtSdpSapRecord,
|
||||
BtSdpDipRecord>;
|
||||
using BtSdpRecord = std::variant<BtSdpHeaderOverlay,
|
||||
BtSdpMasRecord,
|
||||
BtSdpMnsRecord,
|
||||
BtSdpPseRecord,
|
||||
BtSdpPceRecord,
|
||||
BtSdpOpsRecord,
|
||||
BtSdpSapRecord,
|
||||
BtSdpDipRecord>;
|
||||
std::optional<floss::BtSdpHeaderOverlay> DEVICE_BLUETOOTH_EXPORT
|
||||
GetHeaderOverlayFromSdpRecord(const floss::BtSdpRecord& record);
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "base/component_export.h"
|
||||
@ -18,7 +19,6 @@
|
||||
#include "base/time/time.h"
|
||||
#include "device/fido/cable/v2_constants.h"
|
||||
#include "device/fido/fido_constants.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
#include "third_party/icu/source/common/unicode/uversion.h"
|
||||
|
||||
namespace cbor {
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "device/fido/cable/fido_tunnel_device.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
#include "base/metrics/histogram_functions.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
@ -115,7 +117,7 @@ FidoTunnelDevice::FidoTunnelDevice(
|
||||
must_support_ctap_(must_support_ctap) {
|
||||
const eid::Components components = eid::ToComponents(decrypted_eid);
|
||||
|
||||
QRInfo& info = absl::get<QRInfo>(info_);
|
||||
QRInfo& info = std::get<QRInfo>(info_);
|
||||
info.pairing_callback = std::move(pairing_callback);
|
||||
info.local_identity_seed =
|
||||
fido_parsing_utils::Materialize(local_identity_seed);
|
||||
@ -173,7 +175,7 @@ FidoTunnelDevice::FidoTunnelDevice(
|
||||
CHECK(client_payload_bytes.has_value());
|
||||
const std::string client_payload_hex = base::HexEncode(*client_payload_bytes);
|
||||
|
||||
PairedInfo& info = absl::get<PairedInfo>(info_);
|
||||
PairedInfo& info = std::get<PairedInfo>(info_);
|
||||
info.eid_encryption_key = Derive<kEIDKeySize>(pairing->secret, client_nonce,
|
||||
DerivedValueType::kEIDKey);
|
||||
info.peer_identity = pairing->peer_public_key_x962;
|
||||
@ -216,7 +218,7 @@ FidoTunnelDevice::~FidoTunnelDevice() {
|
||||
|
||||
bool FidoTunnelDevice::MatchAdvert(
|
||||
const std::array<uint8_t, kAdvertSize>& advert) {
|
||||
PairedInfo& info = absl::get<PairedInfo>(info_);
|
||||
PairedInfo& info = std::get<PairedInfo>(info_);
|
||||
|
||||
std::optional<CableEidArray> plaintext =
|
||||
eid::Decrypt(advert, info.eid_encryption_key);
|
||||
@ -356,14 +358,14 @@ void FidoTunnelDevice::OnTunnelReady(
|
||||
DCHECK(!handshake_);
|
||||
RecordEvent(CableV2TunnelEvent::kTunnelOk);
|
||||
|
||||
if (auto* info = absl::get_if<QRInfo>(&info_)) {
|
||||
if (auto* info = std::get_if<QRInfo>(&info_)) {
|
||||
// A QR handshake can start as soon as the tunnel is connected.
|
||||
handshake_.emplace(info->psk, /*peer_identity=*/std::nullopt,
|
||||
info->local_identity_seed);
|
||||
} else {
|
||||
// A paired handshake may be able to start if we have already seen
|
||||
// the BLE advert.
|
||||
PairedInfo& paired_info = absl::get<PairedInfo>(info_);
|
||||
PairedInfo& paired_info = std::get<PairedInfo>(info_);
|
||||
if (paired_info.psk) {
|
||||
handshake_.emplace(*paired_info.psk, paired_info.peer_identity,
|
||||
/*local_identity=*/std::nullopt);
|
||||
@ -385,7 +387,7 @@ void FidoTunnelDevice::OnTunnelReady(
|
||||
break;
|
||||
|
||||
case WebSocketAdapter::Result::GONE:
|
||||
if (auto* info = absl::get_if<PairedInfo>(&info_)) {
|
||||
if (auto* info = std::get_if<PairedInfo>(&info_)) {
|
||||
FIDO_LOG(DEBUG) << GetId()
|
||||
<< ": tunnel server reports that contact ID is invalid";
|
||||
RecordEvent(CableV2TunnelEvent::kTunnelGone);
|
||||
@ -556,7 +558,7 @@ void FidoTunnelDevice::OnTunnelData(
|
||||
OnError();
|
||||
return;
|
||||
}
|
||||
if (auto* info = absl::get_if<QRInfo>(&info_)) {
|
||||
if (auto* info = std::get_if<QRInfo>(&info_)) {
|
||||
std::optional<std::unique_ptr<Pairing>> maybe_pairing =
|
||||
Pairing::Parse(linking_it->second, info->tunnel_server_domain,
|
||||
info->local_identity_seed, *handshake_hash_);
|
||||
@ -588,7 +590,7 @@ void FidoTunnelDevice::OnTunnelData(
|
||||
|
||||
established_connection_ = base::MakeRefCounted<EstablishedConnection>(
|
||||
std::move(websocket_client_), GetId(), protocol_revision,
|
||||
std::move(crypter_), *handshake_hash_, absl::get_if<QRInfo>(&info_));
|
||||
std::move(crypter_), *handshake_hash_, std::get_if<QRInfo>(&info_));
|
||||
|
||||
if (discover_callback_) {
|
||||
CHECK(features_.has_value());
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define DEVICE_FIDO_CABLE_FIDO_TUNNEL_DEVICE_H_
|
||||
|
||||
#include <array>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
@ -18,7 +19,6 @@
|
||||
#include "device/fido/fido_constants.h"
|
||||
#include "device/fido/fido_device.h"
|
||||
#include "device/fido/network_context_factory.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
|
||||
namespace device::cablev2 {
|
||||
|
||||
@ -237,7 +237,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoTunnelDevice : public FidoDevice {
|
||||
bool ProcessConnectSignal(base::span<const uint8_t> data);
|
||||
|
||||
State state_ = State::kConnecting;
|
||||
absl::variant<QRInfo, PairedInfo> info_;
|
||||
std::variant<QRInfo, PairedInfo> info_;
|
||||
const std::array<uint8_t, 8> id_;
|
||||
const std::optional<base::RepeatingCallback<void(Event)>> event_callback_;
|
||||
const bool must_support_ctap_;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/feature_list.h"
|
||||
@ -40,7 +41,6 @@
|
||||
#include "net/storage_access_api/status.h"
|
||||
#include "net/traffic_annotation/network_traffic_annotation.h"
|
||||
#include "services/network/public/mojom/network_context.mojom.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
#include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h"
|
||||
#include "third_party/boringssl/src/include/openssl/aes.h"
|
||||
#include "third_party/boringssl/src/include/openssl/ec_key.h"
|
||||
@ -672,14 +672,14 @@ class CTAP2Processor : public Transaction {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto* error = absl::get_if<Platform::Error>(&update)) {
|
||||
if (auto* error = std::get_if<Platform::Error>(&update)) {
|
||||
have_completed_ = true;
|
||||
platform_->OnCompleted(*error);
|
||||
return;
|
||||
} else if (auto* status = absl::get_if<Platform::Status>(&update)) {
|
||||
} else if (auto* status = std::get_if<Platform::Status>(&update)) {
|
||||
platform_->OnStatus(*status);
|
||||
return;
|
||||
} else if (absl::get_if<Transport::Disconnected>(&update)) {
|
||||
} else if (std::get_if<Transport::Disconnected>(&update)) {
|
||||
std::optional<Platform::Error> maybe_error;
|
||||
if (!transaction_received_) {
|
||||
maybe_error = Platform::Error::UNEXPECTED_EOF;
|
||||
@ -691,22 +691,22 @@ class CTAP2Processor : public Transaction {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& msg = absl::get<std::pair<PayloadType, std::vector<uint8_t>>>(update);
|
||||
auto& msg = std::get<std::pair<PayloadType, std::vector<uint8_t>>>(update);
|
||||
if (msg.first != PayloadType::kCTAP) {
|
||||
have_completed_ = true;
|
||||
platform_->OnCompleted(Platform::Error::INVALID_CTAP);
|
||||
return;
|
||||
}
|
||||
const absl::variant<std::vector<uint8_t>, Platform::Error> result =
|
||||
const std::variant<std::vector<uint8_t>, Platform::Error> result =
|
||||
ProcessCTAPMessage(msg.second);
|
||||
if (const auto* error = absl::get_if<Platform::Error>(&result)) {
|
||||
if (const auto* error = std::get_if<Platform::Error>(&result)) {
|
||||
have_completed_ = true;
|
||||
platform_->OnCompleted(*error);
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<uint8_t>& response =
|
||||
absl::get<std::vector<uint8_t>>(result);
|
||||
std::get<std::vector<uint8_t>>(result);
|
||||
if (response.empty()) {
|
||||
// Response is pending.
|
||||
return;
|
||||
@ -715,7 +715,7 @@ class CTAP2Processor : public Transaction {
|
||||
transport_->Write(PayloadType::kCTAP, std::move(response));
|
||||
}
|
||||
|
||||
absl::variant<std::vector<uint8_t>, Platform::Error> ProcessCTAPMessage(
|
||||
std::variant<std::vector<uint8_t>, Platform::Error> ProcessCTAPMessage(
|
||||
base::span<const uint8_t> message_bytes) {
|
||||
if (message_bytes.empty()) {
|
||||
return Platform::Error::INVALID_CTAP;
|
||||
@ -1142,20 +1142,20 @@ class DigitalIdentityProcessor : public Transaction {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
CHECK(!have_completed_);
|
||||
|
||||
if (auto* error = absl::get_if<Platform::Error>(&update)) {
|
||||
if (auto* error = std::get_if<Platform::Error>(&update)) {
|
||||
have_completed_ = true;
|
||||
platform_->OnCompleted(*error);
|
||||
return;
|
||||
} else if (auto* status = absl::get_if<Platform::Status>(&update)) {
|
||||
} else if (auto* status = std::get_if<Platform::Status>(&update)) {
|
||||
platform_->OnStatus(*status);
|
||||
return;
|
||||
} else if (absl::get_if<Transport::Disconnected>(&update)) {
|
||||
} else if (std::get_if<Transport::Disconnected>(&update)) {
|
||||
have_completed_ = true;
|
||||
platform_->OnCompleted(std::nullopt);
|
||||
return;
|
||||
}
|
||||
|
||||
auto& msg = absl::get<std::pair<PayloadType, std::vector<uint8_t>>>(update);
|
||||
auto& msg = std::get<std::pair<PayloadType, std::vector<uint8_t>>>(update);
|
||||
if (msg.first != PayloadType::kJSON) {
|
||||
have_completed_ = true;
|
||||
platform_->OnCompleted(Platform::Error::INVALID_JSON);
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/span.h"
|
||||
@ -16,7 +17,6 @@
|
||||
#include "device/fido/cable/v2_constants.h"
|
||||
#include "device/fido/fido_constants.h"
|
||||
#include "device/fido/network_context_factory.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
#include "third_party/blink/public/mojom/webauthn/authenticator.mojom-forward.h"
|
||||
|
||||
namespace device::cablev2::authenticator {
|
||||
@ -108,10 +108,10 @@ class Transport {
|
||||
// report. The first element is a message from the peer. |Disconnected| is
|
||||
// handled separately because it's context dependent whether that is an error
|
||||
// or not.
|
||||
using Update = absl::variant<std::pair<PayloadType, std::vector<uint8_t>>,
|
||||
Platform::Error,
|
||||
Platform::Status,
|
||||
Disconnected>;
|
||||
using Update = std::variant<std::pair<PayloadType, std::vector<uint8_t>>,
|
||||
Platform::Error,
|
||||
Platform::Status,
|
||||
Disconnected>;
|
||||
virtual ~Transport();
|
||||
|
||||
// StartReading requests that the given callback be called whenever a message
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
|
||||
#include "base/base64url.h"
|
||||
#include "base/feature_list.h"
|
||||
@ -581,7 +582,7 @@ void Derive(uint8_t* out,
|
||||
} // namespace internal
|
||||
|
||||
const char* RequestTypeToString(RequestType request_type) {
|
||||
return absl::visit(
|
||||
return std::visit(
|
||||
base::Overloaded{[](const FidoRequestType& request_type) {
|
||||
switch (request_type) {
|
||||
case FidoRequestType::kMakeCredential:
|
||||
@ -680,7 +681,7 @@ std::optional<std::vector<uint8_t>> EncodePaddedCBORMap(
|
||||
}
|
||||
|
||||
bool ShouldOfferLinking(RequestType request_type) {
|
||||
return absl::visit(
|
||||
return std::visit(
|
||||
base::Overloaded{[](const FidoRequestType&) {
|
||||
return base::FeatureList::IsEnabled(
|
||||
device::kWebAuthnHybridLinking);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "base/containers/span.h"
|
||||
@ -19,7 +20,6 @@
|
||||
#include "device/fido/cable/noise.h"
|
||||
#include "device/fido/cable/v2_constants.h"
|
||||
#include "device/fido/fido_constants.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
#include "third_party/boringssl/src/include/openssl/base.h"
|
||||
|
||||
class GURL;
|
||||
@ -28,7 +28,7 @@ namespace device::cablev2 {
|
||||
|
||||
// The different types of digital credential requests.
|
||||
enum CredentialRequestType { kPresentation, kIssuance };
|
||||
using RequestType = absl::variant<FidoRequestType, CredentialRequestType>;
|
||||
using RequestType = std::variant<FidoRequestType, CredentialRequestType>;
|
||||
|
||||
namespace tunnelserver {
|
||||
// ToKnownDomainID creates a KnownDomainID from a raw 16-bit value, or returns
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback.h"
|
||||
@ -23,7 +24,6 @@
|
||||
#include "device/fido/enclave/types.h"
|
||||
#include "device/fido/fido_parsing_utils.h"
|
||||
#include "device/fido/public_key_credential_descriptor.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
|
||||
namespace device::enclave {
|
||||
|
||||
@ -342,8 +342,8 @@ void EnclaveAuthenticator::ProcessMakeCredentialResponse(
|
||||
auto parse_result = ParseMakeCredentialResponse(
|
||||
std::move(response), pending_make_credential_request_->request,
|
||||
*ui_request_->key_version, ui_request_->up_and_uv_bits);
|
||||
if (absl::holds_alternative<ErrorResponse>(parse_result)) {
|
||||
auto& error_details = absl::get<ErrorResponse>(parse_result);
|
||||
if (std::holds_alternative<ErrorResponse>(parse_result)) {
|
||||
auto& error_details = std::get<ErrorResponse>(parse_result);
|
||||
ProcessErrorResponse(error_details);
|
||||
return;
|
||||
}
|
||||
@ -353,8 +353,8 @@ void EnclaveAuthenticator::ProcessMakeCredentialResponse(
|
||||
.Run(PINValidationResult::kSuccess);
|
||||
}
|
||||
auto& success_result =
|
||||
absl::get<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(parse_result);
|
||||
std::get<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(parse_result);
|
||||
std::move(ui_request_->save_passkey_callback)
|
||||
.Run(std::move(success_result.second));
|
||||
RecordRequestResult("MakeCredential", EnclaveRequestResult::kSuccess);
|
||||
@ -391,8 +391,8 @@ void EnclaveAuthenticator::ProcessGetAssertionResponse(
|
||||
const std::string& cred_id_str = ui_request_->entity->credential_id();
|
||||
auto parse_result = ParseGetAssertionResponse(
|
||||
std::move(response), base::as_byte_span(cred_id_str));
|
||||
if (absl::holds_alternative<ErrorResponse>(parse_result)) {
|
||||
auto& error_details = absl::get<ErrorResponse>(parse_result);
|
||||
if (std::holds_alternative<ErrorResponse>(parse_result)) {
|
||||
auto& error_details = std::get<ErrorResponse>(parse_result);
|
||||
ProcessErrorResponse(error_details);
|
||||
return;
|
||||
}
|
||||
@ -402,22 +402,22 @@ void EnclaveAuthenticator::ProcessGetAssertionResponse(
|
||||
}
|
||||
std::vector<AuthenticatorGetAssertionResponse> responses;
|
||||
responses.emplace_back(
|
||||
std::move(absl::get<AuthenticatorGetAssertionResponse>(parse_result)));
|
||||
std::move(std::get<AuthenticatorGetAssertionResponse>(parse_result)));
|
||||
RecordRequestResult("GetAssertion", EnclaveRequestResult::kSuccess);
|
||||
CompleteGetAssertionRequest(GetAssertionStatus::kSuccess,
|
||||
std::move(responses));
|
||||
}
|
||||
|
||||
void EnclaveAuthenticator::CompleteRequestWithError(
|
||||
absl::variant<GetAssertionStatus, MakeCredentialStatus> error) {
|
||||
if (absl::holds_alternative<GetAssertionStatus>(error)) {
|
||||
std::variant<GetAssertionStatus, MakeCredentialStatus> error) {
|
||||
if (std::holds_alternative<GetAssertionStatus>(error)) {
|
||||
CHECK(pending_get_assertion_request_);
|
||||
CompleteGetAssertionRequest(absl::get<GetAssertionStatus>(error), {});
|
||||
CompleteGetAssertionRequest(std::get<GetAssertionStatus>(error), {});
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK(pending_make_credential_request_);
|
||||
CompleteMakeCredentialRequest(absl::get<MakeCredentialStatus>(error),
|
||||
CompleteMakeCredentialRequest(std::get<MakeCredentialStatus>(error),
|
||||
std::nullopt);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "base/component_export.h"
|
||||
@ -107,7 +108,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) EnclaveAuthenticator
|
||||
// `Complete*` methods invoke callbacks that can result in `this` being
|
||||
// destroyed, and so should only be called immediately before a return.
|
||||
void CompleteRequestWithError(
|
||||
absl::variant<GetAssertionStatus, MakeCredentialStatus> error);
|
||||
std::variant<GetAssertionStatus, MakeCredentialStatus> error);
|
||||
void CompleteMakeCredentialRequest(
|
||||
MakeCredentialStatus status,
|
||||
std::optional<AuthenticatorMakeCredentialResponse> response);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "device/fido/enclave/enclave_protocol_utils.h"
|
||||
|
||||
#include <array>
|
||||
#include <variant>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/json/json_reader.h"
|
||||
@ -240,7 +241,7 @@ ErrorResponse::ErrorResponse(ErrorResponse&) = default;
|
||||
|
||||
ErrorResponse::ErrorResponse(ErrorResponse&&) = default;
|
||||
|
||||
absl::variant<AuthenticatorGetAssertionResponse, ErrorResponse>
|
||||
std::variant<AuthenticatorGetAssertionResponse, ErrorResponse>
|
||||
ParseGetAssertionResponse(cbor::Value response_value,
|
||||
base::span<const uint8_t> credential_id) {
|
||||
if (!response_value.is_array() || response_value.GetArray().empty()) {
|
||||
@ -312,9 +313,9 @@ ParseGetAssertionResponse(cbor::Value response_value,
|
||||
return std::move(*response);
|
||||
}
|
||||
|
||||
absl::variant<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>,
|
||||
ErrorResponse>
|
||||
std::variant<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>,
|
||||
ErrorResponse>
|
||||
ParseMakeCredentialResponse(cbor::Value response_value,
|
||||
const CtapMakeCredentialRequest& request,
|
||||
int32_t wrapped_secret_version,
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "base/component_export.h"
|
||||
@ -19,7 +20,6 @@
|
||||
#include "device/fido/ctap_get_assertion_request.h"
|
||||
#include "device/fido/ctap_make_credential_request.h"
|
||||
#include "device/fido/enclave/types.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
|
||||
namespace sync_pb {
|
||||
class WebauthnCredentialSpecifics;
|
||||
@ -63,19 +63,19 @@ struct COMPONENT_EXPORT(DEVICE_FIDO) ErrorResponse {
|
||||
// one is for the GetAssertion.
|
||||
// Returns one of: A successful response, or a struct containing details of
|
||||
// the error.
|
||||
absl::variant<AuthenticatorGetAssertionResponse, ErrorResponse>
|
||||
COMPONENT_EXPORT(DEVICE_FIDO)
|
||||
ParseGetAssertionResponse(cbor::Value response_value,
|
||||
base::span<const uint8_t> credential_id);
|
||||
std::variant<AuthenticatorGetAssertionResponse, ErrorResponse> COMPONENT_EXPORT(
|
||||
DEVICE_FIDO)
|
||||
ParseGetAssertionResponse(cbor::Value response_value,
|
||||
base::span<const uint8_t> credential_id);
|
||||
|
||||
// Parses a decrypted registration command response from the enclave.
|
||||
// If there are multiple request responses in the array, it assumes the last
|
||||
// one is for the MakeCredential.
|
||||
// Returns one of: A pair containing the response and the new passkey entity,
|
||||
// a struct containing details of the error.
|
||||
absl::variant<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>,
|
||||
ErrorResponse>
|
||||
std::variant<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>,
|
||||
ErrorResponse>
|
||||
COMPONENT_EXPORT(DEVICE_FIDO)
|
||||
ParseMakeCredentialResponse(cbor::Value response,
|
||||
const CtapMakeCredentialRequest& request,
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/span.h"
|
||||
@ -28,7 +29,6 @@
|
||||
#include "device/fido/public_key_credential_user_entity.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
|
||||
namespace device {
|
||||
namespace {
|
||||
@ -401,9 +401,9 @@ TEST_F(EnclaveProtocolUtilsTest, ParseGetAssertionResponse_Success) {
|
||||
auto parse_result =
|
||||
ParseGetAssertionResponse(std::move(response_cbor), cred_id);
|
||||
EXPECT_TRUE(
|
||||
absl::holds_alternative<AuthenticatorGetAssertionResponse>(parse_result));
|
||||
std::holds_alternative<AuthenticatorGetAssertionResponse>(parse_result));
|
||||
const auto& assertion_response =
|
||||
absl::get<AuthenticatorGetAssertionResponse>(parse_result);
|
||||
std::get<AuthenticatorGetAssertionResponse>(parse_result);
|
||||
EXPECT_EQ(assertion_response.user_entity->id,
|
||||
std::vector<uint8_t>({'a', 'b'}));
|
||||
EXPECT_EQ(assertion_response.credential->id, std::vector<uint8_t>({0, 1, 2}));
|
||||
@ -418,8 +418,8 @@ TEST_F(EnclaveProtocolUtilsTest, ParseGetAssertionResponse_Failures) {
|
||||
std::vector<uint8_t> cred_id = {0, 1, 2};
|
||||
auto parse_result =
|
||||
ParseGetAssertionResponse(std::move(response_cbor), cred_id);
|
||||
EXPECT_TRUE(absl::holds_alternative<ErrorResponse>(parse_result) &&
|
||||
absl::get<ErrorResponse>(parse_result).error_string.has_value())
|
||||
EXPECT_TRUE(std::holds_alternative<ErrorResponse>(parse_result) &&
|
||||
std::get<ErrorResponse>(parse_result).error_string.has_value())
|
||||
<< "Failed GetAssertion response parsing for: " << test_case.name;
|
||||
}
|
||||
}
|
||||
@ -439,12 +439,12 @@ TEST_F(EnclaveProtocolUtilsTest, ParseMakeCredentialResponse_Success) {
|
||||
std::move(response_cbor), ctap_request, kWrappedSecretVersion,
|
||||
UserPresentAndVerifiedBits::kPresentAndVerified);
|
||||
EXPECT_TRUE(
|
||||
(absl::holds_alternative<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(
|
||||
(std::holds_alternative<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(
|
||||
parse_result)));
|
||||
const auto& entity =
|
||||
absl::get<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(parse_result)
|
||||
std::get<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(parse_result)
|
||||
.second;
|
||||
EXPECT_EQ(entity.rp_id(), std::string(kRpId));
|
||||
EXPECT_EQ(entity.user_id(), std::string(user_id().begin(), user_id().end()));
|
||||
@ -453,8 +453,8 @@ TEST_F(EnclaveProtocolUtilsTest, ParseMakeCredentialResponse_Success) {
|
||||
encrypted_passkey().end()));
|
||||
|
||||
const auto& register_response =
|
||||
absl::get<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(parse_result)
|
||||
std::get<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(parse_result)
|
||||
.first;
|
||||
auto response_cred_id =
|
||||
register_response.attestation_object.authenticator_data()
|
||||
@ -489,12 +489,12 @@ TEST_F(EnclaveProtocolUtilsTest,
|
||||
std::move(response_cbor), ctap_request, kWrappedSecretVersion,
|
||||
UserPresentAndVerifiedBits::kNeither);
|
||||
EXPECT_TRUE(
|
||||
(absl::holds_alternative<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(
|
||||
(std::holds_alternative<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(
|
||||
parse_result)));
|
||||
const auto& register_response =
|
||||
absl::get<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(parse_result)
|
||||
std::get<std::pair<AuthenticatorMakeCredentialResponse,
|
||||
sync_pb::WebauthnCredentialSpecifics>>(parse_result)
|
||||
.first;
|
||||
EXPECT_FALSE(register_response.attestation_object.authenticator_data()
|
||||
.obtained_user_presence());
|
||||
@ -516,8 +516,8 @@ TEST_F(EnclaveProtocolUtilsTest, ParseMakeCredentialResponse_StringFailures) {
|
||||
auto parse_result = ParseMakeCredentialResponse(
|
||||
std::move(response_cbor), ctap_request, kWrappedSecretVersion,
|
||||
UserPresentAndVerifiedBits::kPresentOnly);
|
||||
EXPECT_TRUE(absl::holds_alternative<ErrorResponse>(parse_result) &&
|
||||
absl::get<ErrorResponse>(parse_result).error_string.has_value())
|
||||
EXPECT_TRUE(std::holds_alternative<ErrorResponse>(parse_result) &&
|
||||
std::get<ErrorResponse>(parse_result).error_string.has_value())
|
||||
<< "Failed MakeCredential response parsing for: " << test_case.name;
|
||||
}
|
||||
}
|
||||
@ -530,9 +530,9 @@ TEST_F(EnclaveProtocolUtilsTest, ParseGetAssertionResponse_IntegerFailure) {
|
||||
auto parse_result =
|
||||
ParseGetAssertionResponse(std::move(response_cbor), cred_id);
|
||||
|
||||
EXPECT_TRUE(absl::holds_alternative<ErrorResponse>(parse_result));
|
||||
EXPECT_TRUE(absl::get<ErrorResponse>(parse_result).error_code.has_value());
|
||||
EXPECT_EQ(*absl::get<ErrorResponse>(parse_result).error_code, 2);
|
||||
EXPECT_TRUE(std::holds_alternative<ErrorResponse>(parse_result));
|
||||
EXPECT_TRUE(std::get<ErrorResponse>(parse_result).error_code.has_value());
|
||||
EXPECT_EQ(*std::get<ErrorResponse>(parse_result).error_code, 2);
|
||||
}
|
||||
|
||||
TEST_F(EnclaveProtocolUtilsTest, ParseMakeCredentialResponse_IntegerFailure) {
|
||||
@ -549,9 +549,9 @@ TEST_F(EnclaveProtocolUtilsTest, ParseMakeCredentialResponse_IntegerFailure) {
|
||||
std::move(response_cbor), ctap_request, kWrappedSecretVersion,
|
||||
UserPresentAndVerifiedBits::kPresentOnly);
|
||||
|
||||
EXPECT_TRUE(absl::holds_alternative<ErrorResponse>(parse_result));
|
||||
EXPECT_TRUE(absl::get<ErrorResponse>(parse_result).error_code.has_value());
|
||||
EXPECT_EQ(*absl::get<ErrorResponse>(parse_result).error_code, 2);
|
||||
EXPECT_TRUE(std::holds_alternative<ErrorResponse>(parse_result));
|
||||
EXPECT_TRUE(std::get<ErrorResponse>(parse_result).error_code.has_value());
|
||||
EXPECT_EQ(*std::get<ErrorResponse>(parse_result).error_code, 2);
|
||||
}
|
||||
|
||||
} // namespace enclave
|
||||
|
@ -5,8 +5,10 @@
|
||||
#include "device/vr/android/cardboard/cardboard_device_params.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
#include "base/notreached.h"
|
||||
#include "third_party/cardboard/src/sdk/include/cardboard.h"
|
||||
@ -98,11 +100,11 @@ bool CardboardDeviceParams::IsValid() {
|
||||
}
|
||||
|
||||
const uint8_t* CardboardDeviceParams::encoded_device_params() {
|
||||
if (absl::holds_alternative<uint8_t*>(encoded_device_params_)) {
|
||||
return absl::get<uint8_t*>(encoded_device_params_);
|
||||
} else if (absl::holds_alternative<OwnedCardboardParams>(
|
||||
if (std::holds_alternative<uint8_t*>(encoded_device_params_)) {
|
||||
return std::get<uint8_t*>(encoded_device_params_);
|
||||
} else if (std::holds_alternative<OwnedCardboardParams>(
|
||||
encoded_device_params_)) {
|
||||
return absl::get<OwnedCardboardParams>(encoded_device_params_).get();
|
||||
return std::get<OwnedCardboardParams>(encoded_device_params_).get();
|
||||
}
|
||||
|
||||
NOTREACHED();
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "device/vr/android/cardboard/scoped_cardboard_objects.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
#include <variant>
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "device/vr/android/cardboard/scoped_cardboard_objects.h"
|
||||
|
||||
namespace device {
|
||||
|
||||
@ -53,8 +53,7 @@ class COMPONENT_EXPORT(VR_CARDBOARD) CardboardDeviceParams {
|
||||
// launched. Meant to be used for testing purposes only.
|
||||
static bool use_cardboard_v1_device_params_for_testing_;
|
||||
|
||||
absl::variant<uint8_t*, OwnedCardboardParams> encoded_device_params_ =
|
||||
nullptr;
|
||||
std::variant<uint8_t*, OwnedCardboardParams> encoded_device_params_ = nullptr;
|
||||
int size_ = 0;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user