#include "content/services/auction_worklet/set_bid_bindings.h"
#include <cmath>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "content/services/auction_worklet/auction_v8_helper.h"
#include "content/services/auction_worklet/bidder_worklet.h"
#include "content/services/auction_worklet/public/mojom/bidder_worklet.mojom.h"
#include "content/services/auction_worklet/public/mojom/private_aggregation_request.mojom.h"
#include "content/services/auction_worklet/webidl_compat.h"
#include "gin/converter.h"
#include "gin/dictionary.h"
#include "third_party/blink/public/common/features_generated.h"
#include "third_party/blink/public/common/interest_group/ad_auction_constants.h"
#include "third_party/blink/public/common/interest_group/ad_auction_currencies.h"
#include "third_party/blink/public/common/interest_group/ad_display_size_utils.h"
#include "url/gurl.h"
#include "url/url_constants.h"
#include "v8/include/v8-exception.h"
#include "v8/include/v8-external.h"
#include "v8/include/v8-function-callback.h"
#include "v8/include/v8-function.h"
namespace auction_worklet {
namespace {
base::optional_ref<const blink::InterestGroup::Ad> FindAdForAssociatedAdUrl(
const GURL& url,
const std::string& error_prefix,
const char* argument_name,
const base::RepeatingCallback<bool(const std::string&)>& is_excluded,
const std::vector<blink::InterestGroup::Ad>& ads,
std::string& out_error) { … }
struct AdRender { … };
IdlConvert::Status ConvertDomStringOrAdRender(
AuctionV8Helper* v8_helper,
AuctionV8Helper::TimeLimitScope& time_limit_scope,
const std::string& error_prefix,
v8::Local<v8::Value> value,
AdRender& out) { … }
bool TryToParseUrlWithSize(AuctionV8Helper* v8_helper,
AuctionV8Helper::TimeLimitScope& time_limit_scope,
const std::string& error_prefix,
const AdRender& value,
std::string& ad_url_out,
std::optional<blink::AdSize>& size_out,
std::string& error_out) { … }
std::string RenderPrefix(const std::string& error_prefix) { … }
std::string ComponentsPrefix(const std::string& error_prefix) { … }
}
SetBidBindings::BidAndWorkletOnlyMetadata::BidAndWorkletOnlyMetadata() =
default;
SetBidBindings::BidAndWorkletOnlyMetadata::BidAndWorkletOnlyMetadata(
BidAndWorkletOnlyMetadata&&) = default;
SetBidBindings::BidAndWorkletOnlyMetadata::~BidAndWorkletOnlyMetadata() =
default;
SetBidBindings::BidAndWorkletOnlyMetadata&
SetBidBindings::BidAndWorkletOnlyMetadata::operator=(
BidAndWorkletOnlyMetadata&&) = default;
std::vector<SetBidBindings::BidAndWorkletOnlyMetadata>
SetBidBindings::TakeBids() { … }
struct SetBidBindings::GenerateBidOutput { … };
SetBidBindings::SetBidBindings(AuctionV8Helper* v8_helper)
: … { … }
SetBidBindings::~SetBidBindings() = default;
void SetBidBindings::ReInitialize(
base::TimeTicks start,
bool has_top_level_seller_origin,
const mojom::BidderWorkletNonSharedParams* bidder_worklet_non_shared_params,
const std::optional<blink::AdCurrency>& per_buyer_currency,
uint16_t multi_bid_limit,
base::RepeatingCallback<bool(const std::string&)> is_ad_excluded,
base::RepeatingCallback<bool(const std::string&)> is_component_ad_excluded,
base::RepeatingCallback<bool(const std::string&,
base::optional_ref<const std::string>,
base::optional_ref<const std::string>,
base::optional_ref<const std::string>)>
is_reporting_id_set_excluded) { … }
void SetBidBindings::AttachToContext(v8::Local<v8::Context> context) { … }
void SetBidBindings::Reset() { … }
IdlConvert::Status SetBidBindings::SetBidImpl(v8::Local<v8::Value> value,
std::string error_prefix) { … }
base::expected<SetBidBindings::GenerateBidOutput, IdlConvert::Status>
SetBidBindings::ConvertBidToIDL(
AuctionV8Helper::TimeLimitScope& time_limit_scope,
v8::Local<v8::Value> input,
const std::string& error_prefix,
const std::string& render_prefix,
const std::string& components_prefix) { … }
base::expected<SetBidBindings::BidAndWorkletOnlyMetadata, IdlConvert::Status>
SetBidBindings::SemanticCheckBid(
AuctionV8Helper::TimeLimitScope& time_limit_scope,
const GenerateBidOutput& idl,
const std::string& error_prefix,
const std::string& render_prefix,
const std::string& components_prefix) { … }
bool SetBidBindings::IsSelectedReportingIdValid(
const blink::InterestGroup::Ad& ad,
const std::string& selected_buyer_and_seller_reporting_id) { … }
void SetBidBindings::SetBid(const v8::FunctionCallbackInfo<v8::Value>& args) { … }
}