#include "third_party/blink/public/common/interest_group/interest_group.h"
#include <stdint.h>
#include <cmath>
#include <cstring>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/numerics/byte_conversions.h"
#include "base/strings/strcat.h"
#include "base/time/time.h"
#include "base/types/optional_ref.h"
#include "crypto/sha2.h"
#include "third_party/blink/public/common/common_export.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/interest_group/ad_display_size_utils.h"
#include "third_party/blink/public/mojom/interest_group/interest_group_types.mojom.h"
#include "third_party/boringssl/src/include/openssl/curve25519.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "url/url_constants.h"
namespace blink {
namespace {
constexpr char kKAnonKeyForAdNameReportingSelectedBuyerAndSellerIdPrefix[] = …;
constexpr char kKAnonKeyForAdNameReportingBuyerAndSellerIdPrefix[] = …;
constexpr char kKAnonKeyForAdNameReportingBuyerReportIdPrefix[] = …;
constexpr char kKAnonKeyForAdNameReportingNamePrefix[] = …;
const size_t kMaxAdRenderIdSize = …;
bool IsUrlAllowedForRenderUrls(const GURL& url) { … }
bool IsUrlAllowed(const GURL& url, const InterestGroup& group) { … }
bool IsUrlAllowedForTrustedBiddingSignals(const GURL& url,
const InterestGroup& group) { … }
size_t EstimateFlatMapSize(
const base::flat_map<std::string, double>& flat_map) { … }
void AppendReportingIdForSelectedReportingKeyKAnonKey(
base::optional_ref<const std::string> reporting_id,
std::string& k_anon_key) { … }
std::string InternalPlainTextKAnonKeyForAdNameReporting(
const url::Origin& interest_group_owner,
const std::string& interest_group_name,
const GURL& interest_group_bidding_url,
const std::string& ad_render_url,
base::optional_ref<const std::string> buyer_reporting_id,
base::optional_ref<const std::string> buyer_and_seller_reporting_id,
base::optional_ref<const std::string>
selected_buyer_and_seller_reporting_id) { … }
}
InterestGroup::Ad::Ad() = default;
InterestGroup::Ad::Ad(base::PassKey<content::InterestGroupStorage>,
std::string&& render_url)
: … { … }
InterestGroup::Ad::Ad(base::PassKey<content::InterestGroupStorage>,
const std::string& render_url)
: … { … }
InterestGroup::Ad::Ad(
GURL render_gurl,
std::optional<std::string> metadata,
std::optional<std::string> size_group,
std::optional<std::string> buyer_reporting_id,
std::optional<std::string> buyer_and_seller_reporting_id,
std::optional<std::vector<std::string>>
selectable_buyer_and_seller_reporting_ids,
std::optional<std::string> ad_render_id,
std::optional<std::vector<url::Origin>> allowed_reporting_origins)
: … { … }
InterestGroup::Ad::~Ad() = default;
size_t InterestGroup::Ad::EstimateSize() const { … }
bool InterestGroup::Ad::operator==(const Ad& other) const { … }
InterestGroup::InterestGroup() = default;
InterestGroup::~InterestGroup() = default;
InterestGroup::InterestGroup(InterestGroup&& other) = default;
InterestGroup& InterestGroup::operator=(InterestGroup&& other) = default;
InterestGroup::InterestGroup(const InterestGroup& other) = default;
InterestGroup& InterestGroup::operator=(const InterestGroup& other) = default;
bool InterestGroup::IsValid() const { … }
size_t InterestGroup::EstimateSize() const { … }
std::string_view InterestGroup::TrustedBiddingSignalsSlotSizeModeToString(
TrustedBiddingSignalsSlotSizeMode slot_size_mode) { … }
std::string DEPRECATED_KAnonKeyForAdBid(
const url::Origin& owner,
const GURL& bidding_url,
const std::string& ad_url_from_gurl_spec) { … }
std::string DEPRECATED_KAnonKeyForAdBid(
const InterestGroup& group,
const std::string& ad_url_from_gurl_spec) { … }
std::string HashedKAnonKeyForAdBid(const url::Origin& owner,
const GURL& bidding_url,
const std::string& ad_url_from_gurl_spec) { … }
std::string HashedKAnonKeyForAdBid(const InterestGroup& group,
const std::string& ad_url_from_gurl_spec) { … }
std::string HashedKAnonKeyForAdBid(const InterestGroup& group,
const blink::AdDescriptor& ad_descriptor) { … }
std::string DEPRECATED_KAnonKeyForAdComponentBid(
const std::string& ad_url_from_gurl_spec) { … }
std::string HashedKAnonKeyForAdComponentBid(
const std::string& ad_url_from_gurl_spec) { … }
std::string HashedKAnonKeyForAdComponentBid(const GURL& ad_url) { … }
std::string HashedKAnonKeyForAdComponentBid(
const blink::AdDescriptor& ad_descriptor) { … }
std::string DEPRECATED_KAnonKeyForAdNameReporting(
const blink::InterestGroup& group,
const blink::InterestGroup::Ad& ad,
base::optional_ref<const std::string>
selected_buyer_and_seller_reporting_id) { … }
std::string HashedKAnonKeyForAdNameReporting(
const blink::InterestGroup& group,
const blink::InterestGroup::Ad& ad,
base::optional_ref<const std::string>
selected_buyer_and_seller_reporting_id) { … }
std::string HashedKAnonKeyForAdNameReportingWithoutInterestGroup(
const url::Origin& interest_group_owner,
const std::string& interest_group_name,
const GURL& interest_group_bidding_url,
const std::string& ad_render_url,
base::optional_ref<const std::string> buyer_reporting_id,
base::optional_ref<const std::string> buyer_and_seller_reporting_id,
base::optional_ref<const std::string>
selected_buyer_and_seller_reporting_id) { … }
}