WebKit Bugzilla
Attachment 361703 Details for
Bug 194510
: Store Ad Click Attribution requests in the network process
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194510-20190211123511.patch (text/plain), 53.64 KB, created by
John Wilander
on 2019-02-11 12:35:11 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
John Wilander
Created:
2019-02-11 12:35:11 PST
Size:
53.64 KB
patch
obsolete
>Subversion Revision: 241252 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 5b18bd844f9ee1331bbda90db1c9ce52963d1ab3..104bc6b1400aafb0cf901dc62ac1fd4a5f0b7b63 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,33 @@ >+2019-02-11 John Wilander <wilander@apple.com> >+ >+ Store Ad Click Attribution requests in the network process >+ https://bugs.webkit.org/show_bug.cgi?id=194510 >+ <rdar://problem/47650118> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: http/tests/adClickAttribution/store-ad-click-attribution.html >+ >+ This patch adds support functions for validation and storage of >+ WebCore::AdClickAttribution objects. >+ >+ * loader/AdClickAttribution.cpp: >+ (WebCore::AdClickAttribution::toString const): >+ * loader/AdClickAttribution.h: >+ (WebCore::AdClickAttribution::Source::Source): >+ (WebCore::AdClickAttribution::Destination::Destination): >+ (WebCore::AdClickAttribution::Destination::operator== const): >+ Added to support WebCore::AdClickAttribution::matchesDestination(). >+ (WebCore::AdClickAttribution::matchesDestination const): >+ Added to support validation once the destination page has loaded. >+ (WebCore::AdClickAttribution::source): >+ (WebCore::AdClickAttribution::destination): >+ Added to support mapped storage based on source and destination. >+ * loader/NavigationAction.h: >+ (WebCore::NavigationAction::adClickAttribution const): >+ (WebCore::NavigationAction::adClickAttribution): Deleted. >+ Corrected the constness of this function. >+ > 2019-02-10 Philippe Normand <pnormand@igalia.com> > > Unreviewed, GTK Debug build fix after r241148. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index edc4b128daeee8a25c36bec7968091d7bcff16e4..bb8cd324b7dc811d17e8a339ed78cb1ab749da2a 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,76 @@ >+2019-02-11 John Wilander <wilander@apple.com> >+ >+ Store Ad Click Attribution requests in the network process >+ https://bugs.webkit.org/show_bug.cgi?id=194510 >+ <rdar://problem/47650118> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ With this patch, WebPageProxy::didCommitLoadForFrame() now looks for >+ an AdClickAttribution object in its navigation state. If there is an >+ attribution, it sends it to the network process where the >+ WebKit::NetworkSession stores it in an object of a new class, >+ WebKit::NetworkAdClickAttribution. >+ >+ This patch also covers test infrastructure to support two new >+ TestRunner functions: >+ - dumpAdClickAttribution() >+ - clearAdClickAttribution() >+ >+ * NetworkProcess/Cookies/WebCookieManager.cpp: >+ Added missing header include. >+ * NetworkProcess/NetworkAdClickAttribution.cpp: Added. >+ (WebKit::NetworkAdClickAttribution::ensureAttributionsForAdClickSource): >+ (WebKit::NetworkAdClickAttribution::store): >+ (WebKit::NetworkAdClickAttribution::clear): >+ (WebKit::NetworkAdClickAttribution::toString const): >+ * NetworkProcess/NetworkAdClickAttribution.h: Added. >+ Stores WebCore::AdClickAttribution objects in a map structure. >+ * NetworkProcess/NetworkLoad.cpp: >+ Added missing header includes. >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::storeAdClickAttribution): >+ (WebKit::NetworkProcess::dumpAdClickAttribution): >+ (WebKit::NetworkProcess::clearAdClickAttribution): >+ * NetworkProcess/NetworkProcess.h: >+ * NetworkProcess/NetworkProcess.messages.in: >+ * NetworkProcess/NetworkSession.cpp: >+ (WebKit::NetworkSession::NetworkSession): >+ (WebKit::NetworkSession::storeAdClickAttribution): >+ (WebKit::NetworkSession::dumpAdClickAttribution): >+ (WebKit::NetworkSession::clearAdClickAttribution): >+ * NetworkProcess/NetworkSession.h: >+ * Sources.txt: >+ * UIProcess/API/APINavigation.h: >+ (API::Navigation::adClickAttribution const): >+ * UIProcess/API/C/WKPage.cpp: >+ (WKPageDumpAdClickAttribution): >+ (WKPageClearAdClickAttribution): >+ Test infrastructure. >+ * UIProcess/API/C/WKPagePrivate.h: >+ * UIProcess/Network/NetworkProcessProxy.cpp: >+ (WebKit::NetworkProcessProxy::dumpAdClickAttribution): >+ (WebKit::NetworkProcessProxy::clearAdClickAttribution): >+ Test infrastructure. >+ * UIProcess/Network/NetworkProcessProxy.h: >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::didFinishDocumentLoadForFrame): >+ This is where pending Ad Click Attributions are forwarded to the >+ network process. >+ (WebKit::WebPageProxy::dumpAdClickAttribution): >+ (WebKit::WebPageProxy::clearAdClickAttribution): >+ Test infrastructure. >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/WebProcessPool.cpp: >+ (WebKit::WebProcessPool::dumpAdClickAttribution): >+ (WebKit::WebProcessPool::clearAdClickAttribution): >+ Test infrastructure. >+ * UIProcess/WebProcessPool.h: >+ * WebKit.xcodeproj/project.pbxproj: >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: >+ (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): >+ Added missing data copying from navigationAction to navigationActionData. >+ > 2019-02-10 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r241167. >diff --git a/Source/WebCore/loader/AdClickAttribution.cpp b/Source/WebCore/loader/AdClickAttribution.cpp >index bdc0639372e3dd3e44ba8567b303fdcb3c665359..460cc5ceac089430a61cf8f7d059e521e2b5916d 100644 >--- a/Source/WebCore/loader/AdClickAttribution.cpp >+++ b/Source/WebCore/loader/AdClickAttribution.cpp >@@ -90,4 +90,23 @@ URL AdClickAttribution::referrer() const > return URL(); > } > >+String AdClickAttribution::toString() const >+{ >+ StringBuilder builder; >+ builder.appendLiteral("Source: "); >+ builder.append(m_source.registrableDomain); >+ builder.appendLiteral("\nDestination: "); >+ builder.append(m_destination.registrableDomain); >+ builder.appendLiteral("\nCampaign ID: "); >+ builder.appendNumber(m_campaign.id); >+ if (m_conversion) { >+ builder.appendLiteral("\nConversion data: "); >+ builder.appendNumber(m_conversion.value().data); >+ } else >+ builder.appendLiteral("\nNo conversion data."); >+ builder.append('\n'); >+ >+ return builder.toString(); >+} >+ > } >diff --git a/Source/WebCore/loader/AdClickAttribution.h b/Source/WebCore/loader/AdClickAttribution.h >index 34af2f2da5577fc487a173d79f7ab4935b94aabb..e19d05127f8b2b21f76a4f9330c358653530e491 100644 >--- a/Source/WebCore/loader/AdClickAttribution.h >+++ b/Source/WebCore/loader/AdClickAttribution.h >@@ -26,15 +26,11 @@ > #pragma once > > #include "PublicSuffix.h" >-#include <wtf/Noncopyable.h> > #include <wtf/Optional.h> >+#include <wtf/URL.h> > #include <wtf/WallTime.h> > #include <wtf/text/WTFString.h> > >-namespace WTF { >-class URL; >-} >- > namespace WebCore { > > class AdClickAttribution { >@@ -46,6 +42,7 @@ public: > static constexpr uint32_t MaxEntropy = 64; > > struct Campaign { >+ Campaign() = default; > explicit Campaign(CampaignId id) > : id { id } > { >@@ -56,13 +53,14 @@ public: > return id < MaxEntropy; > } > >- CampaignId id; >+ CampaignId id { 0 }; > }; > > struct Source { >+ Source() = default; > explicit Source(const String& host) > #if ENABLE(PUBLIC_SUFFIX_LIST) >- : registrableDomain { WebCore::topPrivatelyControlledDomain(host) } >+ : registrableDomain { topPrivatelyControlledDomain(host) } > #else > : registrableDomain { emptyString() } > #endif >@@ -73,15 +71,21 @@ public: > }; > > struct Destination { >+ Destination() = default; > explicit Destination(const String& host) > #if ENABLE(PUBLIC_SUFFIX_LIST) >- : registrableDomain { WebCore::topPrivatelyControlledDomain(host) } >+ : registrableDomain { topPrivatelyControlledDomain(host) } > #else > : registrableDomain { emptyString() } > #endif > { > } > >+ bool operator==(const Destination& other) const >+ { >+ return registrableDomain == other.registrableDomain; >+ } >+ > String registrableDomain; > }; > >@@ -113,6 +117,7 @@ public: > template<class Decoder> static Optional<Conversion> decode(Decoder&); > }; > >+ AdClickAttribution() = default; > AdClickAttribution(Campaign campaign, const Source& source, const Destination& destination) > : m_campaign { campaign } > , m_source { source } >@@ -122,10 +127,15 @@ public: > } > > WEBCORE_EXPORT void setConversion(Conversion&&); >+ bool matchesDestination(const URL& url) const { return m_destination == Destination { topPrivatelyControlledDomain(url.host().toString()) }; }; > WEBCORE_EXPORT URL url() const; > WEBCORE_EXPORT URL referrer() const; >+ Source& source() { return m_source; }; >+ Destination& destination() { return m_destination; }; > Optional<WallTime> earliestTimeToSend() const { return m_earliestTimeToSend; }; > >+ WEBCORE_EXPORT String toString() const; >+ > template<class Encoder> void encode(Encoder&) const; > template<class Decoder> static Optional<AdClickAttribution> decode(Decoder&); > >diff --git a/Source/WebCore/loader/NavigationAction.h b/Source/WebCore/loader/NavigationAction.h >index 9497e980f766ef46cfe44804a1e1b8867d30deca..a69bbd585709866e8d86715dfc21a4852cbb92ae 100644 >--- a/Source/WebCore/loader/NavigationAction.h >+++ b/Source/WebCore/loader/NavigationAction.h >@@ -135,7 +135,7 @@ public: > LockBackForwardList lockBackForwardList() const { return m_lockBackForwardList; } > void setLockBackForwardList(LockBackForwardList lockBackForwardList) { m_lockBackForwardList = lockBackForwardList; } > >- const Optional<AdClickAttribution>& adClickAttribution() { return m_adClickAttribution; }; >+ Optional<AdClickAttribution> adClickAttribution() const { return m_adClickAttribution; }; > void setAdClickAttribution(AdClickAttribution&& adClickAttribution) { m_adClickAttribution = adClickAttribution; }; > > private: >diff --git a/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp b/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp >index 825849ad051542e6750de5ee5af41c91d77c7cf5..1ec5da08c9de6bb00599c813619ef4963a274787 100644 >--- a/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp >+++ b/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "WebCookieManager.h" > >+#include "NetworkProcess.h" > #include "WebCookieManagerMessages.h" > #include "WebCookieManagerProxyMessages.h" > #include "WebCoreArgumentCoders.h" >diff --git a/Source/WebKit/NetworkProcess/NetworkAdClickAttribution.cpp b/Source/WebKit/NetworkProcess/NetworkAdClickAttribution.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..a45c019ff464e7d08f7348601f43e6fa74041624 >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/NetworkAdClickAttribution.cpp >@@ -0,0 +1,75 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "NetworkAdClickAttribution.h" >+ >+#include <wtf/text/StringBuilder.h> >+#include <wtf/text/StringHash.h> >+ >+namespace WebKit { >+ >+using AdClickAttribution = WebCore::AdClickAttribution; >+ >+HashMap<String, AdClickAttribution>& NetworkAdClickAttribution::ensureAttributionsForAdClickSource(const AdClickAttribution::Source& source) >+{ >+ return m_adClickAttributionMap.ensure(source.registrableDomain, [] { >+ return HashMap<String, AdClickAttribution> { }; >+ }).iterator->value; >+} >+ >+void NetworkAdClickAttribution::store(AdClickAttribution&& adClickAttribution) >+{ >+ auto& attributionsForSource = ensureAttributionsForAdClickSource(adClickAttribution.source()); >+ attributionsForSource.add(adClickAttribution.destination().registrableDomain, WTFMove(adClickAttribution)); >+} >+ >+void NetworkAdClickAttribution::clear(CompletionHandler<void()>&& completionHandler) >+{ >+ m_adClickAttributionMap.clear(); >+ completionHandler(); >+} >+ >+void NetworkAdClickAttribution::toString(CompletionHandler<void(String)>&& completionHandler) const >+{ >+ StringBuilder builder; >+ >+ for (auto& innerMap : m_adClickAttributionMap.values()) { >+ unsigned attributionNumber = 1; >+ for (auto& attribution : innerMap.values()) { >+ builder.appendLiteral("WebCore::AdClickAttribution "); >+ builder.appendNumber(attributionNumber++); >+ builder.append('\n'); >+ builder.append(attribution.toString()); >+ } >+ } >+ >+ if (builder.isEmpty()) >+ builder.appendLiteral("No stored Ad Click Attribution data."); >+ >+ completionHandler(builder.toString()); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkAdClickAttribution.h b/Source/WebKit/NetworkProcess/NetworkAdClickAttribution.h >new file mode 100644 >index 0000000000000000000000000000000000000000..38e165c944b6b48d242ece7e9b889796252c92c3 >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/NetworkAdClickAttribution.h >@@ -0,0 +1,50 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <WebCore/AdClickAttribution.h> >+#include <wtf/CompletionHandler.h> >+#include <wtf/HashMap.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebKit { >+ >+class NetworkAdClickAttribution { >+public: >+ >+ using AdClickAttribution = WebCore::AdClickAttribution; >+ >+ void store(AdClickAttribution&&); >+ void clear(CompletionHandler<void()>&&); >+ void toString(CompletionHandler<void(String)>&&) const; >+ >+private: >+ HashMap<String, AdClickAttribution>& ensureAttributionsForAdClickSource(const AdClickAttribution::Source&); >+ >+ HashMap<String, HashMap<String, AdClickAttribution>> m_adClickAttributionMap; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkLoad.cpp b/Source/WebKit/NetworkProcess/NetworkLoad.cpp >index fd62a14c2d78c8ca5a5af0ffba166131d6712ab5..f6df86b22d314315ecb2cbd7deb6947cfab54e1c 100644 >--- a/Source/WebKit/NetworkProcess/NetworkLoad.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkLoad.cpp >@@ -27,8 +27,11 @@ > #include "NetworkLoad.h" > > #include "AuthenticationChallengeDisposition.h" >+#include "AuthenticationManager.h" >+#include "NetworkDataTaskBlob.h" > #include "NetworkProcess.h" > #include "NetworkSession.h" >+#include "WebErrors.h" > #include <WebCore/ResourceRequest.h> > #include <WebCore/SharedBuffer.h> > #include <wtf/Seconds.h> >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index f166fd9e8b5ece14228fab2f073bca2ea930d2f3..de568047af92b44983b39c3473122673b95d72b6 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -2287,4 +2287,26 @@ void NetworkProcess::platformSyncAllCookies(CompletionHandler<void()>&& completi > > #endif > >+void NetworkProcess::storeAdClickAttribution(PAL::SessionID sessionID, WebCore::AdClickAttribution&& adClickAttribution) >+{ >+ if (auto session = networkSession(sessionID)) >+ session->storeAdClickAttribution(WTFMove(adClickAttribution)); >+} >+ >+void NetworkProcess::dumpAdClickAttribution(PAL::SessionID sessionID, CompletionHandler<void(String)>&& completionHandler) >+{ >+ if (auto session = networkSession(sessionID)) >+ return session->dumpAdClickAttribution(WTFMove(completionHandler)); >+ >+ completionHandler(emptyString()); >+} >+ >+void NetworkProcess::clearAdClickAttribution(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) >+{ >+ if (auto session = networkSession(sessionID)) >+ return session->clearAdClickAttribution(WTFMove(completionHandler)); >+ >+ completionHandler(); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.h b/Source/WebKit/NetworkProcess/NetworkProcess.h >index 335c3cafad6716a073695dbb3acc750b2c2c55cd..3d7c1c661c1eddfe80fb52ec252fbf658ef93344 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.h >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.h >@@ -32,6 +32,7 @@ > #include "NetworkContentRuleListManager.h" > #include "NetworkHTTPSUpgradeChecker.h" > #include "SandboxExtension.h" >+#include <WebCore/AdClickAttribution.h> > #include <WebCore/DiagnosticLoggingClient.h> > #include <WebCore/FetchIdentifier.h> > #include <WebCore/IDBKeyData.h> >@@ -294,6 +295,10 @@ public: > > NetworkBlobRegistry& networkBlobRegistry() override { return m_networkBlobRegistry; } > >+ void storeAdClickAttribution(PAL::SessionID, WebCore::AdClickAttribution&&); >+ void dumpAdClickAttribution(PAL::SessionID, CompletionHandler<void(String)>&&); >+ void clearAdClickAttribution(PAL::SessionID, CompletionHandler<void()>&&); >+ > private: > void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&); > std::unique_ptr<WebCore::NetworkStorageSession> platformCreateDefaultStorageSession() const; >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >index 6c4dbb1ff2d6807d43364820b5290bbd6f51a17b..3b131745b2ffbfcda067999ba739170bd7dccadb 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >@@ -163,4 +163,8 @@ messages -> NetworkProcess LegacyReceiver { > #if ENABLE(INDEXED_DATABASE) > SetIDBPerOriginQuota(uint64_t quota) > #endif >+ >+ StoreAdClickAttribution(PAL::SessionID sessionID, WebCore::AdClickAttribution adClickAttribution) >+ DumpAdClickAttribution(PAL::SessionID sessionID) -> (String adClickAttributionState) Async >+ ClearAdClickAttribution(PAL::SessionID sessionID) -> () Async > } >diff --git a/Source/WebKit/NetworkProcess/NetworkSession.cpp b/Source/WebKit/NetworkProcess/NetworkSession.cpp >index 20d09ba75932cc244f0099d58c852f0e1a73b707..26bd6f0a90ff1a9256c0858e5417a5e48a0fb4ad 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSession.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkSession.cpp >@@ -26,10 +26,12 @@ > #include "config.h" > #include "NetworkSession.h" > >+#include "NetworkAdClickAttribution.h" > #include "NetworkProcess.h" > #include "NetworkProcessProxyMessages.h" > #include "WebProcessProxy.h" > #include "WebResourceLoadStatisticsStore.h" >+#include <WebCore/AdClickAttribution.h> > #include <WebCore/NetworkStorageSession.h> > > #if PLATFORM(COCOA) >@@ -68,6 +70,7 @@ NetworkStorageSession& NetworkSession::networkStorageSession() const > NetworkSession::NetworkSession(NetworkProcess& networkProcess, PAL::SessionID sessionID) > : m_sessionID(sessionID) > , m_networkProcess(networkProcess) >+ , m_adClickAttribution(makeUniqueRef<NetworkAdClickAttribution>()) > { > } > >@@ -125,4 +128,19 @@ void NetworkSession::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<Webs > } > #endif > >+void NetworkSession::storeAdClickAttribution(WebCore::AdClickAttribution&& adClickAttribution) >+{ >+ m_adClickAttribution->store(WTFMove(adClickAttribution)); >+} >+ >+void NetworkSession::dumpAdClickAttribution(CompletionHandler<void(String)>&& completionHandler) >+{ >+ m_adClickAttribution->toString(WTFMove(completionHandler)); >+} >+ >+void NetworkSession::clearAdClickAttribution(CompletionHandler<void()>&& completionHandler) >+{ >+ m_adClickAttribution->clear(WTFMove(completionHandler)); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkSession.h b/Source/WebKit/NetworkProcess/NetworkSession.h >index e84107afde26fb902921f1000239fdd14d1ba599..822f043c1244ffb7590cb6a355195acbbfd3b600 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSession.h >+++ b/Source/WebKit/NetworkProcess/NetworkSession.h >@@ -30,16 +30,19 @@ > #include <wtf/Ref.h> > #include <wtf/RefCounted.h> > #include <wtf/Seconds.h> >+#include <wtf/UniqueRef.h> > #include <wtf/WeakPtr.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >+class AdClickAttribution; > class NetworkStorageSession; > enum class ShouldSample : bool; > } > > namespace WebKit { > >+class NetworkAdClickAttribution; > class NetworkDataTask; > class NetworkProcess; > class WebResourceLoadStatisticsStore; >@@ -73,6 +76,9 @@ public: > void logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample); > void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins); > #endif >+ void storeAdClickAttribution(WebCore::AdClickAttribution&&); >+ void dumpAdClickAttribution(CompletionHandler<void(String)>&&); >+ void clearAdClickAttribution(CompletionHandler<void()>&&); > > protected: > NetworkSession(NetworkProcess&, PAL::SessionID); >@@ -84,6 +90,7 @@ protected: > #if ENABLE(RESOURCE_LOAD_STATISTICS) > RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics; > #endif >+ UniqueRef<NetworkAdClickAttribution> m_adClickAttribution; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/Sources.txt b/Source/WebKit/Sources.txt >index b39d264c8f8f6576439cdcdaf45c7caa71e5b9be..05bfc9f8fe3af19ae6e0b9db86b246a63c9aabdb 100644 >--- a/Source/WebKit/Sources.txt >+++ b/Source/WebKit/Sources.txt >@@ -21,6 +21,7 @@ > // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF > // THE POSSIBILITY OF SUCH DAMAGE. > >+NetworkProcess/NetworkAdClickAttribution.cpp > NetworkProcess/NetworkActivityTracker.cpp > NetworkProcess/NetworkCORSPreflightChecker.cpp > NetworkProcess/NetworkConnectionToWebProcess.cpp >diff --git a/Source/WebKit/UIProcess/API/APINavigation.h b/Source/WebKit/UIProcess/API/APINavigation.h >index 9f4f1f81a38048d1734ec217ea283dfa1c80155a..a79bc5d8c36f05cbae9c83ab60ea78ea11058f6f 100644 >--- a/Source/WebKit/UIProcess/API/APINavigation.h >+++ b/Source/WebKit/UIProcess/API/APINavigation.h >@@ -30,9 +30,11 @@ > #include "FrameInfoData.h" > #include "NavigationActionData.h" > #include "WebBackForwardListItem.h" >+#include <WebCore/AdClickAttribution.h> > #include <WebCore/ProcessIdentifier.h> > #include <WebCore/ResourceRequest.h> > #include <WebCore/SecurityOriginData.h> >+#include <wtf/Optional.h> > #include <wtf/Ref.h> > > namespace WebCore { >@@ -142,6 +144,8 @@ public: > > const std::unique_ptr<SubstituteData>& substituteData() const { return m_substituteData; } > >+ Optional<WebCore::AdClickAttribution> adClickAttribution() const { return m_lastNavigationAction.adClickAttribution; } >+ > private: > explicit Navigation(WebKit::WebNavigationState&); > Navigation(WebKit::WebNavigationState&, WebCore::ResourceRequest&&, WebKit::WebBackForwardListItem* fromItem); >diff --git a/Source/WebKit/UIProcess/API/C/WKPage.cpp b/Source/WebKit/UIProcess/API/C/WKPage.cpp >index f05bf0ac42f02bdff753897f7cd26fd4537a1cd6..563a4380d6d3d9c2cec4cf02ab1789a28dfcda74 100644 >--- a/Source/WebKit/UIProcess/API/C/WKPage.cpp >+++ b/Source/WebKit/UIProcess/API/C/WKPage.cpp >@@ -2711,3 +2711,16 @@ void WKPageGetApplicationManifest_b(WKPageRef page, WKPageGetApplicationManifest > } > #endif > >+void WKPageDumpAdClickAttribution(WKPageRef page, WKPageDumpAdClickAttributionFunction callback, void* callbackContext) >+{ >+ toImpl(page)->dumpAdClickAttribution([callbackContext, callback] (const String& adClickAttribution) { >+ callback(WebKit::toAPI(adClickAttribution.impl()), callbackContext); >+ }); >+} >+ >+void WKPageClearAdClickAttribution(WKPageRef page, WKPageClearAdClickAttributionFunction callback, void* callbackContext) >+{ >+ toImpl(page)->clearAdClickAttribution([callbackContext, callback] () { >+ callback(callbackContext); >+ }); >+} >diff --git a/Source/WebKit/UIProcess/API/C/WKPagePrivate.h b/Source/WebKit/UIProcess/API/C/WKPagePrivate.h >index 2d898b83d6c935861e45dc3cbef6a14864fff85c..abdd361896082b57794bc43075a52185ccd21a55 100644 >--- a/Source/WebKit/UIProcess/API/C/WKPagePrivate.h >+++ b/Source/WebKit/UIProcess/API/C/WKPagePrivate.h >@@ -182,6 +182,11 @@ typedef void (^WKPageGetApplicationManifestBlock)(void); > WK_EXPORT void WKPageGetApplicationManifest_b(WKPageRef page, WKPageGetApplicationManifestBlock block); > #endif > >+typedef void (*WKPageDumpAdClickAttributionFunction)(WKStringRef adClickAttributionRepresentation, void* functionContext); >+WK_EXPORT void WKPageDumpAdClickAttribution(WKPageRef, WKPageDumpAdClickAttributionFunction, void* callbackContext); >+typedef void (*WKPageClearAdClickAttributionFunction)(void* functionContext); >+WK_EXPORT void WKPageClearAdClickAttribution(WKPageRef, WKPageClearAdClickAttributionFunction, void* callbackContext); >+ > #ifdef __cplusplus > } > #endif >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >index d2a9289cce7af75cdc65f92e2a9194caca1d3f86..7ea9e4e32c72c6980c7ec087aa268205f30dcc2f 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >@@ -1067,7 +1067,27 @@ void NetworkProcessProxy::didDestroyWebUserContentControllerProxy(WebUserContent > m_webUserContentControllerProxies.remove(&proxy); > } > #endif >+ >+void NetworkProcessProxy::dumpAdClickAttribution(PAL::SessionID sessionID, CompletionHandler<void(const String&)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(emptyString()); >+ return; >+ } >+ >+ sendWithAsyncReply(Messages::NetworkProcess::DumpAdClickAttribution(sessionID), WTFMove(completionHandler)); >+} >+ >+void NetworkProcessProxy::clearAdClickAttribution(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } > >+ sendWithAsyncReply(Messages::NetworkProcess::ClearAdClickAttribution(sessionID), WTFMove(completionHandler)); >+} >+ > void NetworkProcessProxy::sendProcessDidTransitionToForeground() > { > send(Messages::NetworkProcess::ProcessDidTransitionToForeground(), 0); >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >index 5fc62f0d5bd088e676ae2704668a37b9eb7f02d4..b07e6db72eb2172f8225c34a2ea29675a6f443ff 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >@@ -147,6 +147,9 @@ public: > void didDestroyWebUserContentControllerProxy(WebUserContentControllerProxy&); > #endif > >+ void dumpAdClickAttribution(PAL::SessionID, CompletionHandler<void(const String&)>&&); >+ void clearAdClickAttribution(PAL::SessionID, CompletionHandler<void()>&&); >+ > void addSession(Ref<WebsiteDataStore>&&); > void removeSession(PAL::SessionID); > >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 779264de72a590adff347983f18dcddafccbd656..72eb59c3a546699fa3f523ff43caedb035e1a952 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -129,6 +129,7 @@ > #include "WebURLSchemeHandler.h" > #include "WebUserContentControllerProxy.h" > #include "WebsiteDataStore.h" >+#include <WebCore/AdClickAttribution.h> > #include <WebCore/BitmapImage.h> > #include <WebCore/DeprecatedGlobalSettings.h> > #include <WebCore/DiagnosticLoggingClient.h> >@@ -4100,8 +4101,13 @@ void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navi > > // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache. > RefPtr<API::Navigation> navigation; >- if (frame->isMainFrame() && navigationID) >+ if (frame->isMainFrame() && navigationID) { > navigation = navigationState().navigation(navigationID); >+ if (auto adClickAttribution = navigation->adClickAttribution()) { >+ if (adClickAttribution->matchesDestination(frame->url())) >+ m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::StoreAdClickAttribution(m_websiteDataStore->sessionID(), *adClickAttribution)); >+ } >+ } > > if (frame->isMainFrame()) > m_navigationClient->didFinishDocumentLoad(*this, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get()); >@@ -8637,6 +8643,16 @@ void WebPageProxy::removeDataDetectedLinks(CompletionHandler<void(const DataDete > > #endif > >+void WebPageProxy::dumpAdClickAttribution(CompletionHandler<void(const String&)>&& completionHandler) >+{ >+ m_process->processPool().dumpAdClickAttribution(m_websiteDataStore->sessionID(), WTFMove(completionHandler)); >+} >+ >+void WebPageProxy::clearAdClickAttribution(CompletionHandler<void()>&& completionHandler) >+{ >+ m_process->processPool().clearAdClickAttribution(m_websiteDataStore->sessionID(), WTFMove(completionHandler)); >+} >+ > } // namespace WebKit > > #undef MERGE_WHEEL_EVENTS >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index d384cd7c03480d85860b1c58e37f5f22a44e8ac3..2206beb687e73932beabd34595912452cda35c4d 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1454,6 +1454,9 @@ public: > void loadRequestWithNavigationShared(Ref<WebProcessProxy>&&, API::Navigation&, WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& = WTF::nullopt); > void backForwardGoToItemShared(Ref<WebProcessProxy>&&, const WebCore::BackForwardItemIdentifier&, SandboxExtension::Handle&); > >+ void dumpAdClickAttribution(CompletionHandler<void(const String&)>&&); >+ void clearAdClickAttribution(CompletionHandler<void()>&&); >+ > // IPC::MessageReceiver > // Implemented in generated WebPageProxyMessageReceiver.cpp > void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; >diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp >index b1e1fe769cdd59dd817c75ef1b7253a5320e0112..c9de7fb541b00a5a30928ae4999de6b5a55c8405 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.cpp >+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp >@@ -2384,4 +2384,24 @@ void WebProcessPool::clearCurrentModifierStateForTesting() > sendToAllProcesses(Messages::WebProcess::ClearCurrentModifierStateForTesting()); > } > >+void WebProcessPool::dumpAdClickAttribution(PAL::SessionID sessionID, CompletionHandler<void(const String&)>&& completionHandler) >+{ >+ if (!m_networkProcess) { >+ completionHandler(emptyString()); >+ return; >+ } >+ >+ m_networkProcess->dumpAdClickAttribution(sessionID, WTFMove(completionHandler)); >+} >+ >+void WebProcessPool::clearAdClickAttribution(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!m_networkProcess) { >+ completionHandler(); >+ return; >+ } >+ >+ m_networkProcess->clearAdClickAttribution(sessionID, WTFMove(completionHandler)); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/WebProcessPool.h b/Source/WebKit/UIProcess/WebProcessPool.h >index a86edd8243d5be286a07dba70a7619f8d5307e1b..e574e1d7a62c4d7ecf3083d2f8330d98137e5fcd 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.h >+++ b/Source/WebKit/UIProcess/WebProcessPool.h >@@ -479,6 +479,9 @@ public: > void sendDisplayConfigurationChangedMessageForTesting(); > void clearCurrentModifierStateForTesting(); > >+ void dumpAdClickAttribution(PAL::SessionID, CompletionHandler<void(const String&)>&&); >+ void clearAdClickAttribution(PAL::SessionID, CompletionHandler<void()>&&); >+ > #if PLATFORM(GTK) || PLATFORM(WPE) > void setSandboxEnabled(bool enabled) { m_sandboxEnabled = enabled; }; > void addSandboxPath(const CString& path, SandboxPermission permission) { m_extraSandboxPaths.add(path, permission); }; >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index a8a6e9f9eafba0378e074d1097bff5dee4235d1c..7d01d6e55b937a2cf19cf9510851287c42881db6 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -1099,6 +1099,7 @@ > 63C32C281E98119000699BD0 /* _WKGeolocationPositionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 63C32C271E98119000699BD0 /* _WKGeolocationPositionInternal.h */; }; > 65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 6A5080BF1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A5080BE1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 6BD05865220CE8C2000BED5C /* NetworkAdClickAttribution.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BD05863220CE8C2000BED5C /* NetworkAdClickAttribution.h */; }; > 6BE969C11E54D452008B7483 /* corePrediction_model in Resources */ = {isa = PBXBuildFile; fileRef = 6BE969C01E54D452008B7483 /* corePrediction_model */; }; > 6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */; }; > 6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h */; }; >@@ -3515,6 +3516,8 @@ > 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = "<group>"; }; > 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; }; > 6A5080BE1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWindowFeaturesPrivate.h; sourceTree = "<group>"; }; >+ 6BD05863220CE8C2000BED5C /* NetworkAdClickAttribution.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetworkAdClickAttribution.h; sourceTree = "<group>"; }; >+ 6BD05864220CE8C2000BED5C /* NetworkAdClickAttribution.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkAdClickAttribution.cpp; sourceTree = "<group>"; }; > 6BE969C01E54D452008B7483 /* corePrediction_model */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = corePrediction_model; sourceTree = "<group>"; }; > 6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifier.cpp; sourceTree = "<group>"; }; > 6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifierCocoa.cpp; sourceTree = "<group>"; }; >@@ -6433,6 +6436,8 @@ > 413075971DE84ED70039EC69 /* webrtc */, > 53F3CAA5206C443E0086490E /* NetworkActivityTracker.cpp */, > 535BCB902069C49C00CCCE02 /* NetworkActivityTracker.h */, >+ 6BD05864220CE8C2000BED5C /* NetworkAdClickAttribution.cpp */, >+ 6BD05863220CE8C2000BED5C /* NetworkAdClickAttribution.h */, > 513A16491630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp */, > 513A164A1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h */, > 513A164B1630A9BF005D7D22 /* NetworkConnectionToWebProcess.messages.in */, >@@ -9164,6 +9169,7 @@ > 1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */, > 1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */, > 535BCB922069C49C00CCCE02 /* NetworkActivityTracker.h in Headers */, >+ 6BD05865220CE8C2000BED5C /* NetworkAdClickAttribution.h in Headers */, > A105D0D1212734B20034F6C7 /* NetworkBlobRegistry.h in Headers */, > E4436ECC1A0D040B00EAD204 /* NetworkCache.h in Headers */, > E49D40D71AD3FB170066B7B9 /* NetworkCacheBlobStorage.h in Headers */, >@@ -10789,6 +10795,7 @@ > 2D913444212CF9F000128AFD /* NetscapePlugin.cpp in Sources */, > 2D92A796212B6ADA00F493FD /* NetscapePluginModule.cpp in Sources */, > 2D913445212CF9F000128AFD /* NetscapePluginStream.cpp in Sources */, >+ 6BD05866220CE8C2000BED5C /* NetworkAdClickAttribution.cpp in Sources */, > 51DD9F2816367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp in Sources */, > 52F060E11654318500F3281B /* NetworkContentRuleListManagerMessageReceiver.cpp in Sources */, > 51F060E11654318500F3283F /* NetworkMDNSRegisterMessageReceiver.cpp in Sources */, >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >index 938caddbf6c57296b29167e05776c851e9646004..8f611d2396a00ea4b9f68b7a5a9ec16a289f9d74 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >@@ -882,6 +882,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat > navigationActionData.targetBackForwardItemIdentifier = navigationAction.targetBackForwardItemIdentifier(); > navigationActionData.lockHistory = navigationAction.lockHistory(); > navigationActionData.lockBackForwardList = navigationAction.lockBackForwardList(); >+ navigationActionData.adClickAttribution = navigationAction.adClickAttribution(); > > WebCore::Frame* coreFrame = m_frame->coreFrame(); > if (!coreFrame) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 26456d168ee7df5133a320929e08d7f16adec7dd..4e506136bf1771cb1307da98faad3bdd95d35eda 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,38 @@ >+2019-02-11 John Wilander <wilander@apple.com> >+ >+ Store Ad Click Attribution requests in the network process >+ https://bugs.webkit.org/show_bug.cgi?id=194510 >+ <rdar://problem/47650118> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch adds two TestRunner functions: >+ - dumpAdClickAttribution() >+ - clearAdClickAttribution() >+ >+ They call into the network process to dump and clear Ad Click >+ Attribution state, respectively. >+ >+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: >+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp: >+ (WTR::TestRunner::dumpAdClickAttribution): >+ (WTR::TestRunner::clearAdClickAttribution): >+ * WebKitTestRunner/InjectedBundle/TestRunner.h: >+ * WebKitTestRunner/TestController.cpp: >+ (WTR::TestController::resetStateToConsistentValues): >+ (WTR::AdClickAttributionStringResultCallbackContext::AdClickAttributionStringResultCallbackContext): >+ (WTR::adClickAttributionStringResultCallback): >+ (WTR::TestController::dumpAdClickAttribution): >+ (WTR::AdClickAttributionVoidCallbackContext::AdClickAttributionVoidCallbackContext): >+ (WTR::adClickAttributionVoidCallback): >+ (WTR::TestController::clearAdClickAttribution): >+ * WebKitTestRunner/TestController.h: >+ * WebKitTestRunner/TestInvocation.cpp: >+ (WTR::TestInvocation::dumpResults): >+ (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): >+ (WTR::TestInvocation::dumpAdClickAttribution): >+ * WebKitTestRunner/TestInvocation.h: >+ > 2019-02-09 Benjamin Poulain <benjamin@webkit.org> > > Add more tests for clampTo<>() >diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >index dabe19c22f7f564ea3b44fb7cff4a721f964d962..3721ed95ff0ef6d1c603416dcb3224ab00ae3878 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >+++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >@@ -57,6 +57,7 @@ interface TestRunner { > void dumpDOMAsWebArchive(); > void dumpPolicyDelegateCallbacks(); > void dumpResourceLoadStatistics(); >+ void dumpAdClickAttribution(); > > void clearDOMCaches(); > void clearDOMCache(DOMString origin); >@@ -371,4 +372,7 @@ interface TestRunner { > void addTestKeyToKeychain(DOMString privateKeyBase64, DOMString attrLabel, DOMString applicationTagBase64); > void cleanUpKeychain(DOMString attrLabel); > boolean keyExistsInKeychain(DOMString attrLabel, DOMString applicationTagBase64); >+ >+ // Ad Click Attribution >+ void clearAdClickAttribution(); > }; >diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >index 3df7e54f9e31260fda5a15f8dc1805a74474671d..a18a81fed3ee835cb34b7507afef7d2250c28d9d 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >@@ -2730,4 +2730,16 @@ void TestRunner::setShouldDismissJavaScriptAlertsAsynchronously(bool shouldDismi > WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); > } > >+void TestRunner::dumpAdClickAttribution() >+{ >+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("dumpAdClickAttribution")); >+ WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), nullptr, nullptr); >+} >+ >+void TestRunner::clearAdClickAttribution() >+{ >+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("clearAdClickAttribution")); >+ WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), nullptr, nullptr); >+} >+ > } // namespace WTR >diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >index e3b0c26bb258426b5bf88e5f1a3420ae1008166e..dfd7e902da5961af6372e0a5b3f923b0c5cacbde 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >@@ -489,6 +489,10 @@ public: > bool canDoServerTrustEvaluationInNetworkProcess(); > unsigned long serverTrustEvaluationCallbackCallsCount(); > >+ // Ad Click Attribution. >+ void dumpAdClickAttribution(); >+ void clearAdClickAttribution(); >+ > private: > TestRunner(); > >diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp >index 4cc4cccc0f023876de4a00dab367ec8c681ac29b..50b78a32aaaee7bdb183264bbcd0108084f66c5b 100644 >--- a/Tools/WebKitTestRunner/TestController.cpp >+++ b/Tools/WebKitTestRunner/TestController.cpp >@@ -963,6 +963,8 @@ bool TestController::resetStateToConsistentValues(const TestOptions& options, Re > m_openPanelFileURLs = nullptr; > > statisticsResetToConsistentState(); >+ >+ clearAdClickAttribution(); > > m_didReceiveServerRedirectForProvisionalNavigation = false; > m_serverTrustEvaluationCallbackCallsCount = 0; >@@ -3283,4 +3285,55 @@ void TestController::setWebAuthenticationMockConfiguration(WKDictionaryRef confi > WKWebsiteDataStoreSetWebAuthenticationMockConfiguration(WKContextGetWebsiteDataStore(platformContext()), configuration); > } > >+struct AdClickAttributionStringResultCallbackContext { >+ explicit AdClickAttributionStringResultCallbackContext(TestController& controller) >+ : testController(controller) >+ { >+ } >+ >+ TestController& testController; >+ bool done { false }; >+ WKRetainPtr<WKStringRef> adClickAttributionRepresentation; >+}; >+ >+static void adClickAttributionStringResultCallback(WKStringRef adClickAttributionRepresentation, void* userData) >+{ >+ auto* context = static_cast<AdClickAttributionStringResultCallbackContext*>(userData); >+ context->adClickAttributionRepresentation = adClickAttributionRepresentation; >+ context->done = true; >+ context->testController.notifyDone(); >+} >+ >+String TestController::dumpAdClickAttribution() >+{ >+ AdClickAttributionStringResultCallbackContext callbackContext(*this); >+ WKPageDumpAdClickAttribution(m_mainWebView->page(), adClickAttributionStringResultCallback, &callbackContext); >+ runUntil(callbackContext.done, noTimeout); >+ return toWTFString(callbackContext.adClickAttributionRepresentation.get()); >+} >+ >+struct AdClickAttributionVoidCallbackContext { >+ explicit AdClickAttributionVoidCallbackContext(TestController& controller) >+ : testController(controller) >+ { >+ } >+ >+ TestController& testController; >+ bool done { false }; >+}; >+ >+static void adClickAttributionVoidCallback(void* userData) >+{ >+ auto* context = static_cast<AdClickAttributionVoidCallbackContext*>(userData); >+ context->done = true; >+ context->testController.notifyDone(); >+} >+ >+void TestController::clearAdClickAttribution() >+{ >+ AdClickAttributionVoidCallbackContext callbackContext(*this); >+ WKPageClearAdClickAttribution(m_mainWebView->page(), adClickAttributionVoidCallback, &callbackContext); >+ runUntil(callbackContext.done, noTimeout); >+} >+ > } // namespace WTR >diff --git a/Tools/WebKitTestRunner/TestController.h b/Tools/WebKitTestRunner/TestController.h >index 705c17560d8c84761c55671316614f1c20a55fc6..184ee20b7ba7be4e4f13b31e73c3273c9c7440da 100644 >--- a/Tools/WebKitTestRunner/TestController.h >+++ b/Tools/WebKitTestRunner/TestController.h >@@ -289,6 +289,9 @@ public: > > bool isDoingMediaCapture() const; > >+ String dumpAdClickAttribution(); >+ void clearAdClickAttribution(); >+ > private: > WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef); > WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration(const TestOptions&) const; >diff --git a/Tools/WebKitTestRunner/TestInvocation.cpp b/Tools/WebKitTestRunner/TestInvocation.cpp >index 7af33b2219cf88f2a6fd8563f8337bcad092053f..7e79f0bb34f44e64fbad57325e31923662fd0f4b 100644 >--- a/Tools/WebKitTestRunner/TestInvocation.cpp >+++ b/Tools/WebKitTestRunner/TestInvocation.cpp >@@ -259,6 +259,11 @@ void TestInvocation::dumpResults() > if (m_shouldDumpResourceLoadStatistics) > m_textOutput.append(m_savedResourceLoadStatistics.isNull() ? TestController::singleton().dumpResourceLoadStatistics() : m_savedResourceLoadStatistics); > >+ if (m_shouldDumpAdClickAttribution) { >+ auto output = m_savedAdClickAttribution.isNull() ? TestController::singleton().dumpAdClickAttribution() : m_savedAdClickAttribution; >+ m_textOutput.append(output); >+ } >+ > if (m_textOutput.length() || !m_audioResult) > dump(m_textOutput.toString().utf8().data()); > else >@@ -1550,6 +1555,16 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB > return nullptr; > } > >+ if (WKStringIsEqualToUTF8CString(messageName, "dumpAdClickAttribution")) { >+ dumpAdClickAttribution(); >+ return nullptr; >+ } >+ >+ if (WKStringIsEqualToUTF8CString(messageName, "clearAdClickAttribution")) { >+ TestController::singleton().clearAdClickAttribution(); >+ return nullptr; >+ } >+ > ASSERT_NOT_REACHED(); > return nullptr; > } >@@ -1700,4 +1715,9 @@ void TestInvocation::dumpResourceLoadStatistics() > m_shouldDumpResourceLoadStatistics = true; > } > >+void TestInvocation::dumpAdClickAttribution() >+{ >+ m_shouldDumpAdClickAttribution = true; >+} >+ > } // namespace WTR >diff --git a/Tools/WebKitTestRunner/TestInvocation.h b/Tools/WebKitTestRunner/TestInvocation.h >index fe1789765268931fbc2056a14f8d1f12bc7f9650..2cb7f8aba0b519d2b0a091e73879bd243c454f19 100644 >--- a/Tools/WebKitTestRunner/TestInvocation.h >+++ b/Tools/WebKitTestRunner/TestInvocation.h >@@ -86,7 +86,9 @@ public: > void dumpResourceLoadStatistics(); > > bool canOpenWindows() const { return m_canOpenWindows; } >- >+ >+ void dumpAdClickAttribution(); >+ > private: > WKRetainPtr<WKMutableDictionaryRef> createTestSettingsDictionary(); > >@@ -135,6 +137,7 @@ private: > bool m_pixelResultIsPending { false }; > bool m_shouldDumpResourceLoadStatistics { false }; > bool m_canOpenWindows { false }; >+ bool m_shouldDumpAdClickAttribution { false }; > WhatToDump m_whatToDump { WhatToDump::RenderTree }; > > StringBuilder m_textOutput; >@@ -142,7 +145,8 @@ private: > WKRetainPtr<WKDataRef> m_audioResult; > WKRetainPtr<WKImageRef> m_pixelResult; > WKRetainPtr<WKArrayRef> m_repaintRects; >- >+ String m_savedAdClickAttribution; >+ > std::unique_ptr<UIScriptContext> m_UIScriptContext; > UIScriptInvocationData* m_pendingUIScriptInvocationData { nullptr }; > }; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index b793e2c2adc3304a80a6454d752ff45c077128bc..7dbe2b2b4fe453c7ddd2878b77f34685511967bc 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2019-02-11 John Wilander <wilander@apple.com> >+ >+ Store Ad Click Attribution requests in the network process >+ https://bugs.webkit.org/show_bug.cgi?id=194510 >+ <rdar://problem/47650118> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * http/tests/adClickAttribution/store-ad-click-attribution-expected.txt: Added. >+ * http/tests/adClickAttribution/store-ad-click-attribution.html: Added. >+ > 2019-02-10 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r241167. >diff --git a/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution-expected.txt b/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..c21da044cd086954583c9df336ea44de6fa00dfb >--- /dev/null >+++ b/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution-expected.txt >@@ -0,0 +1,14 @@ >+Test storage of ad click attribution. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+Link >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >+WebCore::AdClickAttribution 1 >+Source: 127.0.0.1 >+Destination: localhost >+Campaign ID: 3 >+No conversion data. >diff --git a/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html b/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html >new file mode 100644 >index 0000000000000000000000000000000000000000..ed7de0cedb7ed5ead7472e9dfc0d08dd579c99cd >--- /dev/null >+++ b/LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html >@@ -0,0 +1,43 @@ >+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true, internal:AdClickAttributionEnabled=true ] --> >+<html lang="en"> >+<head> >+ <meta charset="UTF-8"> >+ <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> >+ <script src="/js-test-resources/js-test.js"></script> >+ <script src="/js-test-resources/ui-helper.js"></script> >+</head> >+<body onload="setTimeout(runTest, 0)"> >+<div id="description"></div> >+<a id="targetLink" href="http://localhost:8000/adClickAttribution/store-ad-click-attribution.html?stepTwo" adcampaignid="3" addestination="http://localhost:8000">Link</a><br> >+<div id="console"></div> >+<script> >+ description("Test storage of ad click attribution."); >+ jsTestIsAsync = true; >+ >+ function activateElement(elementID) { >+ var element = document.getElementById(elementID); >+ var centerX = element.offsetLeft + element.offsetWidth / 2; >+ var centerY = element.offsetTop + element.offsetHeight / 2; >+ UIHelper.activateAt(centerX, centerY).then( >+ function () { >+ }, >+ function () { >+ testFailed("Promise rejected."); >+ finishJSTest(); >+ } >+ ); >+ } >+ >+ function runTest() { >+ if (window.location.search === "?stepTwo") { >+ if (testRunner) { >+ testRunner.dumpAdClickAttribution(); >+ } >+ finishJSTest(); >+ } else { >+ activateElement("targetLink"); >+ } >+ } >+</script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194510
:
361703
|
361708
|
361713
|
361876
|
361922
|
361931