#include "chrome/browser/k_anonymity_service/k_anonymity_trust_token_getter.h"
#include <string_view>
#include "base/json/json_writer.h"
#include "base/json/values_util.h"
#include "base/numerics/checked_math.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/k_anonymity_service/k_anonymity_service_metrics.h"
#include "chrome/browser/k_anonymity_service/k_anonymity_service_urls.h"
#include "chrome/common/chrome_features.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/google_api_keys.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "net/base/load_flags.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
namespace {
constexpr base::TimeDelta kRequestMargin = …;
constexpr base::TimeDelta kRequestTimeout = …;
constexpr net::NetworkTrafficAnnotationTag
kKAnonymityServiceGetTokenTrafficAnnotation = …;
std::optional<uint32_t> FindUnsignedInt(base::Value::Dict& dict,
std::string_view field) { … }
}
KAnonymityTrustTokenGetter::PendingRequest::PendingRequest(
KAnonymityTrustTokenGetter::TryGetTrustTokenAndKeyCallback callback)
: … { … }
KAnonymityTrustTokenGetter::PendingRequest::~PendingRequest() = default;
KAnonymityTrustTokenGetter::PendingRequest::PendingRequest(
KAnonymityTrustTokenGetter::PendingRequest&&) noexcept = default;
KAnonymityTrustTokenGetter::PendingRequest&
KAnonymityTrustTokenGetter::PendingRequest::operator=(
KAnonymityTrustTokenGetter::PendingRequest&&) noexcept = default;
KAnonymityTrustTokenGetter::KAnonymityTrustTokenGetter(
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
network::mojom::TrustTokenQueryAnswerer* answerer,
KAnonymityServiceStorage* storage)
: … { … }
KAnonymityTrustTokenGetter::~KAnonymityTrustTokenGetter() = default;
void KAnonymityTrustTokenGetter::TryGetTrustTokenAndKey(
TryGetTrustTokenAndKeyCallback callback) { … }
void KAnonymityTrustTokenGetter::TryGetTrustTokenAndKeyInternal() { … }
void KAnonymityTrustTokenGetter::CheckAccessToken() { … }
void KAnonymityTrustTokenGetter::RequestAccessToken() { … }
void KAnonymityTrustTokenGetter::OnAccessTokenRequestCompleted(
GoogleServiceAuthError error,
signin::AccessTokenInfo access_token_info) { … }
void KAnonymityTrustTokenGetter::CheckTrustTokenKeyCommitment() { … }
void KAnonymityTrustTokenGetter::FetchNonUniqueUserId() { … }
void KAnonymityTrustTokenGetter::OnFetchedNonUniqueUserId(
std::unique_ptr<std::string> response) { … }
void KAnonymityTrustTokenGetter::OnParsedNonUniqueUserId(
data_decoder::DataDecoder::ValueOrError result) { … }
void KAnonymityTrustTokenGetter::FetchTrustTokenKeyCommitment(
int non_unique_user_id) { … }
void KAnonymityTrustTokenGetter::OnFetchedTrustTokenKeyCommitment(
int non_unique_user_id,
std::unique_ptr<std::string> response) { … }
void KAnonymityTrustTokenGetter::OnParsedTrustTokenKeyCommitment(
int non_unique_user_id,
data_decoder::DataDecoder::ValueOrError result) { … }
void KAnonymityTrustTokenGetter::CheckTrustTokens() { … }
void KAnonymityTrustTokenGetter::OnHasTrustTokensComplete(
network::mojom::HasTrustTokensResultPtr result) { … }
void KAnonymityTrustTokenGetter::FetchTrustToken() { … }
void KAnonymityTrustTokenGetter::OnFetchedTrustToken(
scoped_refptr<net::HttpResponseHeaders> headers) { … }
void KAnonymityTrustTokenGetter::FailAllCallbacks() { … }
void KAnonymityTrustTokenGetter::CompleteOneRequest() { … }
void KAnonymityTrustTokenGetter::DoCallback(bool status) { … }