Skip to content
Permalink
Browse files
Add UIEventAttribution SPI that uses PrivateClickMeasurementAttributi…
…onEphemeral::Yes

https://bugs.webkit.org/show_bug.cgi?id=229623

Reviewed by John Wilander.

Source/WebKit:

This will be used by rdar://80806283.

* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _setEphemeralUIEventAttribution:]):
(-[WKWebView _ephemeralUIEventAttribution]):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
(TestWebKitAPI::TEST):



Canonical link: https://commits.webkit.org/241065@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281723 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
achristensen07 committed Aug 27, 2021
1 parent 9c8e5fc commit 9e65013a259cb0ac3257ddf275a294c71d3803db
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
@@ -1,3 +1,17 @@
2021-08-27 Alex Christensen <achristensen@webkit.org>

Add UIEventAttribution SPI that uses PrivateClickMeasurementAttributionEphemeral::Yes
https://bugs.webkit.org/show_bug.cgi?id=229623

Reviewed by John Wilander.

This will be used by rdar://80806283.

* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _setEphemeralUIEventAttribution:]):
(-[WKWebView _ephemeralUIEventAttribution]):

2021-08-27 Alex Christensen <achristensen@webkit.org>

Separate PrivateClickMeasurement database from ResourceLoadStatistics database and add SPI to set its location
@@ -422,6 +422,7 @@ for this property.

#if !TARGET_OS_TV && !TARGET_OS_WATCH
@property (nonatomic, copy, setter=_setUIEventAttribution:) UIEventAttribution *_uiEventAttribution WK_API_AVAILABLE(ios(15.0));
@property (nonatomic, copy, setter=_setEphemeralUIEventAttribution:) UIEventAttribution *_ephemeralUIEventAttribution WK_API_AVAILABLE(ios(WK_IOS_TBA));
#endif

@property (nonatomic, readonly) CGRect _contentVisibleRect WK_API_AVAILABLE(ios(10.0));
@@ -2645,6 +2645,31 @@ - (UIEventAttribution *)_uiEventAttribution
return nil;
#endif
}

- (void)_setEphemeralUIEventAttribution:(UIEventAttribution *)attribution
{
#if HAVE(UI_EVENT_ATTRIBUTION)
if (attribution) {
WebCore::PrivateClickMeasurement measurement(
WebCore::PrivateClickMeasurement::SourceID(attribution.sourceIdentifier),
WebCore::PrivateClickMeasurement::SourceSite(attribution.reportEndpoint),
WebCore::PrivateClickMeasurement::AttributionDestinationSite(attribution.destinationURL),
attribution.sourceDescription,
attribution.purchaser,
WallTime::now(),
WebCore::PrivateClickMeasurementAttributionEphemeral::Yes
);
_page->setPrivateClickMeasurement(WTFMove(measurement));
} else
_page->setPrivateClickMeasurement(std::nullopt);
#endif
}

- (UIEventAttribution *)_ephemeralUIEventAttribution
{
return self._uiEventAttribution;
}

#endif // !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)

- (CGRect)_contentVisibleRect
@@ -1,3 +1,13 @@
2021-08-27 Alex Christensen <achristensen@webkit.org>

Add UIEventAttribution SPI that uses PrivateClickMeasurementAttributionEphemeral::Yes
https://bugs.webkit.org/show_bug.cgi?id=229623

Reviewed by John Wilander.

* TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
(TestWebKitAPI::TEST):

2021-08-27 Yijia Huang <yijia_huang@apple.com>

Add a new email address to contributors.json
@@ -344,6 +344,14 @@ HTTPServer server([&done, connectionCount = 0, &rsaPrivateKey, &modulusNBytes, &
});
}

TEST(EventAttribution, BasicWithEphemeralIOSSPI)
{
runBasicEventAttributionTest(nil, [](WKWebView *webView, const HTTPServer& server) {
auto attribution = adoptNS([[MockEventAttribution alloc] initWithReportEndpoint:server.request().URL destinationURL:exampleURL()]);
webView._ephemeralUIEventAttribution = (UIEventAttribution *)attribution.get();
});
}

#endif // HAVE(UI_EVENT_ATTRIBUTION)

} // namespace TestWebKitAPI

0 comments on commit 9e65013

Please sign in to comment.