WebKit Bugzilla
Attachment 357279 Details for
Bug 192683
: Add a class to bundle download configuration parameters together
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch v2.1
file_192683.txt (text/plain), 84.61 KB, created by
David Quesada
on 2018-12-13 18:01:59 PST
(
hide
)
Description:
Patch v2.1
Filename:
MIME Type:
Creator:
David Quesada
Created:
2018-12-13 18:01:59 PST
Size:
84.61 KB
patch
obsolete
>commit 97c47dba38eed74a009f146a09181dab11550d67 >Author: David Quesada <david_quesada@apple.com> >Date: Thu Dec 13 16:22:28 2018 -0800 > > Add a class to bundle download configuration parameters together > https://bugs.webkit.org/show_bug.cgi?id=192683 > rdar://problem/46711066 > > Reviewed by NOBODY (OOPS!). > > Source/WebKit: > > Introduce WebKit::DownloadConfiguration, a structure to hold the pieces of download-related > configuration - the destination path, a corresponding sandbox extension, and an "allow > overwrite" flag. To support potential use cases where certain aspects of the execution of > a download may be configurable, additional parameters could be included in this structure > and used where appropriate. This will require fewer tedious code changes than it would to > conditionally include the parameters as function arguments and class members everywhere > the three current pieces of configuration are passed around and stored. Methods related to > "deciding the destination" for a download has been renamed to reflect "deciding the > configuration" for the download, since they now work with DownloadConfiguration. > > This structure is exposed in Cocoa API by the _WKDownloadConfiguration class (and related > _WKDownloadDelegate and WKProcessPool methods that work with this class). It doesn't yet > expose any additional API beyond the destination path and allowOverwrite flag. This patch > is just setup to do so. > > * NetworkProcess/Downloads/Download.cpp: > (WebKit::Download::Download): > * NetworkProcess/Downloads/Download.h: > (WebKit::Download::Download): > * NetworkProcess/Downloads/DownloadManager.cpp: > (WebKit::DownloadManager::continueDecidePendingDownloadConfiguration): > (WebKit::DownloadManager::resumeDownload): > * NetworkProcess/Downloads/DownloadManager.h: > * NetworkProcess/Downloads/cocoa/DownloadCocoa.mm: > (WebKit::Download::resume): > * NetworkProcess/NetworkDataTask.h: > (WebKit::NetworkDataTask::setPendingDownloadConfiguration): > (WebKit::NetworkDataTask::downloadConfiguration): > * NetworkProcess/NetworkDataTaskBlob.cpp: > (WebKit::NetworkDataTaskBlob::setPendingDownloadConfiguration): > * NetworkProcess/NetworkDataTaskBlob.h: > * NetworkProcess/NetworkProcess.cpp: > (WebKit::NetworkProcess::resumeDownload): > (WebKit::NetworkProcess::findPendingDownloadLocation): > (WebKit::NetworkProcess::continueDecidePendingDownloadConfiguration): > * NetworkProcess/NetworkProcess.h: > * NetworkProcess/NetworkProcess.messages.in: > * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: > * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: > (WebKit::NetworkDataTaskCocoa::setPendingDownloadConfiguration): > * NetworkProcess/cocoa/NetworkSessionCocoa.mm: > (-[WKNetworkSessionDelegate URLSession:dataTask:didBecomeDownloadTask:]): > * NetworkProcess/soup/NetworkDataTaskSoup.cpp: > (WebKit::NetworkDataTaskSoup::setPendingDownloadConfiguration): > (WebKit::NetworkDataTaskSoup::setPendingDownloadLocation): Deleted. > * NetworkProcess/soup/NetworkDataTaskSoup.h: > * Shared/DownloadConfiguration.cpp: Added. > (WebKit::DownloadConfiguration::encode const): > (WebKit::DownloadConfiguration::decode): > * Shared/DownloadConfiguration.h: Added. > (WebKit::DownloadConfiguration::DownloadConfiguration): > * Sources.txt: > * SourcesCocoa.txt: > * UIProcess/API/APIDownloadClient.h: > (API::DownloadClient::decideConfigurationWithSuggestedFilename): > * UIProcess/API/C/WKContext.cpp: > (WKContextSetDownloadClient): > (WKContextResumeDownload): > * UIProcess/API/Cocoa/WKProcessPool.mm: > (-[WKProcessPool _resumeDownloadFromData:path:originatingWebView:]): > (-[WKProcessPool _resumeDownloadFromData:originatingWebView:configuration:]): > * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: > * UIProcess/API/Cocoa/_WKDownloadConfiguration.h: Added. > * UIProcess/API/Cocoa/_WKDownloadConfiguration.mm: Added. > (checkURLArgument): > (-[_WKDownloadConfiguration destination]): > (-[_WKDownloadConfiguration setDestination:]): > (-[_WKDownloadConfiguration _downloadConfiguration]): > * UIProcess/API/Cocoa/_WKDownloadConfigurationInternal.h: Added. > * UIProcess/API/Cocoa/_WKDownloadDelegate.h: > * UIProcess/API/glib/WebKitDownloadClient.cpp: > * UIProcess/Cocoa/DownloadClient.h: > * UIProcess/Cocoa/DownloadClient.mm: > (WebKit::DownloadClient::DownloadClient): > (WebKit::DownloadClient::decideConfigurationWithSuggestedFilename): > Consult the new _WKDownloadDelegate method that allows specifying a _WKDownloadConfiguration. > * UIProcess/Downloads/DownloadProxy.cpp: > (WebKit::DownloadProxy::decideConfigurationWithSuggestedFilenameAsync): > Drive-by fixup to r238381. Move the m_processPool nil-check to the top of the > completion handler. There's no point in creating a sandbox extension for the destination > file if we don't a process pool (therefore a network process) to send it to. > * UIProcess/Downloads/DownloadProxy.h: > * UIProcess/Downloads/DownloadProxy.messages.in: > * UIProcess/WebProcessPool.cpp: > (WebKit::WebProcessPool::resumeDownload): > * UIProcess/WebProcessPool.h: > * WebKit.xcodeproj/project.pbxproj: > > Tools: > > * TestWebKitAPI/Tests/WebKitCocoa/Download.mm: > (-[ConfigurationDecidingDownloadDelegate _download:decideConfigurationWithSuggestedFilename:completionHandler:]): > (-[ConfigurationDecidingDownloadDelegate _downloadDidFinish:]): > (TEST): > Add a simple API test for configuring a download via the _WKDownloadDelegate method > that asks for a _WKDownloadConfiguration. > >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index b538a9d67b0..2893cacd580 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,99 @@ >+2018-12-13 David Quesada <david_quesada@apple.com> >+ >+ Add a class to bundle download configuration parameters together >+ https://bugs.webkit.org/show_bug.cgi?id=192683 >+ rdar://problem/46711066 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Introduce WebKit::DownloadConfiguration, a structure to hold the pieces of download-related >+ configuration - the destination path, a corresponding sandbox extension, and an "allow >+ overwrite" flag. To support potential use cases where certain aspects of the execution of >+ a download may be configurable, additional parameters could be included in this structure >+ and used where appropriate. This will require fewer tedious code changes than it would to >+ conditionally include the parameters as function arguments and class members everywhere >+ the three current pieces of configuration are passed around and stored. Methods related to >+ "deciding the destination" for a download has been renamed to reflect "deciding the >+ configuration" for the download, since they now work with DownloadConfiguration. >+ >+ This structure is exposed in Cocoa API by the _WKDownloadConfiguration class (and related >+ _WKDownloadDelegate and WKProcessPool methods that work with this class). It doesn't yet >+ expose any additional API beyond the destination path and allowOverwrite flag. This patch >+ is just setup to do so. >+ >+ * NetworkProcess/Downloads/Download.cpp: >+ (WebKit::Download::Download): >+ * NetworkProcess/Downloads/Download.h: >+ (WebKit::Download::Download): >+ * NetworkProcess/Downloads/DownloadManager.cpp: >+ (WebKit::DownloadManager::continueDecidePendingDownloadConfiguration): >+ (WebKit::DownloadManager::resumeDownload): >+ * NetworkProcess/Downloads/DownloadManager.h: >+ * NetworkProcess/Downloads/cocoa/DownloadCocoa.mm: >+ (WebKit::Download::resume): >+ * NetworkProcess/NetworkDataTask.h: >+ (WebKit::NetworkDataTask::setPendingDownloadConfiguration): >+ (WebKit::NetworkDataTask::downloadConfiguration): >+ * NetworkProcess/NetworkDataTaskBlob.cpp: >+ (WebKit::NetworkDataTaskBlob::setPendingDownloadConfiguration): >+ * NetworkProcess/NetworkDataTaskBlob.h: >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::resumeDownload): >+ (WebKit::NetworkProcess::findPendingDownloadLocation): >+ (WebKit::NetworkProcess::continueDecidePendingDownloadConfiguration): >+ * NetworkProcess/NetworkProcess.h: >+ * NetworkProcess/NetworkProcess.messages.in: >+ * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: >+ * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: >+ (WebKit::NetworkDataTaskCocoa::setPendingDownloadConfiguration): >+ * NetworkProcess/cocoa/NetworkSessionCocoa.mm: >+ (-[WKNetworkSessionDelegate URLSession:dataTask:didBecomeDownloadTask:]): >+ * NetworkProcess/soup/NetworkDataTaskSoup.cpp: >+ (WebKit::NetworkDataTaskSoup::setPendingDownloadConfiguration): >+ (WebKit::NetworkDataTaskSoup::setPendingDownloadLocation): Deleted. >+ * NetworkProcess/soup/NetworkDataTaskSoup.h: >+ * Shared/DownloadConfiguration.cpp: Added. >+ (WebKit::DownloadConfiguration::encode const): >+ (WebKit::DownloadConfiguration::decode): >+ * Shared/DownloadConfiguration.h: Added. >+ (WebKit::DownloadConfiguration::DownloadConfiguration): >+ * Sources.txt: >+ * SourcesCocoa.txt: >+ * UIProcess/API/APIDownloadClient.h: >+ (API::DownloadClient::decideConfigurationWithSuggestedFilename): >+ * UIProcess/API/C/WKContext.cpp: >+ (WKContextSetDownloadClient): >+ (WKContextResumeDownload): >+ * UIProcess/API/Cocoa/WKProcessPool.mm: >+ (-[WKProcessPool _resumeDownloadFromData:path:originatingWebView:]): >+ (-[WKProcessPool _resumeDownloadFromData:originatingWebView:configuration:]): >+ * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: >+ * UIProcess/API/Cocoa/_WKDownloadConfiguration.h: Added. >+ * UIProcess/API/Cocoa/_WKDownloadConfiguration.mm: Added. >+ (checkURLArgument): >+ (-[_WKDownloadConfiguration destination]): >+ (-[_WKDownloadConfiguration setDestination:]): >+ (-[_WKDownloadConfiguration _downloadConfiguration]): >+ * UIProcess/API/Cocoa/_WKDownloadConfigurationInternal.h: Added. >+ * UIProcess/API/Cocoa/_WKDownloadDelegate.h: >+ * UIProcess/API/glib/WebKitDownloadClient.cpp: >+ * UIProcess/Cocoa/DownloadClient.h: >+ * UIProcess/Cocoa/DownloadClient.mm: >+ (WebKit::DownloadClient::DownloadClient): >+ (WebKit::DownloadClient::decideConfigurationWithSuggestedFilename): >+ Consult the new _WKDownloadDelegate method that allows specifying a _WKDownloadConfiguration. >+ * UIProcess/Downloads/DownloadProxy.cpp: >+ (WebKit::DownloadProxy::decideConfigurationWithSuggestedFilenameAsync): >+ Drive-by fixup to r238381. Move the m_processPool nil-check to the top of the >+ completion handler. There's no point in creating a sandbox extension for the destination >+ file if we don't a process pool (therefore a network process) to send it to. >+ * UIProcess/Downloads/DownloadProxy.h: >+ * UIProcess/Downloads/DownloadProxy.messages.in: >+ * UIProcess/WebProcessPool.cpp: >+ (WebKit::WebProcessPool::resumeDownload): >+ * UIProcess/WebProcessPool.h: >+ * WebKit.xcodeproj/project.pbxproj: >+ > 2018-12-13 Chris Dumez <cdumez@apple.com> > > [PSON] We should not need to navigate to 'about:blank' to suspend pages >diff --git a/Source/WebKit/NetworkProcess/Downloads/Download.cpp b/Source/WebKit/NetworkProcess/Downloads/Download.cpp >index 177f9ba49c3..04428bd9355 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/Download.cpp >+++ b/Source/WebKit/NetworkProcess/Downloads/Download.cpp >@@ -49,9 +49,10 @@ > namespace WebKit { > using namespace WebCore; > >-Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NetworkDataTask& download, const PAL::SessionID& sessionID, const String& suggestedName) >+Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NetworkDataTask& download, const PAL::SessionID& sessionID, const String& suggestedName, DownloadConfiguration&& downloadConfiguration) > : m_downloadManager(downloadManager) > , m_downloadID(downloadID) >+ , m_downloadConfiguration(WTFMove(downloadConfiguration)) > , m_download(&download) > , m_sessionID(sessionID) > , m_suggestedName(suggestedName) >@@ -62,9 +63,10 @@ Download::Download(DownloadManager& downloadManager, DownloadID downloadID, Netw > } > > #if PLATFORM(COCOA) >-Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NSURLSessionDownloadTask* download, const PAL::SessionID& sessionID, const String& suggestedName) >+Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NSURLSessionDownloadTask* download, const PAL::SessionID& sessionID, const String& suggestedName, DownloadConfiguration&& downloadConfiguration) > : m_downloadManager(downloadManager) > , m_downloadID(downloadID) >+ , m_downloadConfiguration(WTFMove(downloadConfiguration)) > , m_downloadTask(download) > , m_sessionID(sessionID) > , m_suggestedName(suggestedName) >diff --git a/Source/WebKit/NetworkProcess/Downloads/Download.h b/Source/WebKit/NetworkProcess/Downloads/Download.h >index d8fbdd1d39d..1226f40231b 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/Download.h >+++ b/Source/WebKit/NetworkProcess/Downloads/Download.h >@@ -65,14 +65,14 @@ class WebPage; > class Download : public IPC::MessageSender { > WTF_MAKE_NONCOPYABLE(Download); WTF_MAKE_FAST_ALLOCATED; > public: >- Download(DownloadManager&, DownloadID, NetworkDataTask&, const PAL::SessionID& sessionID, const String& suggestedFilename = { }); >+ Download(DownloadManager&, DownloadID, NetworkDataTask&, const PAL::SessionID& sessionID, const String& suggestedFilename = { }, DownloadConfiguration&& = { }); > #if PLATFORM(COCOA) >- Download(DownloadManager&, DownloadID, NSURLSessionDownloadTask*, const PAL::SessionID& sessionID, const String& suggestedFilename = { }); >+ Download(DownloadManager&, DownloadID, NSURLSessionDownloadTask*, const PAL::SessionID& sessionID, const String& suggestedFilename = { }, DownloadConfiguration&& = { }); > #endif > > ~Download(); > >- void resume(const IPC::DataReference& resumeData, const String& path, SandboxExtension::Handle&&); >+ void resume(const IPC::DataReference& resumeData); > void cancel(); > #if PLATFORM(COCOA) > void publishProgress(const URL&, SandboxExtension::Handle&&); >@@ -101,6 +101,7 @@ private: > > DownloadManager& m_downloadManager; > DownloadID m_downloadID; >+ DownloadConfiguration m_downloadConfiguration; > > Vector<RefPtr<WebCore::BlobDataFileReference>> m_blobFileReferences; > RefPtr<SandboxExtension> m_sandboxExtension; >diff --git a/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp b/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp >index 72cd7e1fe71..c07155ba549 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp >+++ b/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp >@@ -95,7 +95,7 @@ void DownloadManager::convertNetworkLoadToDownload(DownloadID downloadID, std::u > m_pendingDownloads.add(downloadID, std::make_unique<PendingDownload>(WTFMove(networkLoad), WTFMove(completionHandler), downloadID, request, response)); > } > >-void DownloadManager::continueDecidePendingDownloadDestination(DownloadID downloadID, String destination, SandboxExtension::Handle&& sandboxExtensionHandle, bool allowOverwrite) >+void DownloadManager::continueDecidePendingDownloadConfiguration(DownloadID downloadID, DownloadConfiguration&& configuration) > { > if (m_downloadsWaitingForDestination.contains(downloadID)) { > auto pair = m_downloadsWaitingForDestination.take(downloadID); >@@ -105,7 +105,7 @@ void DownloadManager::continueDecidePendingDownloadDestination(DownloadID downlo > ASSERT(completionHandler); > ASSERT(m_pendingDownloads.contains(downloadID)); > >- networkDataTask->setPendingDownloadLocation(destination, WTFMove(sandboxExtensionHandle), allowOverwrite); >+ networkDataTask->setPendingDownloadConfiguration(WTFMove(configuration)); > completionHandler(PolicyAction::Download); > if (networkDataTask->state() == NetworkDataTask::State::Canceling || networkDataTask->state() == NetworkDataTask::State::Completed) > return; >@@ -120,14 +120,14 @@ void DownloadManager::continueDecidePendingDownloadDestination(DownloadID downlo > } > } > >-void DownloadManager::resumeDownload(PAL::SessionID sessionID, DownloadID downloadID, const IPC::DataReference& resumeData, const String& path, SandboxExtension::Handle&& sandboxExtensionHandle) >+void DownloadManager::resumeDownload(PAL::SessionID sessionID, DownloadID downloadID, const IPC::DataReference& resumeData, DownloadConfiguration&& configuration) > { > #if !PLATFORM(COCOA) > notImplemented(); > #else >- auto download = std::make_unique<Download>(*this, downloadID, nullptr, sessionID); >+ auto download = std::make_unique<Download>(*this, downloadID, nullptr, sessionID, String { }, WTFMove(configuration)); > >- download->resume(resumeData, path, WTFMove(sandboxExtensionHandle)); >+ download->resume(resumeData); > ASSERT(!m_downloads.contains(downloadID)); > m_downloads.add(downloadID, WTFMove(download)); > #endif >diff --git a/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h b/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h >index fbad888e079..f07dfe55c94 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h >+++ b/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h >@@ -25,6 +25,7 @@ > > #pragma once > >+#include "DownloadConfiguration.h" > #include "DownloadID.h" > #include "NetworkDataTask.h" > #include "PendingDownload.h" >@@ -80,9 +81,9 @@ public: > void continueWillSendRequest(DownloadID, WebCore::ResourceRequest&&); > void willDecidePendingDownloadDestination(NetworkDataTask&, ResponseCompletionHandler&&); > void convertNetworkLoadToDownload(DownloadID, std::unique_ptr<NetworkLoad>&&, ResponseCompletionHandler&&, Vector<RefPtr<WebCore::BlobDataFileReference>>&&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&); >- void continueDecidePendingDownloadDestination(DownloadID, String destination, SandboxExtension::Handle&&, bool allowOverwrite); >+ void continueDecidePendingDownloadConfiguration(DownloadID, DownloadConfiguration&&); > >- void resumeDownload(PAL::SessionID, DownloadID, const IPC::DataReference& resumeData, const String& path, SandboxExtension::Handle&&); >+ void resumeDownload(PAL::SessionID, DownloadID, const IPC::DataReference& resumeData, DownloadConfiguration&&); > > void cancelDownload(DownloadID); > #if PLATFORM(COCOA) >diff --git a/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm b/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm >index d30e4792ea2..45e50ecbbc9 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm >+++ b/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm >@@ -35,9 +35,9 @@ > > namespace WebKit { > >-void Download::resume(const IPC::DataReference& resumeData, const String& path, SandboxExtension::Handle&& sandboxExtensionHandle) >+void Download::resume(const IPC::DataReference& resumeData) > { >- m_sandboxExtension = SandboxExtension::create(WTFMove(sandboxExtensionHandle)); >+ m_sandboxExtension = SandboxExtension::create(WTFMove(m_downloadConfiguration.sandboxExtensionHandle)); > if (m_sandboxExtension) > m_sandboxExtension->consume(); > >@@ -48,6 +48,7 @@ void Download::resume(const IPC::DataReference& resumeData, const String& path, > } > auto& cocoaSession = static_cast<NetworkSessionCocoa&>(*networkSession); > auto nsData = adoptNS([[NSData alloc] initWithBytes:resumeData.data() length:resumeData.size()]); >+ auto path = m_downloadConfiguration.destination; > > // FIXME: This is a temporary workaround for <rdar://problem/34745171>. > #if (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) >diff --git a/Source/WebKit/NetworkProcess/NetworkDataTask.h b/Source/WebKit/NetworkProcess/NetworkDataTask.h >index e104ce5311b..914404b559a 100644 >--- a/Source/WebKit/NetworkProcess/NetworkDataTask.h >+++ b/Source/WebKit/NetworkProcess/NetworkDataTask.h >@@ -25,6 +25,7 @@ > > #pragma once > >+#include "DownloadConfiguration.h" > #include "DownloadID.h" > #include "SandboxExtension.h" > #include <WebCore/Credential.h> >@@ -116,9 +117,10 @@ public: > m_pendingDownload = &pendingDownload; > } > >- virtual void setPendingDownloadLocation(const String& filename, SandboxExtension::Handle&&, bool /*allowOverwrite*/) { m_pendingDownloadLocation = filename; } >+ virtual void setPendingDownloadConfiguration(DownloadConfiguration&& downloadConfiguration) { m_pendingDownloadLocation = downloadConfiguration.destination; m_downloadConfiguration = WTFMove(downloadConfiguration); } > const String& pendingDownloadLocation() const { return m_pendingDownloadLocation; } > bool isDownload() const { return !!m_pendingDownloadID.downloadID(); } >+ DownloadConfiguration& downloadConfiguration() { return m_downloadConfiguration; } > > const WebCore::ResourceRequest& firstRequest() const { return m_firstRequest; } > virtual String suggestedFilename() const { return String(); } >@@ -146,6 +148,7 @@ protected: > NetworkDataTaskClient* m_client { nullptr }; > PendingDownload* m_pendingDownload { nullptr }; > DownloadID m_pendingDownloadID; >+ DownloadConfiguration m_downloadConfiguration { }; > String m_user; > String m_password; > String m_partition; >diff --git a/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp b/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp >index 036ec8efe85..4cc0ed23dff 100644 >--- a/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp >@@ -434,16 +434,16 @@ void NetworkDataTaskBlob::consumeData(const char* data, int bytesRead) > read(); > } > >-void NetworkDataTaskBlob::setPendingDownloadLocation(const String& filename, SandboxExtension::Handle&& sandboxExtensionHandle, bool allowOverwrite) >+void NetworkDataTaskBlob::setPendingDownloadConfiguration(DownloadConfiguration&& downloadConfiguration) > { >- NetworkDataTask::setPendingDownloadLocation(filename, { }, allowOverwrite); >+ NetworkDataTask::setPendingDownloadConfiguration(WTFMove(downloadConfiguration)); > > ASSERT(!m_sandboxExtension); >- m_sandboxExtension = SandboxExtension::create(WTFMove(sandboxExtensionHandle)); >+ m_sandboxExtension = SandboxExtension::create(WTFMove(m_downloadConfiguration.sandboxExtensionHandle)); > if (m_sandboxExtension) > m_sandboxExtension->consume(); > >- if (allowOverwrite && FileSystem::fileExists(m_pendingDownloadLocation)) >+ if (m_downloadConfiguration.allowOverwrite == AllowOverwrite::Yes && FileSystem::fileExists(m_pendingDownloadLocation)) > FileSystem::deleteFile(m_pendingDownloadLocation); > } > >diff --git a/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.h b/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.h >index 00cc1f90dd1..eafac54bf59 100644 >--- a/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.h >+++ b/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.h >@@ -62,7 +62,7 @@ private: > void invalidateAndCancel() override; > NetworkDataTask::State state() const override { return m_state; } > >- void setPendingDownloadLocation(const String&, SandboxExtension::Handle&&, bool /*allowOverwrite*/) override; >+ void setPendingDownloadConfiguration(DownloadConfiguration&&) override; > String suggestedFilename() const override; > > // FileStreamClient methods. >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index 0b31ff7733d..a34b9d44d22 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -788,9 +788,9 @@ void NetworkProcess::downloadRequest(PAL::SessionID sessionID, DownloadID downlo > downloadManager().startDownload(nullptr, sessionID, downloadID, request, suggestedFilename); > } > >-void NetworkProcess::resumeDownload(PAL::SessionID sessionID, DownloadID downloadID, const IPC::DataReference& resumeData, const String& path, WebKit::SandboxExtension::Handle&& sandboxExtensionHandle) >+void NetworkProcess::resumeDownload(PAL::SessionID sessionID, DownloadID downloadID, const IPC::DataReference& resumeData, DownloadConfiguration&& downloadConfiguration) > { >- downloadManager().resumeDownload(sessionID, downloadID, resumeData, path, WTFMove(sandboxExtensionHandle)); >+ downloadManager().resumeDownload(sessionID, downloadID, resumeData, WTFMove(downloadConfiguration)); > } > > void NetworkProcess::cancelDownload(DownloadID downloadID) >@@ -827,15 +827,15 @@ void NetworkProcess::findPendingDownloadLocation(NetworkDataTask& networkDataTas > String suggestedFilename = response.isAttachmentWithFilename() ? response.suggestedFilename() : networkDataTask.suggestedFilename(); > suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(suggestedFilename, response.mimeType()); > >- downloadProxyConnection()->send(Messages::DownloadProxy::DecideDestinationWithSuggestedFilenameAsync(networkDataTask.pendingDownloadID(), suggestedFilename), destinationID); >+ downloadProxyConnection()->send(Messages::DownloadProxy::DecideConfigurationWithSuggestedFilenameAsync(networkDataTask.pendingDownloadID(), suggestedFilename), destinationID); > } > >-void NetworkProcess::continueDecidePendingDownloadDestination(DownloadID downloadID, String destination, SandboxExtension::Handle&& sandboxExtensionHandle, bool allowOverwrite) >+void NetworkProcess::continueDecidePendingDownloadConfiguration(DownloadID downloadID, DownloadConfiguration&& downloadConfiguration) > { >- if (destination.isEmpty()) >+ if (downloadConfiguration.destination.isEmpty()) > downloadManager().cancelDownload(downloadID); > else >- downloadManager().continueDecidePendingDownloadDestination(downloadID, destination, WTFMove(sandboxExtensionHandle), allowOverwrite); >+ downloadManager().continueDecidePendingDownloadConfiguration(downloadID, WTFMove(downloadConfiguration)); > } > > void NetworkProcess::setCacheModel(uint32_t cm) >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.h b/Source/WebKit/NetworkProcess/NetworkProcess.h >index f5c2fedbfc7..b3028e1ad5e 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.h >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.h >@@ -262,13 +262,13 @@ private: > void clearDiskCache(WallTime modifiedSince, Function<void ()>&& completionHandler); > > void downloadRequest(PAL::SessionID, DownloadID, const WebCore::ResourceRequest&, const String& suggestedFilename); >- void resumeDownload(PAL::SessionID, DownloadID, const IPC::DataReference& resumeData, const String& path, SandboxExtension::Handle&&); >+ void resumeDownload(PAL::SessionID, DownloadID, const IPC::DataReference& resumeData, DownloadConfiguration&&); > void cancelDownload(DownloadID); > #if PLATFORM(COCOA) > void publishDownloadProgress(DownloadID, const URL&, SandboxExtension::Handle&&); > #endif > void continueWillSendRequest(DownloadID, WebCore::ResourceRequest&&); >- void continueDecidePendingDownloadDestination(DownloadID, String destination, SandboxExtension::Handle&&, bool allowOverwrite); >+ void continueDecidePendingDownloadConfiguration(DownloadID, DownloadConfiguration&&); > > void setCacheModel(uint32_t); > void allowSpecificHTTPSCertificateForHost(const WebCore::CertificateInfo&, const String& host); >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >index 50795a28227..fd620c61b77 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >@@ -47,14 +47,14 @@ messages -> NetworkProcess LegacyReceiver { > DeleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins, Vector<String> cookieHostNames, Vector<String> HSTSCacheHostNames, uint64_t callbackID) > > DownloadRequest(PAL::SessionID sessionID, WebKit::DownloadID downloadID, WebCore::ResourceRequest request, String suggestedFilename) >- ResumeDownload(PAL::SessionID sessionID, WebKit::DownloadID downloadID, IPC::DataReference resumeData, String path, WebKit::SandboxExtension::Handle sandboxExtensionHandle) >+ ResumeDownload(PAL::SessionID sessionID, WebKit::DownloadID downloadID, IPC::DataReference resumeData, struct WebKit::DownloadConfiguration configuration) > CancelDownload(WebKit::DownloadID downloadID) > #if PLATFORM(COCOA) > PublishDownloadProgress(WebKit::DownloadID downloadID, URL url, WebKit::SandboxExtension::Handle sandboxExtensionHandle) > #endif > > ContinueWillSendRequest(WebKit::DownloadID downloadID, WebCore::ResourceRequest request) >- ContinueDecidePendingDownloadDestination(WebKit::DownloadID downloadID, String destination, WebKit::SandboxExtension::Handle sandboxExtensionHandle, bool allowOverwrite) >+ ContinueDecidePendingDownloadConfiguration(WebKit::DownloadID downloadID, struct WebKit::DownloadConfiguration configuration) > > #if PLATFORM(COCOA) > SetQOS(int latencyQOS, int throughputQOS) >diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h b/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h >index 030fa52bb23..a3843fc8dc3 100644 >--- a/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h >+++ b/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h >@@ -39,6 +39,8 @@ namespace WebKit { > > class NetworkSessionCocoa; > >+struct DownloadConfiguration; >+ > class NetworkDataTaskCocoa final : public NetworkDataTask { > friend class NetworkSessionCocoa; > public: >@@ -65,7 +67,7 @@ public: > void invalidateAndCancel() override { } > NetworkDataTask::State state() const override; > >- void setPendingDownloadLocation(const String&, SandboxExtension::Handle&&, bool /*allowOverwrite*/) override; >+ void setPendingDownloadConfiguration(DownloadConfiguration&&) override; > String suggestedFilename() const override; > > WebCore::NetworkLoadMetrics& networkLoadMetrics() { return m_networkLoadMetrics; } >diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm b/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm >index c84141b8dd4..2dc3b970968 100644 >--- a/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm >+++ b/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm >@@ -382,19 +382,19 @@ void NetworkDataTaskCocoa::willPerformHTTPRedirection(WebCore::ResourceResponse& > } > } > >-void NetworkDataTaskCocoa::setPendingDownloadLocation(const WTF::String& filename, SandboxExtension::Handle&& sandboxExtensionHandle, bool allowOverwrite) >+void NetworkDataTaskCocoa::setPendingDownloadConfiguration(DownloadConfiguration&& downloadConfiguration) > { >- NetworkDataTask::setPendingDownloadLocation(filename, { }, allowOverwrite); >+ NetworkDataTask::setPendingDownloadConfiguration(WTFMove(downloadConfiguration)); > > ASSERT(!m_sandboxExtension); >- m_sandboxExtension = SandboxExtension::create(WTFMove(sandboxExtensionHandle)); >+ m_sandboxExtension = SandboxExtension::create(WTFMove(m_downloadConfiguration.sandboxExtensionHandle)); > if (m_sandboxExtension) > m_sandboxExtension->consume(); > > m_task.get()._pathToDownloadTaskFile = m_pendingDownloadLocation; > >- if (allowOverwrite && WebCore::FileSystem::fileExists(m_pendingDownloadLocation)) >- WebCore::FileSystem::deleteFile(filename); >+ if (m_downloadConfiguration.allowOverwrite == AllowOverwrite::Yes && WebCore::FileSystem::fileExists(m_pendingDownloadLocation)) >+ WebCore::FileSystem::deleteFile(m_pendingDownloadLocation); > } > > bool NetworkDataTaskCocoa::tryPasswordBasedAuthentication(const WebCore::AuthenticationChallenge& challenge, ChallengeCompletionHandler& completionHandler) >diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm >index 2d4a7fdb0b9..9fb1730edb3 100644 >--- a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm >+++ b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm >@@ -555,7 +555,7 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)data > Ref<NetworkDataTaskCocoa> protectedNetworkDataTask(*networkDataTask); > auto downloadID = networkDataTask->pendingDownloadID(); > auto& downloadManager = WebKit::NetworkProcess::singleton().downloadManager(); >- auto download = std::make_unique<WebKit::Download>(downloadManager, downloadID, downloadTask, _session->sessionID(), networkDataTask->suggestedFilename()); >+ auto download = std::make_unique<WebKit::Download>(downloadManager, downloadID, downloadTask, _session->sessionID(), networkDataTask->suggestedFilename(), WTFMove(networkDataTask->downloadConfiguration())); > networkDataTask->transferSandboxExtensionToDownload(*download); > ASSERT(WebCore::FileSystem::fileExists(networkDataTask->pendingDownloadLocation())); > download->didCreateDestination(networkDataTask->pendingDownloadLocation()); >diff --git a/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp b/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp >index 0b7b6350a26..5b3b1573d63 100644 >--- a/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp >+++ b/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp >@@ -95,10 +95,10 @@ String NetworkDataTaskSoup::suggestedFilename() const > return decodeURLEscapeSequences(m_response.url().lastPathComponent()); > } > >-void NetworkDataTaskSoup::setPendingDownloadLocation(const String& filename, SandboxExtension::Handle&& sandboxExtensionHandle, bool allowOverwrite) >+void NetworkDataTaskSoup::setPendingDownloadConfiguration(DownloadConfiguration&& downloadConfiguration) > { >- NetworkDataTask::setPendingDownloadLocation(filename, WTFMove(sandboxExtensionHandle), allowOverwrite); >- m_allowOverwriteDownload = allowOverwrite; >+ NetworkDataTask::setPendingDownloadConfiguration(WTFMove(downloadConfiguration)); >+ m_allowOverwriteDownload = m_downloadConfiguration.allowOverwrite == AllowOverwrite::Yes; > } > > void NetworkDataTaskSoup::createRequest(ResourceRequest&& request) >diff --git a/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h b/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h >index d711c790c37..10671093f69 100644 >--- a/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h >+++ b/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h >@@ -52,7 +52,7 @@ private: > void invalidateAndCancel() override; > NetworkDataTask::State state() const override; > >- void setPendingDownloadLocation(const String&, SandboxExtension::Handle&&, bool /*allowOverwrite*/) override; >+ void setPendingDownloadConfiguration(DownloadConfiguration&&) override; > String suggestedFilename() const override; > > void timeoutFired(); >diff --git a/Source/WebKit/Shared/DownloadConfiguration.cpp b/Source/WebKit/Shared/DownloadConfiguration.cpp >new file mode 100644 >index 00000000000..235bb721e8e >--- /dev/null >+++ b/Source/WebKit/Shared/DownloadConfiguration.cpp >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2018 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 "DownloadConfiguration.h" >+ >+#include "ArgumentCoders.h" >+ >+namespace WebKit { >+ >+void DownloadConfiguration::encode(IPC::Encoder& encoder) const >+{ >+ encoder << destination; >+ sandboxExtensionHandle.encode(encoder); >+ encoder << allowOverwrite; >+} >+ >+std::optional<DownloadConfiguration> DownloadConfiguration::decode(IPC::Decoder& decoder) >+{ >+ DownloadConfiguration config { }; >+ >+ if (!decoder.decode(config.destination)) >+ return std::nullopt; >+ >+ auto sandboxExtensionHandle = SandboxExtension::Handle::decode(decoder); >+ if (!sandboxExtensionHandle) >+ return std::nullopt; >+ >+ config.sandboxExtensionHandle = WTFMove(*sandboxExtensionHandle); >+ >+ if (!decoder.decode(config.allowOverwrite)) >+ return std::nullopt; >+ >+ return { WTFMove(config) }; >+} >+ >+}; // namespace WebKit >diff --git a/Source/WebKit/Shared/DownloadConfiguration.h b/Source/WebKit/Shared/DownloadConfiguration.h >new file mode 100644 >index 00000000000..614b821bd96 >--- /dev/null >+++ b/Source/WebKit/Shared/DownloadConfiguration.h >@@ -0,0 +1,69 @@ >+/* >+ * Copyright (C) 2018 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 "SandboxExtension.h" >+#include <wtf/Optional.h> >+ >+namespace IPC { >+class Decoder; >+class Encoder; >+} >+ >+namespace WebKit { >+ >+enum class AllowOverwrite { No, Yes }; >+ >+struct DownloadConfiguration { >+ >+ DownloadConfiguration() = default; >+ DownloadConfiguration(const String& destination, AllowOverwrite allowOverwrite = AllowOverwrite::No) >+ : destination(destination) >+ , allowOverwrite(allowOverwrite) >+ { >+ } >+ >+ String destination; >+ SandboxExtension::Handle sandboxExtensionHandle; >+ AllowOverwrite allowOverwrite; >+ >+ void encode(IPC::Encoder&) const; >+ static std::optional<DownloadConfiguration> decode(IPC::Decoder&); >+}; >+ >+} // namespace WebKit >+ >+namespace WTF { >+ >+template<> struct EnumTraits<WebKit::AllowOverwrite> { >+ using values = EnumValues< >+ WebKit::AllowOverwrite, >+ WebKit::AllowOverwrite::No, >+ WebKit::AllowOverwrite::Yes >+ >; >+}; >+ >+} // namespace WTF; >diff --git a/Source/WebKit/Sources.txt b/Source/WebKit/Sources.txt >index 055ec5e5761..5bc0ff08188 100644 >--- a/Source/WebKit/Sources.txt >+++ b/Source/WebKit/Sources.txt >@@ -100,6 +100,7 @@ Shared/BlobDataFileReferenceWithSandboxExtension.cpp @no-unify > Shared/CacheModel.cpp > Shared/ChildProcess.cpp @no-unify > Shared/ContextMenuContextData.cpp >+Shared/DownloadConfiguration.cpp > Shared/EditorState.cpp > Shared/FontInfo.cpp > Shared/FrameInfoData.cpp >diff --git a/Source/WebKit/SourcesCocoa.txt b/Source/WebKit/SourcesCocoa.txt >index 55eaf591317..f1842596908 100644 >--- a/Source/WebKit/SourcesCocoa.txt >+++ b/Source/WebKit/SourcesCocoa.txt >@@ -230,6 +230,7 @@ UIProcess/API/Cocoa/_WKAutomationSession.mm > UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.mm > UIProcess/API/Cocoa/_WKContextMenuElementInfo.mm > UIProcess/API/Cocoa/_WKDownload.mm >+UIProcess/API/Cocoa/_WKDownloadConfiguration.mm > UIProcess/API/Cocoa/_WKElementAction.mm > UIProcess/API/Cocoa/_WKErrorRecoveryAttempting.mm > UIProcess/API/Cocoa/_WKExperimentalFeature.mm >diff --git a/Source/WebKit/UIProcess/API/APIDownloadClient.h b/Source/WebKit/UIProcess/API/APIDownloadClient.h >index 02376e1e110..a770880e097 100644 >--- a/Source/WebKit/UIProcess/API/APIDownloadClient.h >+++ b/Source/WebKit/UIProcess/API/APIDownloadClient.h >@@ -25,6 +25,7 @@ > > #pragma once > >+#include "DownloadConfiguration.h" > #include <wtf/CompletionHandler.h> > #include <wtf/text/WTFString.h> > >@@ -39,8 +40,6 @@ class AuthenticationChallengeProxy; > class DownloadProxy; > class WebProcessPool; > class WebProtectionSpace; >- >-enum class AllowOverwrite { No, Yes }; > } > > namespace API { >@@ -53,7 +52,7 @@ public: > virtual void didReceiveAuthenticationChallenge(WebKit::WebProcessPool&, WebKit::DownloadProxy&, WebKit::AuthenticationChallengeProxy&) { } > virtual void didReceiveResponse(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WebCore::ResourceResponse&) { } > virtual void didReceiveData(WebKit::WebProcessPool&, WebKit::DownloadProxy&, uint64_t) { } >- virtual void decideDestinationWithSuggestedFilename(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&, Function<void(WebKit::AllowOverwrite, WTF::String)>&& completionHandler) { completionHandler(WebKit::AllowOverwrite::No, { }); } >+ virtual void decideConfigurationWithSuggestedFilename(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&, Function<void(WebKit::DownloadConfiguration&&)>&& completionHandler) { completionHandler({ }); } > virtual void didCreateDestination(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WTF::String&) { } > virtual void didFinish(WebKit::WebProcessPool&, WebKit::DownloadProxy&) { } > virtual void didFail(WebKit::WebProcessPool&, WebKit::DownloadProxy&, const WebCore::ResourceError&) { } >diff --git a/Source/WebKit/UIProcess/API/C/WKContext.cpp b/Source/WebKit/UIProcess/API/C/WKContext.cpp >index e3b468b8011..d8f5f893a14 100644 >--- a/Source/WebKit/UIProcess/API/C/WKContext.cpp >+++ b/Source/WebKit/UIProcess/API/C/WKContext.cpp >@@ -206,14 +206,14 @@ void WKContextSetDownloadClient(WKContextRef contextRef, const WKContextDownload > m_client.didReceiveData(toAPI(&processPool), toAPI(&downloadProxy), length, m_client.base.clientInfo); > } > >- void decideDestinationWithSuggestedFilename(WebProcessPool& processPool, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, WTF::String)>&& completionHandler) final >+ void decideConfigurationWithSuggestedFilename(WebProcessPool& processPool, DownloadProxy& downloadProxy, const String& filename, Function<void(DownloadConfiguration&&)>&& completionHandler) final > { > if (!m_client.decideDestinationWithSuggestedFilename) >- return completionHandler(AllowOverwrite::No, { }); >+ return completionHandler({ }); > > bool allowOverwrite = false; > WKRetainPtr<WKStringRef> destination(AdoptWK, m_client.decideDestinationWithSuggestedFilename(toAPI(&processPool), toAPI(&downloadProxy), toAPI(filename.impl()), &allowOverwrite, m_client.base.clientInfo)); >- completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, toWTFString(destination.get())); >+ completionHandler({ toWTFString(destination.get()), allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No }); > } > > void didCreateDestination(WebProcessPool& processPool, DownloadProxy& downloadProxy, const String& path) final >@@ -282,7 +282,7 @@ WKDownloadRef WKContextDownloadURLRequest(WKContextRef contextRef, WKURLRequestR > > WKDownloadRef WKContextResumeDownload(WKContextRef contextRef, WKDataRef resumeData, WKStringRef path) > { >- return toAPI(toImpl(contextRef)->resumeDownload(nullptr, toImpl(resumeData), toWTFString(path))); >+ return toAPI(toImpl(contextRef)->resumeDownload(nullptr, toImpl(resumeData), { toWTFString(path) })); > } > > void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef contextRef, WKTypeRef userDataRef) >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm >index a18381ab35a..ed1e073df85 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm >@@ -43,6 +43,7 @@ > #import "WebProcessPool.h" > #import "_WKAutomationDelegate.h" > #import "_WKAutomationSessionInternal.h" >+#import "_WKDownloadConfigurationInternal.h" > #import "_WKDownloadDelegate.h" > #import "_WKDownloadInternal.h" > #import "_WKProcessPoolConfigurationInternal.h" >@@ -578,7 +579,15 @@ - (_WKDownload *)_downloadURLRequest:(NSURLRequest *)request originatingWebView: > > - (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData path:(NSString *)path originatingWebView:(WKWebView *)webView > { >- return wrapper(_processPool->resumeDownload([webView _page], API::Data::createWithoutCopying(resumeData).ptr(), path)); >+ return wrapper(_processPool->resumeDownload([webView _page], API::Data::createWithoutCopying(resumeData).ptr(), { path })); >+} >+ >+- (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData originatingWebView:(WKWebView *)webView configuration:(_WKDownloadConfiguration *)wkConfiguration >+{ >+ WebKit::DownloadConfiguration configuration { }; >+ if (wkConfiguration) >+ configuration = [wkConfiguration _downloadConfiguration]; >+ return wrapper(_processPool->resumeDownload([webView _page], API::Data::createWithoutCopying(resumeData).ptr(), WTFMove(configuration))); > } > > - (void)_getActivePagesOriginsInWebProcessForTesting:(pid_t)pid completionHandler:(void(^)(NSArray<NSString *> *))completionHandler >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h >index 3de2c0362bf..55fde18d407 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h >@@ -31,6 +31,7 @@ > @class WKWebView; > @class _WKAutomationSession; > @class _WKDownload; >+@class _WKDownloadConfiguration; > @class _WKProcessPoolConfiguration; > @protocol _WKAutomationDelegate; > @protocol _WKDownloadDelegate; >@@ -83,6 +84,7 @@ > > - (_WKDownload *)_downloadURLRequest:(NSURLRequest *)request originatingWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > - (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData path:(NSString *)path originatingWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+- (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData originatingWebView:(WKWebView *)webView configuration:(_WKDownloadConfiguration *)configuration WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > // Test only. Should be called only while no web content processes are running. > - (void)_terminateNetworkProcess; >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadConfiguration.h b/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadConfiguration.h >new file mode 100644 >index 00000000000..9eec440c0d0 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadConfiguration.h >@@ -0,0 +1,43 @@ >+/* >+ * Copyright (C) 2018 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. >+ */ >+ >+#import <Foundation/Foundation.h> >+#import <WebKit/WKFoundation.h> >+ >+#if WK_API_ENABLED >+ >+NS_ASSUME_NONNULL_BEGIN >+ >+WK_CLASS_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)) >+@interface _WKDownloadConfiguration : NSObject >+ >+@property (nonatomic, retain, nullable) NSURL *destination; >+@property (nonatomic) BOOL allowOverwrite; >+ >+@end >+ >+NS_ASSUME_NONNULL_END >+ >+#endif // WK_API_ENABLED >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadConfiguration.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadConfiguration.mm >new file mode 100644 >index 00000000000..32e3c149a67 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadConfiguration.mm >@@ -0,0 +1,64 @@ >+/* >+ * Copyright (C) 2018 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. >+ */ >+ >+#import "config.h" >+#import "_WKDownloadConfigurationInternal.h" >+ >+#if WK_API_ENABLED >+ >+static void checkURLArgument(NSURL *url) >+{ >+ if (url && ![url isFileURL]) >+ [NSException raise:NSInvalidArgumentException format:@"%@ is not a file URL", url]; >+} >+ >+@implementation _WKDownloadConfiguration { >+ RetainPtr<NSURL> m_destination; >+} >+ >+- (NSURL *)destination >+{ >+ return m_destination.get(); >+} >+ >+- (void)setDestination:(NSURL *)destination >+{ >+ checkURLArgument(destination); >+ m_destination = destination; >+} >+ >+- (WebKit::DownloadConfiguration)_downloadConfiguration >+{ >+ WebKit::DownloadConfiguration config { }; >+ >+ config.destination = [m_destination path]; >+ config.allowOverwrite = _allowOverwrite ? WebKit::AllowOverwrite::Yes : WebKit::AllowOverwrite::Yes; >+ >+ return config; >+} >+ >+@end >+ >+#endif // WK_API_ENABLED >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadConfigurationInternal.h b/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadConfigurationInternal.h >new file mode 100644 >index 00000000000..eb98ff01413 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadConfigurationInternal.h >@@ -0,0 +1,38 @@ >+/* >+ * Copyright (C) 2018 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. >+ */ >+ >+#import "_WKDownloadConfiguration.h" >+ >+#if WK_API_ENABLED >+ >+#import "DownloadConfiguration.h" >+ >+@interface _WKDownloadConfiguration () >+ >+- (WebKit::DownloadConfiguration)_downloadConfiguration; >+ >+@end >+ >+#endif // WK_API_ENABLED >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate.h b/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate.h >index e8be40f8705..6257b1507e6 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate.h >@@ -30,6 +30,7 @@ > #import <Foundation/Foundation.h> > > @class _WKDownload; >+@class _WKDownloadConfiguration; > > @protocol _WKDownloadDelegate <NSObject> > @optional >@@ -38,6 +39,7 @@ > - (void)_download:(_WKDownload *)download didReceiveResponse:(NSURLResponse *)response; > - (void)_download:(_WKDownload *)download didReceiveData:(uint64_t)length; > - (void)_download:(_WKDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename completionHandler:(void (^)(BOOL allowOverwrite, NSString *destination))completionHandler; >+- (void)_download:(_WKDownload *)download decideConfigurationWithSuggestedFilename:(NSString *)filename completionHandler:(void (^)(_WKDownloadConfiguration *configuration))completionHandler; > - (void)_downloadDidFinish:(_WKDownload *)download; > - (void)_download:(_WKDownload *)download didFailWithError:(NSError *)error; > - (void)_downloadDidCancel:(_WKDownload *)download; >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp b/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp >index ead4f234991..2bc279e70cb 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitDownloadClient.cpp >@@ -74,12 +74,12 @@ private: > webkitDownloadNotifyProgress(download.get(), length); > } > >- void decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler) override >+ void decideConfigurationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(DownloadConfiguration&&)>&& completionHandler) override > { > GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(&downloadProxy); > bool allowOverwrite = false; > String destination = webkitDownloadDecideDestinationWithSuggestedFilename(download.get(), filename.utf8(), allowOverwrite); >- completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, destination); >+ completionHandler({ destination, allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No }); > } > > void didCreateDestination(WebProcessPool&, DownloadProxy& downloadProxy, const String& path) override >diff --git a/Source/WebKit/UIProcess/Cocoa/DownloadClient.h b/Source/WebKit/UIProcess/Cocoa/DownloadClient.h >index 118866cc6f1..b7b21a81c9b 100644 >--- a/Source/WebKit/UIProcess/Cocoa/DownloadClient.h >+++ b/Source/WebKit/UIProcess/Cocoa/DownloadClient.h >@@ -51,7 +51,7 @@ private: > void didStart(WebProcessPool&, DownloadProxy&) final; > void didReceiveResponse(WebProcessPool&, DownloadProxy&, const WebCore::ResourceResponse&) final; > void didReceiveData(WebProcessPool&, DownloadProxy&, uint64_t length) final; >- void decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy&, const String& suggestedFilename, Function<void(AllowOverwrite, String)>&&) final; >+ void decideConfigurationWithSuggestedFilename(WebProcessPool&, DownloadProxy&, const String& suggestedFilename, Function<void(DownloadConfiguration&&)>&&) final; > void didFinish(WebProcessPool&, DownloadProxy&) final; > void didFail(WebProcessPool&, DownloadProxy&, const WebCore::ResourceError&) final; > void didCancel(WebProcessPool&, DownloadProxy&) final; >@@ -77,6 +77,7 @@ private: > bool downloadDidReceiveData : 1; > bool downloadDecideDestinationWithSuggestedFilenameAllowOverwrite : 1; > bool downloadDecideDestinationWithSuggestedFilenameCompletionHandler : 1; >+ bool downloadDecideConfigurationWithSuggestedFilenameCompletionHandler : 1; > bool downloadDidFinish : 1; > bool downloadDidFail : 1; > bool downloadDidCancel : 1; >diff --git a/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm b/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm >index 3b49628fdf6..b8f09ff43c0 100644 >--- a/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm >+++ b/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm >@@ -40,6 +40,7 @@ > #import "WebCredential.h" > #import "WebPageProxy.h" > #import "WebProcessProxy.h" >+#import "_WKDownloadConfigurationInternal.h" > #import "_WKDownloadDelegate.h" > #import "_WKDownloadInternal.h" > #import <WebCore/FileSystem.h> >@@ -57,6 +58,7 @@ DownloadClient::DownloadClient(id <_WKDownloadDelegate> delegate) > m_delegateMethods.downloadDidReceiveData = [delegate respondsToSelector:@selector(_download:didReceiveData:)]; > m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameAllowOverwrite = [delegate respondsToSelector:@selector(_download:decideDestinationWithSuggestedFilename:allowOverwrite:)]; > m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameCompletionHandler = [delegate respondsToSelector:@selector(_download:decideDestinationWithSuggestedFilename:completionHandler:)]; >+ m_delegateMethods.downloadDecideConfigurationWithSuggestedFilenameCompletionHandler = [delegate respondsToSelector:@selector(_download:decideConfigurationWithSuggestedFilename:completionHandler:)]; > m_delegateMethods.downloadDidFinish = [delegate respondsToSelector:@selector(_downloadDidFinish:)]; > m_delegateMethods.downloadDidFail = [delegate respondsToSelector:@selector(_download:didFailWithError:)]; > m_delegateMethods.downloadDidCancel = [delegate respondsToSelector:@selector(_downloadDidCancel:)]; >@@ -177,32 +179,42 @@ void DownloadClient::processDidCrash(WebProcessPool&, DownloadProxy& downloadPro > [m_delegate _downloadProcessDidCrash:wrapper(downloadProxy)]; > } > >-void DownloadClient::decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler) >+void DownloadClient::decideConfigurationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(DownloadConfiguration&&)>&& completionHandler) > { > #if USE(SYSTEM_PREVIEW) > if (downloadProxy.isSystemPreviewDownload()) { > NSString *temporaryDirectory = WebCore::FileSystem::createTemporaryDirectory(@"SystemPreviews"); > NSString *destination = [temporaryDirectory stringByAppendingPathComponent:filename]; >- completionHandler(AllowOverwrite::Yes, destination); >+ completionHandler({ destination, AllowOverwrite::Yes }); > return; > } > #endif > >- if (!m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameAllowOverwrite && !m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameCompletionHandler) >- return completionHandler(AllowOverwrite::No, { }); >+ if (!m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameAllowOverwrite && !m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameCompletionHandler && !m_delegateMethods.downloadDecideConfigurationWithSuggestedFilenameCompletionHandler) >+ return completionHandler({ }); > >- if (m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameAllowOverwrite) { >+ if (m_delegateMethods.downloadDecideConfigurationWithSuggestedFilenameCompletionHandler) { >+ [m_delegate _download:wrapper(downloadProxy) decideConfigurationWithSuggestedFilename:filename completionHandler:makeBlockPtr([checker = CompletionHandlerCallChecker::create(m_delegate.get().get(), @selector(_download:decideConfigurationWithSuggestedFilename:completionHandler:)), completionHandler = WTFMove(completionHandler)] (_WKDownloadConfiguration *wkDownloadConfiguration) { >+ if (checker->completionHandlerHasBeenCalled()) >+ return; >+ checker->didCallCompletionHandler(); >+ DownloadConfiguration downloadConfiguration { }; >+ if (wkDownloadConfiguration) >+ downloadConfiguration = [wkDownloadConfiguration _downloadConfiguration]; >+ completionHandler(WTFMove(downloadConfiguration)); >+ }).get()]; >+ } else if (m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameAllowOverwrite) { > BOOL allowOverwrite = NO; > ALLOW_DEPRECATED_DECLARATIONS_BEGIN > NSString *destination = [m_delegate _download:wrapper(downloadProxy) decideDestinationWithSuggestedFilename:filename allowOverwrite:&allowOverwrite]; > ALLOW_DEPRECATED_DECLARATIONS_END >- completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, destination); >+ completionHandler({ destination, allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No }); > } else { > [m_delegate _download:wrapper(downloadProxy) decideDestinationWithSuggestedFilename:filename completionHandler:makeBlockPtr([checker = CompletionHandlerCallChecker::create(m_delegate.get().get(), @selector(_download:decideDestinationWithSuggestedFilename:completionHandler:)), completionHandler = WTFMove(completionHandler)] (BOOL allowOverwrite, NSString *destination) { > if (checker->completionHandlerHasBeenCalled()) > return; > checker->didCallCompletionHandler(); >- completionHandler(allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No, destination); >+ completionHandler({ destination, allowOverwrite ? AllowOverwrite::Yes : AllowOverwrite::No }); > }).get()]; > } > } >diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >index d74ddb37052..92e0ccfcbd0 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >+++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >@@ -528,8 +528,6 @@ - (BOOL)tryToPerform:(SEL)action with:(id)object > > @end > >-using namespace WebKit; >- > #if HAVE(TOUCH_BAR) > > @interface WKTextListTouchBarViewController : NSViewController { >@@ -538,9 +536,9 @@ @private > ListType _currentListType; > } > >-@property (nonatomic) ListType currentListType; >+@property (nonatomic) WebKit::ListType currentListType; > >-- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl; >+- (instancetype)initWithWebViewImpl:(WebKit::WebViewImpl*)webViewImpl; > > @end > >@@ -557,7 +555,7 @@ static const NSUInteger noListSegment = 0; > static const NSUInteger unorderedListSegment = 1; > static const NSUInteger orderedListSegment = 2; > >-- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl >+- (instancetype)initWithWebViewImpl:(WebKit::WebViewImpl*)webViewImpl > { > if (!(self = [super init])) > return nil; >@@ -600,9 +598,9 @@ - (void)_selectList:(id)sender > // There is no "remove list" edit command, but InsertOrderedList and InsertUnorderedList both > // behave as toggles, so we can invoke the appropriate edit command depending on our _currentListType > // to remove an existing list. We don't have to do anything if _currentListType is NoList. >- if (_currentListType == OrderedList) >+ if (_currentListType == WebKit::OrderedList) > _webViewImpl->page().executeEditCommand(@"InsertOrderedList", @""); >- else if (_currentListType == UnorderedList) >+ else if (_currentListType == WebKit::UnorderedList) > _webViewImpl->page().executeEditCommand(@"InsertUnorderedList", @""); > break; > case unorderedListSegment: >@@ -616,17 +614,17 @@ - (void)_selectList:(id)sender > _webViewImpl->dismissTextTouchBarPopoverItemWithIdentifier(NSTouchBarItemIdentifierTextList); > } > >-- (void)setCurrentListType:(ListType)listType >+- (void)setCurrentListType:(WebKit::ListType)listType > { > NSSegmentedControl *insertListControl = (NSSegmentedControl *)self.view; > switch (listType) { >- case NoList: >+ case WebKit::NoList: > [insertListControl setSelected:YES forSegment:noListSegment]; > break; >- case OrderedList: >+ case WebKit::OrderedList: > [insertListControl setSelected:YES forSegment:orderedListSegment]; > break; >- case UnorderedList: >+ case WebKit::UnorderedList: > [insertListControl setSelected:YES forSegment:unorderedListSegment]; > break; > } >@@ -646,7 +644,7 @@ @private > RetainPtr<WKTextListTouchBarViewController> _textListTouchBarViewController; > > @private >- WebViewImpl* _webViewImpl; >+ WebKit::WebViewImpl* _webViewImpl; > } > > @property (nonatomic) BOOL textIsBold; >@@ -655,7 +653,7 @@ @property (nonatomic) BOOL textIsUnderlined; > @property (nonatomic) NSTextAlignment currentTextAlignment; > @property (nonatomic, retain, readwrite) NSColor *textColor; > >-- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl; >+- (instancetype)initWithWebViewImpl:(WebKit::WebViewImpl*)webViewImpl; > @end > > @implementation WKTextTouchBarItemController >@@ -665,7 +663,7 @@ @synthesize textIsItalic=_textIsItalic; > @synthesize textIsUnderlined=_textIsUnderlined; > @synthesize currentTextAlignment=_currentTextAlignment; > >-- (instancetype)initWithWebViewImpl:(WebViewImpl*)webViewImpl >+- (instancetype)initWithWebViewImpl:(WebKit::WebViewImpl*)webViewImpl > { > if (!(self = [super init])) > return nil; >diff --git a/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp b/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp >index 75102ee3b00..0bacfdecc7b 100644 >--- a/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp >+++ b/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp >@@ -175,21 +175,20 @@ void DownloadProxy::didReceiveData(uint64_t length) > m_processPool->downloadClient().didReceiveData(*m_processPool, *this, length); > } > >-void DownloadProxy::decideDestinationWithSuggestedFilenameAsync(DownloadID downloadID, const String& suggestedFilename) >+void DownloadProxy::decideConfigurationWithSuggestedFilenameAsync(DownloadID downloadID, const String& suggestedFilename) > { > if (!m_processPool) > return; > >- m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*m_processPool, *this, suggestedFilename, [this, protectedThis = makeRef(*this), downloadID = downloadID] (AllowOverwrite allowOverwrite, String destination) { >- SandboxExtension::Handle sandboxExtensionHandle; >- if (!destination.isNull()) >- SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle); >- >+ m_processPool->downloadClient().decideConfigurationWithSuggestedFilename(*m_processPool, *this, suggestedFilename, [this, protectedThis = makeRef(*this), downloadID = downloadID] (DownloadConfiguration&& configuration) { > if (!m_processPool) > return; > >+ if (!configuration.destination.isNull()) >+ SandboxExtension::createHandle(configuration.destination, SandboxExtension::Type::ReadWrite, configuration.sandboxExtensionHandle); >+ > if (auto* networkProcess = m_processPool->networkProcess()) >- networkProcess->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite == AllowOverwrite::Yes), 0); >+ networkProcess->send(Messages::NetworkProcess::ContinueDecidePendingDownloadConfiguration(downloadID, WTFMove(configuration)), 0); > }); > } > >diff --git a/Source/WebKit/UIProcess/Downloads/DownloadProxy.h b/Source/WebKit/UIProcess/Downloads/DownloadProxy.h >index f24049957a2..f081b5accbb 100644 >--- a/Source/WebKit/UIProcess/Downloads/DownloadProxy.h >+++ b/Source/WebKit/UIProcess/Downloads/DownloadProxy.h >@@ -115,7 +115,7 @@ private: > void didFail(const WebCore::ResourceError&, const IPC::DataReference& resumeData); > void didCancel(const IPC::DataReference& resumeData); > void willSendRequest(WebCore::ResourceRequest&& redirectRequest, const WebCore::ResourceResponse& redirectResponse); >- void decideDestinationWithSuggestedFilenameAsync(DownloadID, const String& suggestedFilename); >+ void decideConfigurationWithSuggestedFilenameAsync(DownloadID, const String& suggestedFilename); > > DownloadProxyMap& m_downloadProxyMap; > RefPtr<WebProcessPool> m_processPool; >diff --git a/Source/WebKit/UIProcess/Downloads/DownloadProxy.messages.in b/Source/WebKit/UIProcess/Downloads/DownloadProxy.messages.in >index ea56dab1d62..2eb790fac43 100644 >--- a/Source/WebKit/UIProcess/Downloads/DownloadProxy.messages.in >+++ b/Source/WebKit/UIProcess/Downloads/DownloadProxy.messages.in >@@ -24,7 +24,7 @@ messages -> DownloadProxy { > DidStart(WebCore::ResourceRequest request, AtomicString suggestedFilename) > DidReceiveAuthenticationChallenge(WebCore::AuthenticationChallenge challenge, uint64_t challengeID) > WillSendRequest(WebCore::ResourceRequest redirectRequest, WebCore::ResourceResponse redirectResponse)) >- DecideDestinationWithSuggestedFilenameAsync(WebKit::DownloadID downloadID, String suggestedFilename) >+ DecideConfigurationWithSuggestedFilenameAsync(WebKit::DownloadID downloadID, String suggestedFilename) > > DidReceiveResponse(WebCore::ResourceResponse response) > DidReceiveData(uint64_t length) >diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp >index c8f805e8984..0f8aa986486 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.cpp >+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp >@@ -1261,17 +1261,16 @@ DownloadProxy* WebProcessPool::download(WebPageProxy* initiatingPage, const Reso > return downloadProxy; > } > >-DownloadProxy* WebProcessPool::resumeDownload(WebPageProxy* initiatingPage, const API::Data* resumeData, const String& path) >+DownloadProxy* WebProcessPool::resumeDownload(WebPageProxy* initiatingPage, const API::Data* resumeData, DownloadConfiguration&& downloadConfiguration) > { > auto* downloadProxy = createDownloadProxy(ResourceRequest(), initiatingPage); > PAL::SessionID sessionID = initiatingPage ? initiatingPage->sessionID() : PAL::SessionID::defaultSessionID(); > >- SandboxExtension::Handle sandboxExtensionHandle; >- if (!path.isEmpty()) >- SandboxExtension::createHandle(path, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle); >+ if (!downloadConfiguration.destination.isEmpty()) >+ SandboxExtension::createHandle(downloadConfiguration.destination, SandboxExtension::Type::ReadWrite, downloadConfiguration.sandboxExtensionHandle); > > if (networkProcess()) { >- networkProcess()->send(Messages::NetworkProcess::ResumeDownload(sessionID, downloadProxy->downloadID(), resumeData->dataReference(), path, sandboxExtensionHandle), 0); >+ networkProcess()->send(Messages::NetworkProcess::ResumeDownload(sessionID, downloadProxy->downloadID(), resumeData->dataReference(), WTFMove(downloadConfiguration)), 0); > return downloadProxy; > } > >diff --git a/Source/WebKit/UIProcess/WebProcessPool.h b/Source/WebKit/UIProcess/WebProcessPool.h >index 076794df0ce..4c231d72da7 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.h >+++ b/Source/WebKit/UIProcess/WebProcessPool.h >@@ -29,6 +29,7 @@ > #include "APIObject.h" > #include "APIProcessPoolConfiguration.h" > #include "APIWebsiteDataStore.h" >+#include "DownloadConfiguration.h" > #include "DownloadProxyMap.h" > #include "GenericCallback.h" > #include "HiddenPageThrottlingAutoIncreasesCounter.h" >@@ -189,7 +190,7 @@ public: > const String& injectedBundlePath() const { return m_configuration->injectedBundlePath(); } > > DownloadProxy* download(WebPageProxy* initiatingPage, const WebCore::ResourceRequest&, const String& suggestedFilename = { }); >- DownloadProxy* resumeDownload(WebPageProxy* initiatingPage, const API::Data* resumeData, const String& path); >+ DownloadProxy* resumeDownload(WebPageProxy* initiatingPage, const API::Data* resumeData, DownloadConfiguration&& = { }); > > void setInjectedBundleInitializationUserData(RefPtr<API::Object>&& userData) { m_injectedBundleInitializationUserData = WTFMove(userData); } > >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 6b189008453..5e45eb3c702 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -1078,8 +1078,10 @@ > 636353A51E9858DF0009F8AF /* _WKGeolocationCoreLocationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 63FABE191E970D65003011D5 /* _WKGeolocationCoreLocationProvider.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 637281A221ADC744009E0DE6 /* WKDownloadProgress.h in Headers */ = {isa = PBXBuildFile; fileRef = 637281A021ADC744009E0DE6 /* WKDownloadProgress.h */; }; > 637281A321ADC744009E0DE6 /* WKDownloadProgress.mm in Sources */ = {isa = PBXBuildFile; fileRef = 637281A121ADC744009E0DE6 /* WKDownloadProgress.mm */; }; >+ 63BDE7DE219248C80098C90B /* DownloadConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 63BDE7DC219248C80098C90B /* DownloadConfiguration.h */; }; > 63C32C261E9810D900699BD0 /* _WKGeolocationPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 63C32C241E9810D900699BD0 /* _WKGeolocationPosition.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 63C32C281E98119000699BD0 /* _WKGeolocationPositionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 63C32C271E98119000699BD0 /* _WKGeolocationPositionInternal.h */; }; >+ 63EE417921C1BB04007A9F74 /* _WKDownloadConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 63EE417721C1BB04007A9F74 /* _WKDownloadConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 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, ); }; }; > 6B821DDC1EEF05DD00D7AF4A /* WebResourceLoadStatisticsTelemetry.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B821DDA1EEF05DD00D7AF4A /* WebResourceLoadStatisticsTelemetry.h */; }; >@@ -3487,9 +3489,14 @@ > 6348424F1FB26E7100946E3C /* APIApplicationManifest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIApplicationManifest.h; sourceTree = "<group>"; }; > 637281A021ADC744009E0DE6 /* WKDownloadProgress.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKDownloadProgress.h; sourceTree = "<group>"; }; > 637281A121ADC744009E0DE6 /* WKDownloadProgress.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKDownloadProgress.mm; sourceTree = "<group>"; }; >+ 63BDE7DC219248C80098C90B /* DownloadConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DownloadConfiguration.h; sourceTree = "<group>"; }; >+ 63BDE7DD219248C80098C90B /* DownloadConfiguration.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadConfiguration.cpp; sourceTree = "<group>"; }; > 63C32C231E9810D900699BD0 /* _WKGeolocationPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKGeolocationPosition.mm; sourceTree = "<group>"; }; > 63C32C241E9810D900699BD0 /* _WKGeolocationPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKGeolocationPosition.h; sourceTree = "<group>"; }; > 63C32C271E98119000699BD0 /* _WKGeolocationPositionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKGeolocationPositionInternal.h; sourceTree = "<group>"; }; >+ 63EE417721C1BB04007A9F74 /* _WKDownloadConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKDownloadConfiguration.h; sourceTree = "<group>"; }; >+ 63EE417821C1BB04007A9F74 /* _WKDownloadConfiguration.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKDownloadConfiguration.mm; sourceTree = "<group>"; }; >+ 63EE417B21C1BBE7007A9F74 /* _WKDownloadConfigurationInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKDownloadConfigurationInternal.h; sourceTree = "<group>"; }; > 63FABE191E970D65003011D5 /* _WKGeolocationCoreLocationProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKGeolocationCoreLocationProvider.h; sourceTree = "<group>"; }; > 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageResourceLoadClient.cpp; sourceTree = "<group>"; }; > 6546A82A13000164000CEB1C /* InjectedBundlePageResourceLoadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageResourceLoadClient.h; sourceTree = "<group>"; }; >@@ -5152,6 +5159,8 @@ > 7C065F291C8CD95F00C2D950 /* WebUserContentControllerDataTypes.cpp */, > 7C065F2A1C8CD95F00C2D950 /* WebUserContentControllerDataTypes.h */, > C0337DD0127A2980008FF4F4 /* WebWheelEvent.cpp */, >+ 63BDE7DC219248C80098C90B /* DownloadConfiguration.h */, >+ 63BDE7DD219248C80098C90B /* DownloadConfiguration.cpp */, > ); > path = Shared; > sourceTree = "<group>"; >@@ -5991,6 +6000,9 @@ > A1A4FE5818DCE9FA00B5EA8A /* _WKDownload.mm */, > A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */, > A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */, >+ 63EE417721C1BB04007A9F74 /* _WKDownloadConfiguration.h */, >+ 63EE417821C1BB04007A9F74 /* _WKDownloadConfiguration.mm */, >+ 63EE417B21C1BBE7007A9F74 /* _WKDownloadConfigurationInternal.h */, > 379A873818BBFE0F00588AF2 /* _WKElementAction.h */, > 379A873718BBFE0F00588AF2 /* _WKElementAction.mm */, > 379A873B18BBFF0700588AF2 /* _WKElementActionInternal.h */, >@@ -9338,6 +9350,7 @@ > BC4A6292147312BE006C681A /* WebConnectionClient.h in Headers */, > 1A1FEC1D1627B45700700F6D /* WebConnectionMessages.h in Headers */, > BC4A62A814744EC7006C681A /* WebConnectionToWebProcess.h in Headers */, >+ 63BDE7DE219248C80098C90B /* DownloadConfiguration.h in Headers */, > 31A505FA1680025500A930EB /* WebContextClient.h in Headers */, > BC09B8F9147460F7005F5625 /* WebContextConnectionClient.h in Headers */, > BCDE059B11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h in Headers */, >@@ -9531,6 +9544,7 @@ > BC4075F4124FF0270068F20A /* WKArray.h in Headers */, > 512F58F612A88A5400629530 /* WKAuthenticationChallenge.h in Headers */, > 512F58F812A88A5400629530 /* WKAuthenticationDecisionListener.h in Headers */, >+ 63EE417921C1BB04007A9F74 /* _WKDownloadConfiguration.h in Headers */, > 37C4C08D1814AC5C003688B9 /* WKBackForwardList.h in Headers */, > 37C4C0951814B9E6003688B9 /* WKBackForwardListInternal.h in Headers */, > 37C4C08718149C5B003688B9 /* WKBackForwardListItem.h in Headers */, >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index c4215c8c99b..18525d5ebb2 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,18 @@ >+2018-12-13 David Quesada <david_quesada@apple.com> >+ >+ Add a class to bundle download configuration parameters together >+ https://bugs.webkit.org/show_bug.cgi?id=192683 >+ rdar://problem/46711066 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/Download.mm: >+ (-[ConfigurationDecidingDownloadDelegate _download:decideConfigurationWithSuggestedFilename:completionHandler:]): >+ (-[ConfigurationDecidingDownloadDelegate _downloadDidFinish:]): >+ (TEST): >+ Add a simple API test for configuring a download via the _WKDownloadDelegate method >+ that asks for a _WKDownloadConfiguration. >+ > 2018-12-13 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] Support dropping contact card data (public.vcard) in editable content >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm >index dae0d2710c8..9ce3d0f70a8 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm >@@ -35,6 +35,7 @@ > #import "TestWKWebView.h" > #import <WebCore/FileSystem.h> > #import <WebKit/_WKDownload.h> >+#import <WebKit/_WKDownloadConfiguration.h> > #import <WebKit/_WKDownloadDelegate.h> > #import <WebKit/WKNavigationDelegatePrivate.h> > #import <WebKit/WKProcessPoolPrivate.h> >@@ -620,5 +621,41 @@ TEST(_WKDownload, DownloadCanceledWhileDecidingDestination) > [TestProtocol unregister]; > } > >+@interface ConfigurationDecidingDownloadDelegate : NSObject <_WKDownloadDelegate> >+@end >+ >+@implementation ConfigurationDecidingDownloadDelegate { >+ String _destinationPath; >+} >+ >+- (void)_download:(_WKDownload *)download decideConfigurationWithSuggestedFilename:(NSString *)filename completionHandler:(void (^)(_WKDownloadConfiguration *))completionHandler >+{ >+ WebCore::FileSystem::PlatformFileHandle fileHandle; >+ _destinationPath = WebCore::FileSystem::openTemporaryFile("TestWebKitAPI", fileHandle); >+ EXPECT_TRUE(fileHandle != WebCore::FileSystem::invalidPlatformFileHandle); >+ WebCore::FileSystem::closeFile(fileHandle); >+ >+ auto configuration = adoptNS([[_WKDownloadConfiguration alloc] init]); >+ [configuration setDestination:[NSURL fileURLWithPath:_destinationPath]]; >+ [configuration setAllowOverwrite:YES]; >+ completionHandler(configuration.get()); >+} >+ >+- (void)_downloadDidFinish:(_WKDownload *)download >+{ >+ EXPECT_TRUE([[NSFileManager defaultManager] contentsEqualAtPath:_destinationPath andPath:[sourceURL path]]); >+ WebCore::FileSystem::deleteFile(_destinationPath); >+ isDone = true; >+} >+ >+@end >+ >+TEST(_WKDownload, DownloadDecideConfiguration) >+{ >+ auto navigationDelegate = adoptNS([[ConvertResponseToDownloadNavigationDelegate alloc] init]); >+ auto downloadDelegate = adoptNS([[ConfigurationDecidingDownloadDelegate alloc] init]); >+ runTest(navigationDelegate.get(), downloadDelegate.get(), sourceURL); >+} >+ > #endif > #endif
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 192683
:
357265
|
357274
|
357279
|
357285