#include "services/network/trust_tokens/trust_token_request_redemption_helper.h"
#include <algorithm>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/metrics/histogram_functions.h"
#include "net/base/load_flags.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "services/network/public/cpp/trust_token_http_headers.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/trust_tokens/proto/public.pb.h"
#include "services/network/trust_tokens/trust_token_database_owner.h"
#include "services/network/trust_tokens/trust_token_key_commitment_parser.h"
#include "services/network/trust_tokens/trust_token_parameterization.h"
#include "services/network/trust_tokens/trust_token_store.h"
#include "url/url_constants.h"
namespace network {
namespace {
base::Value::Dict CreateLogValue(std::string_view outcome) { … }
enum NetLogOp { … };
void LogOutcome(const net::NetLogWithSource& log,
NetLogOp begin_or_finalize,
std::string_view outcome) { … }
}
TrustTokenRequestRedemptionHelper::TrustTokenRequestRedemptionHelper(
SuitableTrustTokenOrigin top_level_origin,
mojom::TrustTokenRefreshPolicy refresh_policy,
TrustTokenStore* token_store,
const TrustTokenKeyCommitmentGetter* key_commitment_getter,
std::optional<std::string> custom_key_commitment,
std::optional<url::Origin> custom_issuer,
std::unique_ptr<Cryptographer> cryptographer,
net::NetLogWithSource net_log)
: … { … }
TrustTokenRequestRedemptionHelper::~TrustTokenRequestRedemptionHelper() =
default;
void TrustTokenRequestRedemptionHelper::Begin(
const GURL& url,
base::OnceCallback<void(std::optional<net::HttpRequestHeaders>,
mojom::TrustTokenOperationStatus)> done) { … }
void TrustTokenRequestRedemptionHelper::OnGotKeyCommitment(
base::OnceCallback<void(std::optional<net::HttpRequestHeaders>,
mojom::TrustTokenOperationStatus)> done,
mojom::TrustTokenKeyCommitmentResultPtr commitment_result) { … }
void TrustTokenRequestRedemptionHelper::Finalize(
net::HttpResponseHeaders& response_headers,
base::OnceCallback<void(mojom::TrustTokenOperationStatus)> done) { … }
std::optional<TrustToken>
TrustTokenRequestRedemptionHelper::RetrieveSingleToken() { … }
mojom::TrustTokenOperationResultPtr
TrustTokenRequestRedemptionHelper::CollectOperationResultWithStatus(
mojom::TrustTokenOperationStatus status) { … }
}