#ifndef CONTENT_SERVICES_AUCTION_WORKLET_BIDDER_LAZY_FILLER_H_
#define CONTENT_SERVICES_AUCTION_WORKLET_BIDDER_LAZY_FILLER_H_
#include <string>
#include <string_view>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "content/services/auction_worklet/auction_v8_helper.h"
#include "content/services/auction_worklet/context_recycler.h"
#include "content/services/auction_worklet/public/mojom/bidder_worklet.mojom-forward.h"
#include "third_party/blink/public/common/interest_group/interest_group.h"
#include "third_party/blink/public/mojom/interest_group/interest_group_types.mojom-forward.h"
#include "v8/include/v8-forward.h"
class GURL;
namespace auction_worklet {
class AuctionV8Logger;
class CONTENT_EXPORT InterestGroupLazyFiller : public PersistedLazyFiller {
public:
InterestGroupLazyFiller(AuctionV8Helper* v8_helper,
AuctionV8Logger* v8_logger);
void ReInitialize(const GURL* bidding_logic_url,
const GURL* bidding_wasm_helper_url,
const GURL* trusted_bidding_signals_url,
const mojom::BidderWorkletNonSharedParams*
bidder_worklet_non_shared_params);
bool FillInObject(
v8::Local<v8::Object> object,
base::RepeatingCallback<bool(const std::string&)> is_ad_excluded,
base::RepeatingCallback<bool(const std::string&)>
is_ad_component_excluded,
base::RepeatingCallback<bool(
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)>
is_reporting_id_set_excluded);
void Reset() override;
private:
bool CreateAdVector(
v8::Local<v8::Object>& object,
std::string_view name,
base::RepeatingCallback<bool(const std::string&)> is_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,
std::optional<size_t> selectable_reporting_ids_limit,
const std::vector<blink::InterestGroup::Ad>& ads,
v8::Local<v8::ObjectTemplate>& lazy_filler_template);
static void HandleUserBiddingSignals(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleBiddingLogicUrl(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleDeprecatedBiddingLogicUrl(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleBiddingWasmHelperUrl(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleDeprecatedBiddingWasmHelperUrl(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleUpdateUrl(v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleDeprecatedUpdateUrl(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleDeprecatedDailyUpdateUrl(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleTrustedBiddingSignalsUrl(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleDeprecatedTrustedBiddingSignalsUrl(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleTrustedBiddingSignalsKeys(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandlePriorityVector(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleUseBiddingSignalsPrioritization(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandleDeprecatedAdsRenderUrl(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
raw_ptr<const GURL> bidding_logic_url_ = nullptr;
raw_ptr<const GURL> bidding_wasm_helper_url_ = nullptr;
raw_ptr<const GURL> trusted_bidding_signals_url_ = nullptr;
raw_ptr<const mojom::BidderWorkletNonSharedParams>
bidder_worklet_non_shared_params_ = nullptr;
const bool creative_scanning_enabled_;
const raw_ptr<AuctionV8Logger> v8_logger_;
};
enum class PrevWinsType { kSeconds, kMilliseconds };
class CONTENT_EXPORT BiddingBrowserSignalsLazyFiller
: public PersistedLazyFiller {
public:
explicit BiddingBrowserSignalsLazyFiller(AuctionV8Helper* v8_helper);
void ReInitialize(blink::mojom::BiddingBrowserSignals* bidder_browser_signals,
base::Time auction_start_time);
bool FillInObject(v8::Local<v8::Object> object);
void Reset() override;
private:
static void HandlePrevWins(v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandlePrevWinsMs(v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static void HandlePrevWinsInternal(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info,
PrevWinsType prev_wins_type);
raw_ptr<blink::mojom::BiddingBrowserSignals> bidder_browser_signals_ =
nullptr;
base::Time auction_start_time_;
};
}
#endif