Diff
Modified: trunk/Source/WebKit/ChangeLog (284300 => 284301)
--- trunk/Source/WebKit/ChangeLog 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/ChangeLog 2021-10-16 02:59:03 UTC (rev 284301)
@@ -1,3 +1,30 @@
+2021-10-15 Alex Christensen <achristen...@webkit.org>
+
+ Use attributedBundleIdentifier instead of applicationBundleIdentifier when present for handling PCM attribution
+ https://bugs.webkit.org/show_bug.cgi?id=231827
+
+ Reviewed by Brady Eidson.
+
+ This is the same identifier that SafariViewController uses in _setEphemeralUIEventAttribution:forApplicationWithBundleID:
+ If we don't do this, then SafariViewController looks in the database for PCMs from com.apple.SafariViewService and doesn't find any and doesn't send any reports.
+
+ * NetworkProcess/NetworkDataTask.cpp:
+ (WebKit::NetworkDataTask::attributedBundleIdentifier):
+ * NetworkProcess/NetworkDataTask.h:
+ * NetworkProcess/NetworkLoad.cpp:
+ (WebKit::NetworkLoad::attributedBundleIdentifier):
+ * NetworkProcess/NetworkLoad.h:
+ * NetworkProcess/NetworkResourceLoader.cpp:
+ (WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest):
+ * NetworkProcess/NetworkResourceLoader.h:
+ * NetworkProcess/NetworkSession.cpp:
+ (WebKit::NetworkSession::handlePrivateClickMeasurementConversion):
+ * NetworkProcess/NetworkSession.h:
+ * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
+ * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+ (-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:applicationBundleID:ephemeral:]):
+ (-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:applicationBundleID:]): Deleted.
+
2021-10-15 Per Arne Vollan <pvol...@apple.com>
[macOS] Add telemetry for system calls in WP
Modified: trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp (284300 => 284301)
--- trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp 2021-10-16 02:59:03 UTC (rev 284301)
@@ -175,4 +175,11 @@
#endif
}
+String NetworkDataTask::attributedBundleIdentifier(WebPageProxyIdentifier pageID)
+{
+ if (auto* session = networkSession())
+ return session->attributedBundleIdentifierFromPageIdentifier(pageID);
+ return { };
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h (284300 => 284301)
--- trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h 2021-10-16 02:59:03 UTC (rev 284301)
@@ -27,6 +27,7 @@
#include "DownloadID.h"
#include "SandboxExtension.h"
+#include "WebPageProxyIdentifier.h"
#include <WebCore/Credential.h>
#include <WebCore/FrameLoaderTypes.h>
#include <WebCore/NetworkLoadMetrics.h>
@@ -135,6 +136,7 @@
virtual void setH2PingCallback(const URL&, CompletionHandler<void(Expected<WTF::Seconds, WebCore::ResourceError>&&)>&&);
virtual void setPriority(WebCore::ResourceLoadPriority) { }
+ String attributedBundleIdentifier(WebPageProxyIdentifier);
PAL::SessionID sessionID() const;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp (284300 => 284301)
--- trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp 2021-10-16 02:59:03 UTC (rev 284301)
@@ -317,4 +317,11 @@
completionHandler(makeUnexpected(internalError(url)));
}
+String NetworkLoad::attributedBundleIdentifier(WebPageProxyIdentifier pageID)
+{
+ if (m_task)
+ return m_task->attributedBundleIdentifier(pageID);
+ return { };
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoad.h (284300 => 284301)
--- trunk/Source/WebKit/NetworkProcess/NetworkLoad.h 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoad.h 2021-10-16 02:59:03 UTC (rev 284301)
@@ -60,6 +60,7 @@
const NetworkLoadParameters& parameters() const { return m_parameters; }
const URL& url() const { return parameters().request.url(); }
+ String attributedBundleIdentifier(WebPageProxyIdentifier);
void continueWillSendRequest(WebCore::ResourceRequest&&);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (284300 => 284301)
--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp 2021-10-16 02:59:03 UTC (rev 284301)
@@ -1080,8 +1080,10 @@
ASSERT(!isSynchronous());
NetworkSession* networkSession = nullptr;
- if (privateClickMeasurementAttributionTriggerData && (networkSession = m_connection->networkProcess().networkSession(sessionID())))
- networkSession->handlePrivateClickMeasurementConversion(WTFMove(*privateClickMeasurementAttributionTriggerData), request.url(), redirectRequest);
+ if (privateClickMeasurementAttributionTriggerData && (networkSession = m_connection->networkProcess().networkSession(sessionID()))) {
+ auto attributedBundleIdentifier = m_networkLoad ? m_networkLoad->attributedBundleIdentifier(m_parameters.webPageProxyID) : String();
+ networkSession->handlePrivateClickMeasurementConversion(WTFMove(*privateClickMeasurementAttributionTriggerData), request.url(), redirectRequest, WTFMove(attributedBundleIdentifier));
+ }
if (m_isKeptAlive) {
continueWillSendRequest(WTFMove(redirectRequest), false);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h (284300 => 284301)
--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h 2021-10-16 02:59:03 UTC (rev 284301)
@@ -212,8 +212,6 @@
void logSlowCacheRetrieveIfNeeded(const NetworkCache::Cache::RetrieveInfo&);
- void handlePrivateClickMeasurementConversion(WebCore::PrivateClickMeasurement::AttributionTriggerData&&, const URL&, const WebCore::ResourceRequest&);
-
std::optional<Seconds> validateCacheEntryForMaxAgeCapValidation(const WebCore::ResourceRequest&, const WebCore::ResourceRequest& redirectRequest, const WebCore::ResourceResponse&);
ResourceLoadInfo resourceLoadInfo();
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (284300 => 284301)
--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2021-10-16 02:59:03 UTC (rev 284301)
@@ -331,12 +331,12 @@
privateClickMeasurement().storeUnattributed(WTFMove(unattributedPrivateClickMeasurement), [] { });
}
-void NetworkSession::handlePrivateClickMeasurementConversion(PrivateClickMeasurement::AttributionTriggerData&& attributionTriggerData, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest)
+void NetworkSession::handlePrivateClickMeasurementConversion(PrivateClickMeasurement::AttributionTriggerData&& attributionTriggerData, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest, String&& attributedBundleIdentifier)
{
+ String appBundleID = WTFMove(attributedBundleIdentifier);
#if PLATFORM(COCOA)
- auto appBundleID = WebCore::applicationBundleIdentifier();
-#else
- auto appBundleID = String();
+ if (appBundleID.isEmpty())
+ appBundleID = WebCore::applicationBundleIdentifier();
#endif
if (m_ephemeralMeasurement) {
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (284300 => 284301)
--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2021-10-16 02:59:03 UTC (rev 284301)
@@ -127,7 +127,7 @@
virtual void clearAppBoundSession() { }
#endif
void storePrivateClickMeasurement(WebCore::PrivateClickMeasurement&&);
- void handlePrivateClickMeasurementConversion(WebCore::PrivateClickMeasurement::AttributionTriggerData&&, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest);
+ void handlePrivateClickMeasurementConversion(WebCore::PrivateClickMeasurement::AttributionTriggerData&&, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest, String&& attributedBundleIdentifier);
void dumpPrivateClickMeasurement(CompletionHandler<void(String)>&&);
void clearPrivateClickMeasurement(CompletionHandler<void()>&&);
void clearPrivateClickMeasurementForRegistrableDomain(WebCore::RegistrableDomain&&, CompletionHandler<void()>&&);
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h (284300 => 284301)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h 2021-10-16 02:59:03 UTC (rev 284301)
@@ -44,7 +44,7 @@
@interface WKWebView (WKTesting)
-- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(nullable NSString *)nonce applicationBundleID:(NSString *)bundleID WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(nullable NSString *)nonce applicationBundleID:(NSString *)bundleID ephemeral:(BOOL)ephemeral WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin;
- (CGFloat)_pageScale;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm (284300 => 284301)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm 2021-10-16 02:59:03 UTC (rev 284301)
@@ -55,7 +55,7 @@
@implementation WKWebView (WKTesting)
-- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(NSString *)nonce applicationBundleID:(NSString *)bundleID
+- (void)_addEventAttributionWithSourceID:(uint8_t)sourceID destinationURL:(NSURL *)destination sourceDescription:(NSString *)sourceDescription purchaser:(NSString *)purchaser reportEndpoint:(NSURL *)reportEndpoint optionalNonce:(NSString *)nonce applicationBundleID:(NSString *)bundleID ephemeral:(BOOL)ephemeral
{
WebCore::PrivateClickMeasurement measurement(
WebCore::PrivateClickMeasurement::SourceID(sourceID),
@@ -63,7 +63,7 @@
WebCore::PrivateClickMeasurement::AttributionDestinationSite(destination),
bundleID,
WallTime::now(),
- WebCore::PrivateClickMeasurement::AttributionEphemeral::No
+ ephemeral ? WebCore::PrivateClickMeasurement::AttributionEphemeral::Yes : WebCore::PrivateClickMeasurement::AttributionEphemeral::No
);
if (nonce)
measurement.setEphemeralSourceNonce({ nonce });
Modified: trunk/Tools/ChangeLog (284300 => 284301)
--- trunk/Tools/ChangeLog 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Tools/ChangeLog 2021-10-16 02:59:03 UTC (rev 284301)
@@ -1,3 +1,14 @@
+2021-10-15 Alex Christensen <achristen...@webkit.org>
+
+ Use attributedBundleIdentifier instead of applicationBundleIdentifier when present for handling PCM attribution
+ https://bugs.webkit.org/show_bug.cgi?id=231827
+
+ Reviewed by Brady Eidson.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
+ (TestWebKitAPI::runBasicPCMTest):
+ (TestWebKitAPI::TEST):
+
2021-10-15 Ross Kirsling <ross.kirsl...@sony.com>
Realize Mac CMake build of WebCore and WebKit
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm (284300 => 284301)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm 2021-10-16 01:43:14 UTC (rev 284300)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm 2021-10-16 02:59:03 UTC (rev 284301)
@@ -120,7 +120,7 @@
[[NSFileManager defaultManager] removeItemAtURL:adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]).get()._resourceLoadStatisticsDirectory error:nil];
}
-void runBasicPCMTest(WKWebViewConfiguration *configuration, Function<void(WKWebView *, const HTTPServer&)>&& addAttributionToWebView)
+void runBasicPCMTest(WKWebViewConfiguration *configuration, Function<void(WKWebView *, const HTTPServer&)>&& addAttributionToWebView, bool setTestAppBundleID = true)
{
clearState();
[WKWebsiteDataStore _setNetworkProcessSuspensionAllowedForTesting:NO];
@@ -163,10 +163,13 @@
[[webView configuration].websiteDataStore _trustServerForLocalPCMTesting:secTrustFromCertificateChain(@[(id)testCertificate().get()]).get()];
[webView _setPrivateClickMeasurementAttributionReportURLsForTesting:serverURL destinationURL:exampleURL() completionHandler:^{
[webView _setPrivateClickMeasurementOverrideTimerForTesting:YES completionHandler:^{
- [webView _setPrivateClickMeasurementAppBundleIDForTesting:@"test.bundle.id" completionHandler:^{
- NSString *html = [NSString stringWithFormat:@"<script>fetch('%@conversionRequestBeforeRedirect',{mode:'no-cors'})</script>", serverURL];
+ NSString *html = [NSString stringWithFormat:@"<script>fetch('%@conversionRequestBeforeRedirect',{mode:'no-cors'})</script>", serverURL];
+ if (setTestAppBundleID) {
+ [webView _setPrivateClickMeasurementAppBundleIDForTesting:@"test.bundle.id" completionHandler:^{
+ [webView loadHTMLString:html baseURL:exampleURL()];
+ }];
+ } else
[webView loadHTMLString:html baseURL:exampleURL()];
- }];
}];
}];
Util::run(&done);
@@ -309,7 +312,7 @@
auto webView = adoptNS([WKWebView new]);
webView.get().navigationDelegate = delegateAllowingAllTLS();
- [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:serverURL optionalNonce:@"ABCDEFabcdef0123456789" applicationBundleID:@"test.bundle.id"];
+ [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:serverURL optionalNonce:@"ABCDEFabcdef0123456789" applicationBundleID:@"test.bundle.id" ephemeral:NO];
[[webView configuration].websiteDataStore _setResourceLoadStatisticsEnabled:YES];
[[webView configuration].websiteDataStore _trustServerForLocalPCMTesting:secTrustFromCertificateChain(@[(id)testCertificate().get()]).get()];
@@ -332,10 +335,19 @@
TEST(PrivateClickMeasurement, Basic)
{
runBasicPCMTest(nil, [](WKWebView *webView, const HTTPServer& server) {
- [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"test.bundle.id"];
+ [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"test.bundle.id" ephemeral:NO];
});
}
+TEST(PrivateClickMeasurement, EphemeralWithAttributedBundleIdentifier)
+{
+ auto configuration = adoptNS([WKWebViewConfiguration new]);
+ configuration.get()._attributedBundleIdentifier = @"other.test.bundle.id";
+ runBasicPCMTest(configuration.get(), [](WKWebView *webView, const HTTPServer& server) {
+ [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"other.test.bundle.id" ephemeral:YES];
+ }, false);
+}
+
TEST(PrivateClickMeasurement, DatabaseLocation)
{
NSFileManager *fileManager = [NSFileManager defaultManager];
@@ -354,7 +366,7 @@
auto dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()]);
viewConfiguration.get().websiteDataStore = dataStore.get();
runBasicPCMTest(viewConfiguration.get(), [](WKWebView *webView, const HTTPServer& server) {
- [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"test.bundle.id"];
+ [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"test.bundle.id" ephemeral:NO];
});
originalNetworkProcessPid = [dataStore _networkProcessIdentifier];
EXPECT_GT(originalNetworkProcessPid, 0);
@@ -497,7 +509,7 @@
auto [tempDir, configuration] = setUpDaemon(adoptNS([WKWebViewConfiguration new]).autorelease());
attemptConnectionInProcessWithoutEntitlement();
runBasicPCMTest(configuration, [](WKWebView *webView, const HTTPServer& server) {
- [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"test.bundle.id"];
+ [webView _addEventAttributionWithSourceID:42 destinationURL:exampleURL() sourceDescription:@"test source description" purchaser:@"test purchaser" reportEndpoint:server.request().URL optionalNonce:nil applicationBundleID:@"test.bundle.id" ephemeral:NO];
});
cleanUpDaemon(tempDir);
}