#include "services/network/trust_tokens/trust_token_request_issuance_helper.h"
#include <utility>
#include "base/command_line.h"
#include "base/functional/callback.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "base/task/thread_pool.h"
#include "net/base/load_flags.h"
#include "net/http/http_response_headers.h"
#include "net/log/net_log_event_type.h"
#include "net/url_request/url_request.h"
#include "services/network/public/cpp/features.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/trust_tokens.mojom.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/suitable_trust_token_origin.h"
#include "services/network/trust_tokens/trust_token_key_commitment_parser.h"
#include "services/network/trust_tokens/trust_token_key_filtering.h"
#include "services/network/trust_tokens/trust_token_parameterization.h"
#include "services/network/trust_tokens/trust_token_store.h"
#include "services/network/trust_tokens/types.h"
#include "url/url_constants.h"
namespace network {
Cryptographer;
struct TrustTokenRequestIssuanceHelper::CryptographerAndBlindedTokens { … };
struct TrustTokenRequestIssuanceHelper::CryptographerAndUnblindedTokens { … };
namespace {
TrustTokenRequestIssuanceHelper::CryptographerAndBlindedTokens
BeginIssuanceOnPostedSequence(std::unique_ptr<Cryptographer> cryptographer,
int batch_size) { … }
TrustTokenRequestIssuanceHelper::CryptographerAndUnblindedTokens
ConfirmIssuanceOnPostedSequence(std::unique_ptr<Cryptographer> cryptographer,
std::string response_header) { … }
base::Value::Dict CreateLogValue(std::string_view outcome) { … }
enum NetLogOp { … };
void LogOutcome(const net::NetLogWithSource& log,
NetLogOp begin_or_finalize,
std::string_view outcome) { … }
}
TrustTokenRequestIssuanceHelper::TrustTokenRequestIssuanceHelper(
SuitableTrustTokenOrigin top_level_origin,
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)
: … { … }
TrustTokenRequestIssuanceHelper::~TrustTokenRequestIssuanceHelper() = default;
TrustTokenRequestIssuanceHelper::Cryptographer::UnblindedTokens::
UnblindedTokens() = default;
TrustTokenRequestIssuanceHelper::Cryptographer::UnblindedTokens::
~UnblindedTokens() = default;
void TrustTokenRequestIssuanceHelper::Begin(
const GURL& url,
base::OnceCallback<void(std::optional<net::HttpRequestHeaders>,
mojom::TrustTokenOperationStatus)> done) { … }
void TrustTokenRequestIssuanceHelper::OnGotKeyCommitment(
const GURL& url,
base::OnceCallback<void(std::optional<net::HttpRequestHeaders>,
mojom::TrustTokenOperationStatus)> done,
mojom::TrustTokenKeyCommitmentResultPtr commitment_result) { … }
void TrustTokenRequestIssuanceHelper::OnDelegateBeginIssuanceCallComplete(
const GURL& url,
base::OnceCallback<void(std::optional<net::HttpRequestHeaders>,
mojom::TrustTokenOperationStatus)> done,
CryptographerAndBlindedTokens cryptographer_and_blinded_tokens) { … }
void TrustTokenRequestIssuanceHelper::Finalize(
net::HttpResponseHeaders& response_headers,
base::OnceCallback<void(mojom::TrustTokenOperationStatus)> done) { … }
void TrustTokenRequestIssuanceHelper::ProcessIssuanceResponse(
std::string issuance_response,
base::OnceCallback<void(mojom::TrustTokenOperationStatus)> done) { … }
void TrustTokenRequestIssuanceHelper::OnDoneProcessingIssuanceResponse(
base::OnceCallback<void(mojom::TrustTokenOperationStatus)> done,
CryptographerAndUnblindedTokens cryptographer_and_unblinded_tokens) { … }
mojom::TrustTokenOperationResultPtr
TrustTokenRequestIssuanceHelper::CollectOperationResultWithStatus(
mojom::TrustTokenOperationStatus status) { … }
}