[WK2] Add API to query if a download was user-initiated
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 21:28:01 +0000 (21:28 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 21:28:01 +0000 (21:28 +0000)
commit251ff840c6eee4b0eb61c16ef231075c2f9ea4ca
tree9f03d712b9b2bf34587f89c6afd4459fe371ac08
parentc79512da49d4a7df4cd3ae98307b9239a0b68d5f
[WK2] Add API to query if a download was user-initiated
https://bugs.webkit.org/show_bug.cgi?id=177435
<rdar://problem/34498422>

Reviewed by Alex Christensen.

Source/WebKit:

Add C and Cocoa private API to query if a download was user-initiated.

For clarity, we now construct navigation object for subframe loads
as well (we used to do so only for main frame loads). This allows us
to store the user-intiated flag and the redirect chain on the navigation
object instead of the WebFrameProxy.

* UIProcess/API/APINavigation.cpp:
(API::Navigation::Navigation):
(API::Navigation::appendRedirectionURL):
* UIProcess/API/APINavigation.h:
(API::Navigation::takeRedirectChain):
(API::Navigation::setWasUserInitiated):
(API::Navigation::wasUserInitiated const):
* UIProcess/API/C/WKDownload.cpp:
(WKDownloadGetWasUserInitiated):
* UIProcess/API/C/WKDownload.h:
* UIProcess/API/Cocoa/_WKDownload.h:
* UIProcess/API/Cocoa/_WKDownload.mm:
(-[_WKDownload wasUserInitiated]):
* UIProcess/Downloads/DownloadProxy.h:
(WebKit::DownloadProxy::setWasUserInitiated):
(WebKit::DownloadProxy::wasUserInitiated const):
* UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::didStartProvisionalLoad):
(WebKit::WebFrameProxy::didReceiveServerRedirectForProvisionalLoad):
(WebKit::WebFrameProxy::didFailProvisionalLoad):
(WebKit::WebFrameProxy::didFinishLoad):
(WebKit::WebFrameProxy::didFailLoad):
* UIProcess/WebFrameProxy.h:
(WebKit::WebFrameProxy::title const):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::decidePolicyForResponse):
(WebKit::WebPageProxy::decidePolicyForResponseSync):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKit/mac/ContextMenuDownload.mm:
(TestWebKitAPI::decideDestinationWithSuggestedFilename):
* TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
(-[DownloadDelegate _downloadDidStart:]):
(-[DownloadDelegate _downloadDidFinish:]):
(runTest):
(TEST):
(-[BlobDownloadDelegate _downloadDidStart:]):
(-[BlobDownloadDelegate _downloadDidFinish:]):
(-[RedirectedDownloadDelegate _downloadDidStart:]):
(-[RedirectedDownloadDelegate _downloadDidFinish:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/APINavigation.cpp
Source/WebKit/UIProcess/API/APINavigation.h
Source/WebKit/UIProcess/API/C/WKDownload.cpp
Source/WebKit/UIProcess/API/C/WKDownload.h
Source/WebKit/UIProcess/API/Cocoa/_WKDownload.h
Source/WebKit/UIProcess/API/Cocoa/_WKDownload.mm
Source/WebKit/UIProcess/Downloads/DownloadProxy.h
Source/WebKit/UIProcess/WebFrameProxy.cpp
Source/WebKit/UIProcess/WebFrameProxy.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebPage/WebFrame.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit/mac/ContextMenuDownload.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm