Skip to content

Commit

Permalink
Add kDirectSeller fenced frame beacon reporting destination
Browse files Browse the repository at this point in the history
The "direct-seller" destination is an alias for whichever seller is dealing directly with the buyer. It corresponds to the "seller" in a single-layer auction and the "component-seller" in a multi-layer auction.
From the discussion in WICG/turtledove#441.

Change-Id: I334501296dccce0015c4f403f4ed5e337403f5ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4282418
Reviewed-by: Caleb Raitto <caraitto@chromium.org>
Commit-Queue: Russ Hamilton <behamilton@google.com>
Reviewed-by: Andrew Paseltiner <apaseltiner@chromium.org>
Reviewed-by: Brendon Tiszka <tiszka@google.com>
Reviewed-by: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108577}
  • Loading branch information
brusshamilton authored and Chromium LUCI CQ committed Feb 22, 2023
1 parent 4f75775 commit 17b33b6
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,8 @@ class AttributionsFencedFrameBrowserTest : public AttributionsBrowserTest {
->GetStoragePartition()
->GetURLLoaderFactoryForBrowserProcess(),
AttributionDataHostManager::FromBrowserContext(
web_contents()->GetBrowserContext()));
web_contents()->GetBrowserContext()),
/*direct_seller_is_seller=*/false);
}

private:
Expand Down
6 changes: 4 additions & 2 deletions content/browser/fenced_frame/fenced_frame_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4644,7 +4644,8 @@ class FencedFrameReportEventBrowserTest
->GetStoragePartition()
->GetURLLoaderFactoryForBrowserProcess(),
AttributionDataHostManager::FromBrowserContext(
web_contents()->GetBrowserContext()));
web_contents()->GetBrowserContext()),
/*direct_seller_is_seller=*/false);
}

// A helper function for specifying reportEvent tests. Each step consists of a
Expand Down Expand Up @@ -6070,7 +6071,8 @@ class FencedFrameAutomaticBeaconBrowserTest
->GetStoragePartition()
->GetURLLoaderFactoryForBrowserProcess(),
AttributionDataHostManager::FromBrowserContext(
web_contents()->GetBrowserContext()));
web_contents()->GetBrowserContext()),
/*direct_seller_is_seller=*/false);
}

void SendBasicRequest(GURL url) {
Expand Down
17 changes: 16 additions & 1 deletion content/browser/fenced_frame/fenced_frame_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/strings/strcat.h"
#include "base/types/pass_key.h"
#include "components/attribution_reporting/os_registration.h"
Expand Down Expand Up @@ -97,7 +98,10 @@ base::StringPiece ReportingDestinationAsString(
return "ComponentSeller";
case blink::FencedFrame::ReportingDestination::kSharedStorageSelectUrl:
return "SharedStorageSelectUrl";
case blink::FencedFrame::ReportingDestination::kDirectSeller:
return "DirectSeller";
}
NOTREACHED();
}

} // namespace
Expand Down Expand Up @@ -182,11 +186,13 @@ scoped_refptr<FencedFrameReporter> FencedFrameReporter::CreateForSharedStorage(

scoped_refptr<FencedFrameReporter> FencedFrameReporter::CreateForFledge(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
AttributionDataHostManager* attribution_data_host_manager) {
AttributionDataHostManager* attribution_data_host_manager,
bool direct_seller_is_seller) {
scoped_refptr<FencedFrameReporter> reporter =
base::MakeRefCounted<FencedFrameReporter>(
base::PassKey<FencedFrameReporter>(), std::move(url_loader_factory),
attribution_data_host_manager);
reporter->direct_seller_is_seller_ = direct_seller_is_seller;
reporter->reporting_metadata_.emplace(
blink::FencedFrame::ReportingDestination::kBuyer,
ReportingDestinationInfo());
Expand Down Expand Up @@ -225,6 +231,15 @@ bool FencedFrameReporter::SendReport(
absl::optional<int64_t> navigation_id) {
DCHECK(request_initiator_frame);

if (reporting_destination ==
blink::FencedFrame::ReportingDestination::kDirectSeller) {
if (direct_seller_is_seller_) {
reporting_destination = blink::FencedFrame::ReportingDestination::kSeller;
} else {
reporting_destination =
blink::FencedFrame::ReportingDestination::kComponentSeller;
}
}
auto it = reporting_metadata_.find(reporting_destination);
// Check metadata registration for given destination. If there's no map, or
// the map is empty, can't send a request. An entry with a null (not empty)
Expand Down
9 changes: 7 additions & 2 deletions content/browser/fenced_frame/fenced_frame_reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ class CONTENT_EXPORT FencedFrameReporter
// for the beacons.
static scoped_refptr<FencedFrameReporter> CreateForFledge(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
AttributionDataHostManager* attribution_data_host_manager);
AttributionDataHostManager* attribution_data_host_manager,
bool direct_seller_is_seller);

// Called when a mapping for reports of type `reporting_destination` is ready.
// The reporter must currently be considering maps of type
// `reporting_destination` pending - that is:
//
// 1) It must have been created by CreateForFledge()
// 2) `reporting_destination` must be one of kBuyer, kSeller, or
// 2) `reporting_destination` must be one of kBuyer, kSeller, kDirectSeller or
// kComponentSeller.
// 3) OnUrlMappingReady() must not yet have been invoked with
// `reporting_destination` yet.
Expand Down Expand Up @@ -223,6 +224,10 @@ class CONTENT_EXPORT FencedFrameReporter
ReportingDestinationInfo>
reporting_metadata_;

// True if the "directSeller" alias maps to the Seller destination. False if
// it maps to the "ComponentSeller" destination.
bool direct_seller_is_seller_ = false;

// Stores data registered by one of the documents in a FencedFrame using
// the `Fence.setReportEventDataForAutomaticBeacons` API.
//
Expand Down
49 changes: 38 additions & 11 deletions content/browser/fenced_frame/fenced_frame_reporter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ TEST_F(FencedFrameReporterTest, NoReportNoMap) {
shared_url_loader_factory(), attribution_data_host_manager(),
/*reporting_url_map=*/{{"event_type", report_destination_}});
std::string error_message;
// FencedFrameReporters for Shared Storage a non-existent maps for FLEDGE
// destinations.
// A Shared Storage FencedFrameReporter has no map for FLEDGE destinations.
EXPECT_FALSE(
reporter->SendReport("event_type", "event_data",
blink::FencedFrame::ReportingDestination::kBuyer,
Expand All @@ -113,6 +112,13 @@ TEST_F(FencedFrameReporterTest, NoReportNoMap) {
EXPECT_EQ(error_message,
"This frame did not register reporting metadata for destination "
"'Seller'.");
EXPECT_FALSE(reporter->SendReport(
"event_type", "event_data",
blink::FencedFrame::ReportingDestination::kDirectSeller, main_rfh_impl(),
error_message));
EXPECT_EQ(error_message,
"This frame did not register reporting metadata for destination "
"'ComponentSeller'.");
EXPECT_FALSE(reporter->SendReport(
"event_type", "event_data",
blink::FencedFrame::ReportingDestination::kComponentSeller,
Expand All @@ -123,7 +129,8 @@ TEST_F(FencedFrameReporterTest, NoReportNoMap) {

// A FLEDGE FencedFrameReporter has no map for Shared Storage.
reporter = FencedFrameReporter::CreateForFledge(
shared_url_loader_factory(), attribution_data_host_manager());
shared_url_loader_factory(), attribution_data_host_manager(),
/*direct_seller_is_seller=*/false);
EXPECT_FALSE(reporter->SendReport(
"event_type", "event_data",
blink::FencedFrame::ReportingDestination::kSharedStorageSelectUrl,
Expand Down Expand Up @@ -247,7 +254,8 @@ TEST_F(FencedFrameReporterTest, SendReports) {
TEST_F(FencedFrameReporterTest, SendFledgeReportsAfterMapsReceived) {
scoped_refptr<FencedFrameReporter> reporter =
FencedFrameReporter::CreateForFledge(shared_url_loader_factory(),
attribution_data_host_manager());
attribution_data_host_manager(),
/*direct_seller_is_seller=*/false);

// Receive all mappings.
reporter->OnUrlMappingReady(
Expand Down Expand Up @@ -287,14 +295,23 @@ TEST_F(FencedFrameReporterTest, SendFledgeReportsAfterMapsReceived) {
EXPECT_EQ(test_url_loader_factory_.NumPending(), 3);
ValidateRequest((*test_url_loader_factory_.pending_requests())[2].request,
report_destination3_, "event_data");

EXPECT_TRUE(reporter->SendReport(
"event_type", "event_data",
blink::FencedFrame::ReportingDestination::kDirectSeller, main_rfh_impl(),
error_message));
EXPECT_EQ(test_url_loader_factory_.NumPending(), 4);
ValidateRequest((*test_url_loader_factory_.pending_requests())[3].request,
report_destination2_, "event_data");
}

// Test reports in the FLEDGE case, where reporting URL maps are received after
// SendReport() calls.
TEST_F(FencedFrameReporterTest, SendReportsFledgeBeforeMapsReceived) {
scoped_refptr<FencedFrameReporter> reporter =
FencedFrameReporter::CreateForFledge(shared_url_loader_factory(),
attribution_data_host_manager());
attribution_data_host_manager(),
/*direct_seller_is_seller=*/true);

// Make reports. They should be queued, since mappings haven't been received
// yet.
Expand All @@ -311,29 +328,38 @@ TEST_F(FencedFrameReporterTest, SendReportsFledgeBeforeMapsReceived) {
reporter->SendReport("event_type", "event_data",
blink::FencedFrame::ReportingDestination::kBuyer,
main_rfh_impl(), error_message));
EXPECT_TRUE(reporter->SendReport(
"event_type", "event_data",
blink::FencedFrame::ReportingDestination::kDirectSeller, main_rfh_impl(),
error_message));

EXPECT_EQ(test_url_loader_factory_.NumPending(), 0);

// Each report should be sent as its mapping is received.

reporter->OnUrlMappingReady(
blink::FencedFrame::ReportingDestination::kSeller,
/*reporting_url_map=*/{{"event_type", report_destination_}});
EXPECT_EQ(test_url_loader_factory_.NumPending(), 1);
EXPECT_EQ(test_url_loader_factory_.NumPending(), 2);
ValidateRequest((*test_url_loader_factory_.pending_requests())[0].request,
report_destination_, "event_data");
// This one is from the "DirectSeller" destination, which was aliased to
// kSeller.
ValidateRequest((*test_url_loader_factory_.pending_requests())[1].request,
report_destination_, "event_data");

reporter->OnUrlMappingReady(
blink::FencedFrame::ReportingDestination::kComponentSeller,
/*reporting_url_map=*/{{"event_type", report_destination2_}});
EXPECT_EQ(test_url_loader_factory_.NumPending(), 2);
ValidateRequest((*test_url_loader_factory_.pending_requests())[1].request,
EXPECT_EQ(test_url_loader_factory_.NumPending(), 3);
ValidateRequest((*test_url_loader_factory_.pending_requests())[2].request,
report_destination2_, "event_data");

reporter->OnUrlMappingReady(
blink::FencedFrame::ReportingDestination::kBuyer,
/*reporting_url_map=*/{{"event_type", report_destination3_}});
EXPECT_EQ(test_url_loader_factory_.NumPending(), 3);
ValidateRequest((*test_url_loader_factory_.pending_requests())[2].request,
EXPECT_EQ(test_url_loader_factory_.NumPending(), 4);
ValidateRequest((*test_url_loader_factory_.pending_requests())[3].request,
report_destination3_, "event_data");
}

Expand All @@ -344,7 +370,8 @@ TEST_F(FencedFrameReporterTest, SendReportsFledgeBeforeMapsReceived) {
TEST_F(FencedFrameReporterTest, SendFledgeReportsBeforeMapsReceivedWithErrors) {
scoped_refptr<FencedFrameReporter> reporter =
FencedFrameReporter::CreateForFledge(shared_url_loader_factory(),
attribution_data_host_manager());
attribution_data_host_manager(),
/*direct_seller_is_seller=*/false);

// SendReport() is called, and then a mapping is received that doesn't have
// the report's event type. No request should be made.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ GURL GenerateAndVerifyPendingMappedURN(
scoped_refptr<FencedFrameReporter> CreateReporter() {
return FencedFrameReporter::CreateForFledge(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(nullptr),
/*attribution_data_host_manager=*/nullptr);
/*attribution_data_host_manager=*/nullptr,
/*direct_seller_is_seller=*/false);
}

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ TEST(FencedFrameConfigMojomTraitsTest, PropertiesHasFencedFrameReportingTest) {
// Create a reporting service with a dummy SharedURLLoaderFactory.
properties.fenced_frame_reporter_ = FencedFrameReporter::CreateForFledge(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(nullptr),
/*attribution_data_host_manager=*/nullptr);
/*attribution_data_host_manager=*/nullptr,
/*direct_seller_is_seller=*/false);
input_properties = properties.RedactFor(FencedFrameEntity::kEmbedder);
EXPECT_TRUE(input_properties.has_fenced_frame_reporting());
mojo::test::SerializeAndDeserialize<blink::mojom::FencedFrameProperties>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ InterestGroupAuctionReporter::InterestGroupAuctionReporter(
std::move(private_aggregation_requests_reserved)),
private_aggregation_requests_non_reserved_(
std::move(private_aggregation_requests_non_reserved)),
fenced_frame_reporter_(
FencedFrameReporter::CreateForFledge(url_loader_factory_,
attribution_data_host_manager)) {
fenced_frame_reporter_(FencedFrameReporter::CreateForFledge(
url_loader_factory_,
attribution_data_host_manager,
/*direct_seller_is_seller=*/
!component_seller_winning_bid_info.has_value())) {
DCHECK(interest_group_manager_);
DCHECK(auction_worklet_manager_);
DCHECK(url_loader_factory_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ EnumTraits<blink::mojom::ReportingDestination,
return blink::mojom::ReportingDestination::kComponentSeller;
case blink::FencedFrame::ReportingDestination::kSharedStorageSelectUrl:
return blink::mojom::ReportingDestination::kSharedStorageSelectUrl;
case blink::FencedFrame::ReportingDestination::kDirectSeller:
return blink::mojom::ReportingDestination::kDirectSeller;
}
NOTREACHED();
return blink::mojom::ReportingDestination::kBuyer;
Expand Down Expand Up @@ -104,6 +106,9 @@ bool EnumTraits<blink::mojom::ReportingDestination,
case blink::mojom::ReportingDestination::kSharedStorageSelectUrl:
*out = blink::FencedFrame::ReportingDestination::kSharedStorageSelectUrl;
return true;
case blink::mojom::ReportingDestination::kDirectSeller:
*out = blink::FencedFrame::ReportingDestination::kDirectSeller;
return true;
}
NOTREACHED();
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum ReportingDestination {
kSeller,
kComponentSeller,
kSharedStorageSelectUrl,
kDirectSeller,
};

// TODO(crbug.com/1347953): Decompose this into flags that directly control the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum ReportingDestination {
kSeller,
kComponentSeller,
kSharedStorageSelectUrl,
kDirectSeller,
};

// The fenced frame config's "mode" describes a set of functionalities that it
Expand Down
2 changes: 2 additions & 0 deletions third_party/blink/renderer/core/html/fenced_frame/fence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ blink::FencedFrame::ReportingDestination ToPublicDestination(
return blink::FencedFrame::ReportingDestination::kSeller;
case V8FenceReportingDestination::Enum::kComponentSeller:
return blink::FencedFrame::ReportingDestination::kComponentSeller;
case V8FenceReportingDestination::Enum::kDirectSeller:
return blink::FencedFrame::ReportingDestination::kDirectSeller;
case V8FenceReportingDestination::Enum::kSharedStorageSelectUrl:
return blink::FencedFrame::ReportingDestination::kSharedStorageSelectUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ enum FenceReportingDestination {
"buyer",
"seller",
"component-seller",
"direct-seller",
"shared-storage-select-url"
};

dictionary FenceEvent {
required DOMString eventType;
required DOMString eventData;
required sequence<FenceReportingDestination> destination;
};
};

0 comments on commit 17b33b6

Please sign in to comment.