chromium/chrome/browser/k_anonymity_service/k_anonymity_trust_token_getter.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 =;

// Pull a number that may be an unsigned 32 bit integer from Dict and return it
// as an int. If the number is less than int32_t max then the JSON parser will
// store it as an int, otherwise it will be stored as a double. Check that the
// double would fit in a 32 bit integer exactly before returning.
std::optional<uint32_t> FindUnsignedInt(base::Value::Dict& dict,
                                        std::string_view field) {}

}  // namespace

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) {}

// This function is where we start for each queued request.
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) {}

// The server sends the key commitment in a custom message format. We have to
// reformat the response from the server into a format the browser understands
// (V3 trust token key commitment). See the explainer here:
// https://github.com/WICG/trust-token-api/blob/main/ISSUER_PROTOCOL.md
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) {}