Skip to content

Commit

Permalink
Fenced frames: Add reporting to custom destination URLs [2/N]
Browse files Browse the repository at this point in the history
This CL adds a no-op mojo interface, which is exercised by WPTs added
in the previous CL.

The next CL will actually implement and test the browser side of the
API (reusing much of the existing FencedFrameReporter implementation).

CL 1/N: https://chromium-review.googlesource.com/c/chromium/src/+/4711374

WICG/turtledove#477

Change-Id: I21a2072fae8663a797432501077ff182b568e03c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4721545
Reviewed-by: Dominic Farolino <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Commit-Queue: Garrett Tanzer <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1178188}
  • Loading branch information
Garrett Tanzer authored and Chromium LUCI CQ committed Aug 2, 2023
1 parent 4024df3 commit 13d3de2
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 4 deletions.
11 changes: 11 additions & 0 deletions content/browser/renderer_host/render_frame_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8502,6 +8502,17 @@ void RenderFrameHostImpl::SendFencedFrameReportingBeacon(
}
}

// TODO(crbug.com/1400992): Move SendFencedFrameReportingBeaconToCustomURL into
// a separate refcounted class.
void RenderFrameHostImpl::SendFencedFrameReportingBeaconToCustomURL(
const GURL& destination_url,
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features) {
// TODO(gtanzer): Implement the body of this method.
std::ignore = destination_url;
std::ignore = attribution_reporting_runtime_features;
}

void RenderFrameHostImpl::MaybeSendFencedFrameReportingBeacon(
NavigationRequest& navigation_request) {
// The fenced frame "reserved.top_navigation" automatic beacon only cares
Expand Down
4 changes: 4 additions & 0 deletions content/browser/renderer_host/render_frame_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2446,6 +2446,10 @@ class CONTENT_EXPORT RenderFrameHostImpl
const std::vector<blink::FencedFrame::ReportingDestination>& destinations,
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features) override;
void SendFencedFrameReportingBeaconToCustomURL(
const GURL& destination_url,
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features) override;
void SetFencedFrameAutomaticBeaconReportEventData(
const std::string& event_data,
const std::vector<blink::FencedFrame::ReportingDestination>& destinations,
Expand Down
19 changes: 19 additions & 0 deletions third_party/blink/public/mojom/frame/frame.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,25 @@ interface LocalFrameHost {
network.mojom.AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features);

// See:
// https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md
//
// This implements the API:
// window.fence.reportEvent({destinationURL})
//
// A document in a fenced frame can invoke the reportEvent API to request the
// browser to send a beacon to the https URL `destinationURL`, where macros
// in `destinationURL` will be substituted using the values specified by
// registerAdMacro in the Protected Audience auction's buyer worklet.
//
// TODO(crbug.com/1443561): Get rid of
// `attribution_reporting_runtime_features` when Runtime Feature State fully
// supports runtime feature access from the browser process.
SendFencedFrameReportingBeaconToCustomURL(
url.mojom.Url destination_url,
network.mojom.AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features);

// Notify the browser that there is a legacy technology used by the page.
// The event contains the technology `type` and code location from the
// ExecutionContext.
Expand Down
16 changes: 12 additions & 4 deletions third_party/blink/renderer/core/html/fenced_frame/fence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ void Fence::reportEventToDestinationURL(ScriptState* script_state,
return;
}

GURL destinationURL(KURL(event->destinationURL()));
if (!destinationURL.is_valid()) {
KURL destinationURL(event->destinationURL());
if (!destinationURL.IsValid()) {
exception_state.ThrowTypeError(
"The destination URL provided to reportEvent() is not a valid URL.");
return;
}
if (!destinationURL.SchemeIs(url::kHttpsScheme)) {
if (!destinationURL.ProtocolIs(url::kHttpsScheme)) {
exception_state.ThrowTypeError(
"The destination URL provided to reportEvent() does not have the "
"required scheme (https).");
Expand All @@ -193,7 +193,15 @@ void Fence::reportEventToDestinationURL(ScriptState* script_state,
return;
}

// TODO(gtanzer): Call into the browser.
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features;
if (AttributionSrcLoader* attribution_src_loader =
frame->GetAttributionSrcLoader()) {
attribution_reporting_runtime_features =
attribution_src_loader->GetRuntimeFeatures();
}
frame->GetLocalFrameHostRemote().SendFencedFrameReportingBeaconToCustomURL(
destinationURL, attribution_reporting_runtime_features);
}

void Fence::setReportEventDataForAutomaticBeacons(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ void FakeLocalFrameHost::SendFencedFrameReportingBeacon(
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features) {}

void FakeLocalFrameHost::SendFencedFrameReportingBeaconToCustomURL(
const blink::KURL& destination_url,
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features) {}

void FakeLocalFrameHost::SetFencedFrameAutomaticBeaconReportEventData(
const WTF::String& event_data,
const WTF::Vector<blink::FencedFrame::ReportingDestination>& destinations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ class FakeLocalFrameHost : public mojom::blink::LocalFrameHost {
const WTF::Vector<blink::FencedFrame::ReportingDestination>& destinations,
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features) override;
void SendFencedFrameReportingBeaconToCustomURL(
const blink::KURL& destination_url,
network::AttributionReportingRuntimeFeatures
attribution_reporting_runtime_features) override;
void SetFencedFrameAutomaticBeaconReportEventData(
const WTF::String& event_data,
const WTF::Vector<blink::FencedFrame::ReportingDestination>& destinations,
Expand Down

0 comments on commit 13d3de2

Please sign in to comment.