#include "content/browser/webid/digital_credentials/digital_identity_request_impl.h"
#include <memory>
#include "base/functional/callback.h"
#include "base/functional/callback_forward.h"
#include "base/metrics/histogram_functions.h"
#include "base/types/optional_util.h"
#include "base/values.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/webid/flags.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/digital_identity_interstitial_type.h"
#include "content/public/browser/digital_identity_provider.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom.h"
#include "third_party/re2/src/re2/re2.h"
Value;
RequestDigitalIdentityStatus;
InterstitialType;
RequestStatusForMetrics;
DigitalIdentityInterstitialAbortCallback;
namespace content {
namespace {
constexpr char kOpenid4vpProtocol[] = …;
constexpr char kPreviewProtocol[] = …;
constexpr char kMdlDocumentType[] = …;
constexpr char kOpenid4vpPathRegex[] = …;
constexpr char kMdocAgeOverDataElementRegex[] = …;
constexpr char kMdocAgeInYearsDataElement[] = …;
constexpr char kMdocAgeBirthYearDataElement[] = …;
constexpr char kMdocBirthDateDataElement[] = …;
constexpr char kDigitalIdentityDialogParam[] = …;
constexpr char kDigitalIdentityNoDialogParamValue[] = …;
constexpr char kDigitalIdentityLowRiskDialogParamValue[] = …;
constexpr char kDigitalIdentityHighRiskDialogParamValue[] = …;
const base::Value::Dict* FindSingleElementListEntry(
const base::Value::Dict& dict,
const std::string& list_key) { … }
bool CanMdocDataElementBypassInterstitial(const std::string& data_element) { … }
bool CanRequestCredentialBypassInterstitialForOpenid4vpProtocol(
const base::Value& request) { … }
bool CanRequestCredentialBypassInterstitialForPreviewProtocol(
const base::Value& request) { … }
bool CanRequestCredentialBypassInterstitial(Protocol protocol,
const base::Value& request) { … }
Protocol GetProtocol(const std::optional<std::string>& protocol_name) { … }
}
void DigitalIdentityRequestImpl::Create(
RenderFrameHost& host,
mojo::PendingReceiver<blink::mojom::DigitalIdentityRequest> receiver) { … }
std::optional<InterstitialType>
DigitalIdentityRequestImpl::ComputeInterstitialType(
const url::Origin& rp_origin,
const DigitalIdentityProvider* provider,
Protocol protocol,
const data_decoder::DataDecoder::ValueOrError& request) { … }
DigitalIdentityRequestImpl::DigitalIdentityRequestImpl(
RenderFrameHost& host,
mojo::PendingReceiver<blink::mojom::DigitalIdentityRequest> receiver)
: … { … }
DigitalIdentityRequestImpl::~DigitalIdentityRequestImpl() = default;
void DigitalIdentityRequestImpl::CompleteRequest(
const base::expected<std::string, RequestStatusForMetrics>& response) { … }
void DigitalIdentityRequestImpl::CompleteRequestWithStatus(
RequestDigitalIdentityStatus status,
const base::expected<std::string, RequestStatusForMetrics>& response) { … }
std::optional<base::Value> BuildRequest(
blink::mojom::DigitalCredentialProviderPtr provider) { … }
void DigitalIdentityRequestImpl::Request(
blink::mojom::DigitalCredentialProviderPtr digital_credential_provider,
RequestCallback callback) { … }
void DigitalIdentityRequestImpl::Abort() { … }
void DigitalIdentityRequestImpl::OnRequestJsonParsed(
Protocol protocol,
base::Value request_to_send,
data_decoder::DataDecoder::ValueOrError parsed_result) { … }
void DigitalIdentityRequestImpl::OnInterstitialDone(
base::Value request_to_send,
RequestStatusForMetrics status_after_interstitial) { … }
}