Skip to content

Commit

Permalink
Fenced frames: Add reporting to custom destination URLs [3.5/N]
Browse files Browse the repository at this point in the history
Gate this new surface of the reportEvent API behind a feature flag.

WICG/turtledove#477

Change-Id: I24686173a489ef1c6775c537a26c95c3b185d52a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4752873
Commit-Queue: Garrett Tanzer <[email protected]>
Reviewed-by: Shivani Sharma <[email protected]>
Reviewed-by: Arthur Sonzogni <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1180965}
  • Loading branch information
Garrett Tanzer authored and Chromium LUCI CQ committed Aug 8, 2023
1 parent 37053b4 commit 0c20fbc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
29 changes: 29 additions & 0 deletions content/browser/renderer_host/render_frame_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8501,6 +8501,13 @@ void RenderFrameHostImpl::SendFencedFrameReportingBeacon(
const std::vector<blink::FencedFrame::ReportingDestination>& destinations,
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features) {
if (!blink::features::IsFencedFramesEnabled()) {
mojo::ReportBadMessage(
"SendFencedFrameReportingBeacon() received while FencedFrames not "
"enabled.");
return;
}

if (event_data.length() > blink::kFencedFrameMaxBeaconLength) {
mojo::ReportBadMessage(
"The data provided to SendFencedFrameReportingBeacon() exceeds the "
Expand All @@ -8523,6 +8530,21 @@ void RenderFrameHostImpl::SendFencedFrameReportingBeaconToCustomURL(
const GURL& destination_url,
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features) {
if (!blink::features::IsFencedFramesEnabled()) {
mojo::ReportBadMessage(
"SendFencedFrameReportingBeaconToCustomURL() received while "
"FencedFrames not enabled.");
return;
}

if (!base::FeatureList::IsEnabled(
blink::features::kAdAuctionReportingWithMacroApi)) {
mojo::ReportBadMessage(
"SendFencedFrameReportingBeaconToCustomURL() received while "
"AdAuctionReportingWithMacroApi not enabled.");
return;
}

if (!destination_url.is_valid() ||
!destination_url.SchemeIs(url::kHttpsScheme)) {
mojo::ReportBadMessage(
Expand Down Expand Up @@ -8697,6 +8719,13 @@ void RenderFrameHostImpl::SetFencedFrameAutomaticBeaconReportEventData(
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features,
bool once) {
if (!blink::features::IsFencedFramesEnabled()) {
mojo::ReportBadMessage(
"SetFencedFrameAutomaticBeaconReportEventData() received while "
"FencedFrames not enabled.");
return;
}

if (event_data.length() > blink::kFencedFrameMaxBeaconLength) {
mojo::ReportBadMessage(
"The data provided to SetFencedFrameAutomaticBeaconReportEventData() "
Expand Down
4 changes: 3 additions & 1 deletion third_party/blink/renderer/core/html/fenced_frame/fence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ void Fence::reportEvent(ScriptState* script_state,
return;
}

if (event->hasDestinationURL()) {
if (event->hasDestinationURL() &&
base::FeatureList::IsEnabled(
blink::features::kAdAuctionReportingWithMacroApi)) {
reportEventToDestinationURL(script_state, event, exception_state);
} else {
reportEventToDestinationEnum(script_state, event, exception_state);
Expand Down

0 comments on commit 0c20fbc

Please sign in to comment.