Store Ad Click Attribution requests in the network process
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 20:47:00 +0000 (20:47 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 20:47:00 +0000 (20:47 +0000)
commit557c8e55b46341768e8db2eabbc9d415fe892219
tree2bb1afa89b5fd57db25aa3f53f7f607110104126
parent3a6f724c65c5f1786b3708a584f154c79706465a
Store Ad Click Attribution requests in the network process
https://bugs.webkit.org/show_bug.cgi?id=194510
<rdar://problem/47650118>

Reviewed by Alex Christensen and Daniel Bates.

Source/WebCore:

Test: http/tests/adClickAttribution/store-ad-click-attribution.html

This patch adds support functions for validation and storage of
WebCore::AdClickAttribution objects. It also adds WTF::HashTraits so that
WebCore::AdClickAttribution::Source and WebCore::AdClickAttribution::Destination
can be used in a HashMap.

* loader/AdClickAttribution.cpp:
(WebCore::AdClickAttribution::toString const):
* loader/AdClickAttribution.h:
(WebCore::AdClickAttribution::Source::operator== const):
(WebCore::AdClickAttribution::Source::deletedValue):
(WebCore::AdClickAttribution::Source::constructDeletedValue):
(WebCore::AdClickAttribution::Source::deleteValue):
(WebCore::AdClickAttribution::Source::isDeletedValue const):
(WebCore::AdClickAttribution::SourceHash::hash):
(WebCore::AdClickAttribution::SourceHash::equal):
(WebCore::AdClickAttribution::Destination::operator== const):
(WebCore::AdClickAttribution::Destination::matches const):
    This convenience function allows matching of a WTF::URL object.
(WebCore::AdClickAttribution::Destination::deletedValue):
(WebCore::AdClickAttribution::Destination::constructDeletedValue):
(WebCore::AdClickAttribution::Destination::deleteValue):
(WebCore::AdClickAttribution::Destination::isDeletedValue const):
(WebCore::AdClickAttribution::DestinationHash::hash):
(WebCore::AdClickAttribution::DestinationHash::equal):
(WebCore::AdClickAttribution::source const):
(WebCore::AdClickAttribution::destination const):
    Getters added to support mapped storage based on source and destination.
(WTF::HashTraits<WebCore::AdClickAttribution::Source>::emptyValue):
(WTF::HashTraits<WebCore::AdClickAttribution::Source>::constructDeletedValue):
(WTF::HashTraits<WebCore::AdClickAttribution::Source>::isDeletedValue):
(WTF::HashTraits<WebCore::AdClickAttribution::Destination>::emptyValue):
(WTF::HashTraits<WebCore::AdClickAttribution::Destination>::constructDeletedValue):
(WTF::HashTraits<WebCore::AdClickAttribution::Destination>::isDeletedValue):
* loader/NavigationAction.h:
(WebCore::NavigationAction::adClickAttribution const):
(WebCore::NavigationAction::adClickAttribution): Deleted.
    Corrected the constness of this function.

Source/WebKit:

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/Downloads/DownloadManager.cpp:
    Added missing header include.
* NetworkProcess/NetworkAdClickAttribution.cpp: Added.
(WebKit::NetworkAdClickAttribution::ensureDestinationMapForSource):
(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:
* NetworkProcess/soup/RemoteNetworkingContextSoup.cpp:
    Added missing header include.
* Sources.txt:
    Added NetworkProcess/NetworkAdClickAttribution.cpp.
* 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.

Tools:

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:

LayoutTests:

* TestExpectations:
    Marked "Skip" because the feature is not applicable to WK1.
* http/tests/adClickAttribution/store-ad-click-attribution-expected.txt: Added.
* http/tests/adClickAttribution/store-ad-click-attribution.html: Added.
* platform/wk2/TestExpectations:
    Marked "Pass."

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241451 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/store-ad-click-attribution.html [new file with mode: 0644]
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/loader/AdClickAttribution.cpp
Source/WebCore/loader/AdClickAttribution.h
Source/WebCore/loader/NavigationAction.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp
Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp
Source/WebKit/NetworkProcess/NetworkAdClickAttribution.cpp [new file with mode: 0644]
Source/WebKit/NetworkProcess/NetworkAdClickAttribution.h [new file with mode: 0644]
Source/WebKit/NetworkProcess/NetworkLoad.cpp
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/NetworkProcess/NetworkSession.cpp
Source/WebKit/NetworkProcess/NetworkSession.h
Source/WebKit/NetworkProcess/soup/RemoteNetworkingContextSoup.cpp
Source/WebKit/Sources.txt
Source/WebKit/UIProcess/API/APINavigation.h
Source/WebKit/UIProcess/API/C/WKPage.cpp
Source/WebKit/UIProcess/API/C/WKPagePrivate.h
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/TestInvocation.h