Diff
Modified: trunk/LayoutTests/ChangeLog (206355 => 206356)
--- trunk/LayoutTests/ChangeLog 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/ChangeLog 2016-09-25 02:39:38 UTC (rev 206356)
@@ -1,5 +1,25 @@
2016-09-24 Chris Dumez <[email protected]>
+ <a download> does not support Blob URLs
+ https://bugs.webkit.org/show_bug.cgi?id=156099
+ <rdar://problem/25535520>
+
+ Reviewed by Darin Adler.
+
+ Unskip / rebaseline existing tests now that <a download> supports Blob URLs.
+
+ * TestExpectations:
+ * fast/dom/HTMLAnchorElement/anchor-download-expected.txt:
+ * fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt: Added.
+ * fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html: Added.
+ * fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt:
+ * http/tests/security/anchor-download-allow-blob-expected.txt:
+ * platform/ios-simulator-wk1/TestExpectations:
+ * platform/mac-wk1/TestExpectations:
+ * platform/mac/TestExpectations:
+
+2016-09-24 Chris Dumez <[email protected]>
+
[WK2] anchor.download attribute value is ignored by NETWORK_SESSION code path
https://bugs.webkit.org/show_bug.cgi?id=162531
Modified: trunk/LayoutTests/TestExpectations (206355 => 206356)
--- trunk/LayoutTests/TestExpectations 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/TestExpectations 2016-09-25 02:39:38 UTC (rev 206356)
@@ -894,9 +894,6 @@
fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html [ ImageOnlyFailure ]
fast/scrolling/rtl-scrollbars-animation-property.html [ Failure ]
-# <a download> does not support Blobs
-webkit.org/b/156099 http/tests/security/anchor-download-allow-blob.html [ Failure ]
-
# <a download> does not honor cross-origin restrictions
webkit.org/b/156100 http/tests/security/anchor-download-block-crossorigin.html [ Failure ]
Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt (206355 => 206356)
--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt 2016-09-25 02:39:38 UTC (rev 206356)
@@ -1,4 +1,4 @@
+Downloading URL with suggested filename ""
Download started.
-Download failed.
-Failed: NSURLErrorDomain, code=-1002, description=unsupported URL
+Download completed.
Blob URL
Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt (0 => 206356)
--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click-expected.txt 2016-09-25 02:39:38 UTC (rev 206356)
@@ -0,0 +1,5 @@
+Test that synthetic clicks on an anchor with a download attribute are ignored.
+
+This test passes if you do not see any 'Download started' message above.
+
+Blob URL
Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html (0 => 206356)
--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html 2016-09-25 02:39:38 UTC (rev 206356)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/_javascript_'>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>Test that synthetic clicks on an anchor with a download attribute are ignored.</p>
+<p> This test passes if you do not see any 'Download started' message above.</p>
+<a id="blob-url" download>Blob URL</a>
+<script>
+function runTest()
+{
+ var string = "test";
+ var blob = new Blob([string], {type: "text/html"});
+ var link = document.getElementById("blob-url");
+ link.href = ""
+ link.click();
+ setTimeout(function() {
+ testRunner.notifyDone();
+ }, 100);
+}
+runTest();
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt (206355 => 206356)
--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt 2016-09-25 02:39:38 UTC (rev 206356)
@@ -1,4 +1,4 @@
+Downloading URL with suggested filename ""
Download started.
-Download failed.
-Failed: NSURLErrorDomain, code=-1002, description=unsupported URL
+Download completed.
Blob URL
Modified: trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt (206355 => 206356)
--- trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/http/tests/security/anchor-download-allow-blob-expected.txt 2016-09-25 02:39:38 UTC (rev 206356)
@@ -1,4 +1,11 @@
Downloading URL with suggested filename "foo.pdf"
+Download started.
+Download completed.
Tests that a suggested filename on a download attribute is allowed if the link is a blob URL.
The suggested filename at the top should be foo.pdf.
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (206355 => 206356)
--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations 2016-09-25 02:39:38 UTC (rev 206356)
@@ -1312,7 +1312,8 @@
webkit.org/b/155495 compositing/visible-rect/animated-from-none.html [ Failure Pass ]
-# <a download> is not support in WK1 yet.
+# <a download> is not supported in WK1 yet.
+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
webkit.org/b/156069 http/tests/security/anchor-download-allow-blob.html [ Skip ]
webkit.org/b/156069 http/tests/security/anchor-download-allow-data.html [ Skip ]
webkit.org/b/156069 http/tests/security/anchor-download-allow-sameorigin.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac/TestExpectations (206355 => 206356)
--- trunk/LayoutTests/platform/mac/TestExpectations 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2016-09-25 02:39:38 UTC (rev 206356)
@@ -1380,11 +1380,6 @@
# <rdar://problem/25279189> LayoutTest http/tests/security/mixedContent/insecure-audio-video-in-main-frame.html is flaky
[ Sierra+ ] http/tests/security/mixedContent/insecure-audio-video-in-main-frame.html [ Pass Failure ]
-# <rdar://problem/25536266> [Mac][iOS][NETWORK_SESSION] Unable to download BLOB URLs (156180)
-[ Sierra+ ] fast/dom/HTMLAnchorElement/anchor-download.html [ Skip ]
-[ Sierra+ ] fast/dom/HTMLAnchorElement/anchor-nodownload-set.html [ Skip ]
-[ Sierra+ ] http/tests/security/anchor-download-allow-blob.html [ Skip ]
-
# <rdar://problem/25780035> CSP does not ignore paths for media redirects
[ Sierra+ ] http/tests/security/contentSecurityPolicy/audio-redirect-allowed2.html [ Skip ]
[ Sierra+ ] http/tests/security/contentSecurityPolicy/video-redirect-allowed2.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (206355 => 206356)
--- trunk/LayoutTests/platform/mac-wk1/TestExpectations 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2016-09-25 02:39:38 UTC (rev 206356)
@@ -187,9 +187,10 @@
# This hit-test test doesn't work on DRT
webkit.org/b/156084 accessibility/mac/video-tag-hit-test.html [ Skip ]
-# <a download> is not support in WK1 yet.
+# <a download> is not supported in WK1 yet.
webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-nodownload-set.html [ Failure ]
webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download.html [ Failure ]
+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
webkit.org/b/156069 http/tests/security/anchor-download-allow-blob.html [ Skip ]
webkit.org/b/156069 http/tests/security/anchor-download-allow-data.html [ Skip ]
webkit.org/b/156069 http/tests/security/anchor-download-allow-sameorigin.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (206355 => 206356)
--- trunk/Source/WebCore/ChangeLog 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebCore/ChangeLog 2016-09-25 02:39:38 UTC (rev 206356)
@@ -1,3 +1,25 @@
+2016-09-24 Chris Dumez <[email protected]>
+
+ <a download> does not support Blob URLs
+ https://bugs.webkit.org/show_bug.cgi?id=156099
+ <rdar://problem/25535520>
+
+ Reviewed by Darin Adler.
+
+ Only allow trusted events to trigger downloads for <a download>, as per:
+ - https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation
+
+ Without this, a script could download a file to the user's disk without
+ any user gesture or consent, simply by calling a.click(). I have confirmed
+ that Firefox also ignores the click for <a download> if it is synthetic.
+ Chrome allows synthetic clicks to trigger downloads but I filed a bug
+ about it.
+
+ Test: fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html
+
+ * html/HTMLAnchorElement.cpp:
+ (WebCore::HTMLAnchorElement::handleClick):
+
2016-09-24 Yusuke Suzuki <[email protected]>
[Binding] setDOMException should be inlined and fall to the slow path if exception occurs
Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (206355 => 206356)
--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp 2016-09-25 02:39:38 UTC (rev 206356)
@@ -367,8 +367,14 @@
auto downloadAttribute = nullAtom;
#if ENABLE(DOWNLOAD_ATTRIBUTE)
- if (RuntimeEnabledFeatures::sharedFeatures().downloadAttributeEnabled())
+ if (RuntimeEnabledFeatures::sharedFeatures().downloadAttributeEnabled()) {
downloadAttribute = attributeWithoutSynchronization(downloadAttr);
+ // If the a element has a download attribute and the algorithm is not triggered by user activation
+ // then abort these steps.
+ // https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation
+ if (!downloadAttribute.isNull() && !event.isTrusted())
+ return;
+ }
#endif
frame->loader().urlSelected(kurl, target(), &event, LockHistory::No, LockBackForwardList::No, hasRel(RelationNoReferrer) ? NeverSendReferrer : MaybeSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate(), downloadAttribute);
Modified: trunk/Source/WebKit2/CMakeLists.txt (206355 => 206356)
--- trunk/Source/WebKit2/CMakeLists.txt 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/CMakeLists.txt 2016-09-25 02:39:38 UTC (rev 206356)
@@ -213,6 +213,7 @@
NetworkProcess/NetworkProcessCreationParameters.cpp
NetworkProcess/NetworkResourceLoadParameters.cpp
+ NetworkProcess/Downloads/BlobDownloadClient.cpp
NetworkProcess/Downloads/Download.cpp
NetworkProcess/Downloads/DownloadManager.cpp
Modified: trunk/Source/WebKit2/ChangeLog (206355 => 206356)
--- trunk/Source/WebKit2/ChangeLog 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/ChangeLog 2016-09-25 02:39:38 UTC (rev 206356)
@@ -1,5 +1,54 @@
2016-09-24 Chris Dumez <[email protected]>
+ <a download> does not support Blob URLs
+ https://bugs.webkit.org/show_bug.cgi?id=156099
+ <rdar://problem/25535520>
+
+ Reviewed by Darin Adler.
+
+ Add support for downloading Blob URLs to WebKit2. This should work for
+ all WebKit2 port. This also works in combination with the download
+ attribute on anchor elements. Note that the download attribute is only
+ enabled at runtime in the context of the layout tests for now. I'll
+ enable the download attribute on WK2 once I have fixed Bug 162531.
+
+ * CMakeLists.txt:
+ * NetworkProcess/Downloads/BlobDownloadClient.cpp: Added.
+ (WebKit::BlobDownloadClient::BlobDownloadClient):
+ (WebKit::BlobDownloadClient::didReceiveResponse):
+ (WebKit::BlobDownloadClient::didReceiveBuffer):
+ (WebKit::BlobDownloadClient::didFinishLoading):
+ (WebKit::BlobDownloadClient::didFail):
+ * NetworkProcess/Downloads/BlobDownloadClient.h: Added.
+ * NetworkProcess/Downloads/Download.cpp:
+ (WebKit::Download::Download):
+ (WebKit::Download::start):
+ (WebKit::Download::didStart):
+ (WebKit::Download::didReceiveResponse):
+ (WebKit::Download::decideDestinationWithSuggestedFilename):
+ (WebKit::Download::~Download): Deleted.
+ (WebKit::Download::didReceiveData): Deleted.
+ (WebKit::Download::shouldDecodeSourceDataOfMIMEType): Deleted.
+ * NetworkProcess/Downloads/Download.h:
+ (WebKit::Download::Download):
+ (WebKit::Download::suggestedName):
+ (WebKit::Download::request):
+ * NetworkProcess/Downloads/DownloadManager.cpp:
+ (WebKit::DownloadManager::startDownload):
+ * NetworkProcess/Downloads/ios/DownloadIOS.mm:
+ (WebKit::Download::startNetworkLoad):
+ * NetworkProcess/Downloads/mac/DownloadMac.mm:
+ (WebKit::Download::startNetworkLoad):
+ * NetworkProcess/Downloads/soup/DownloadSoup.cpp:
+ (WebKit::Download::startNetworkLoad):
+ * UIProcess/Downloads/DownloadProxy.cpp:
+ (WebKit::DownloadProxy::decideDestinationWithSuggestedFilename):
+ * UIProcess/Downloads/DownloadProxy.h:
+ * UIProcess/Downloads/DownloadProxy.messages.in:
+ * WebKit2.xcodeproj/project.pbxproj:
+
+2016-09-24 Chris Dumez <[email protected]>
+
[WK2] anchor.download attribute value is ignored by NETWORK_SESSION code path
https://bugs.webkit.org/show_bug.cgi?id=162531
Added: trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp (0 => 206356)
--- trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.cpp 2016-09-25 02:39:38 UTC (rev 206356)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2016 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 "BlobDownloadClient.h"
+
+#include "DataReference.h"
+#include "Download.h"
+#include "WebErrors.h"
+#include <WebCore/ResourceError.h>
+#include <WebCore/SharedBuffer.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+BlobDownloadClient::BlobDownloadClient(Download& download)
+ : m_download(download)
+{
+}
+
+void BlobDownloadClient::didReceiveResponse(ResourceHandle*, ResourceResponse&& response)
+{
+ m_download.didReceiveResponse(WTFMove(response));
+
+ bool allowOverwrite = false;
+ m_destinationPath = m_download.decideDestinationWithSuggestedFilename(m_download.suggestedName(), allowOverwrite);
+ if (m_destinationPath.isEmpty()) {
+ didFail(nullptr, cancelledError(m_download.request()));
+ return;
+ }
+ if (fileExists(m_destinationPath)) {
+ if (!allowOverwrite) {
+ m_destinationPath = emptyString();
+ didFail(nullptr, cancelledError(m_download.request()));
+ return;
+ }
+ deleteFile(m_destinationPath);
+ }
+
+ m_destinationFile = openFile(m_destinationPath, OpenForWrite);
+ m_download.didCreateDestination(m_destinationPath);
+}
+
+void BlobDownloadClient::didReceiveBuffer(ResourceHandle*, Ref<SharedBuffer>&& buffer, int)
+{
+ writeToFile(m_destinationFile, buffer->data(), buffer->size());
+ m_download.didReceiveData(buffer->size());
+}
+
+void BlobDownloadClient::didFinishLoading(ResourceHandle*, double)
+{
+ closeFile(m_destinationFile);
+ m_download.didFinish();
+}
+
+void BlobDownloadClient::didFail(ResourceHandle*, const ResourceError& error)
+{
+ closeFile(m_destinationFile);
+ if (!m_destinationPath.isEmpty())
+ deleteFile(m_destinationPath);
+
+ m_download.didFail(error, IPC::DataReference());
+}
+
+}
Added: trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.h (0 => 206356)
--- trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.h (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/BlobDownloadClient.h 2016-09-25 02:39:38 UTC (rev 206356)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <WebCore/FileSystem.h>
+#include <WebCore/ResourceHandleClient.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class Download;
+class NetworkLoadParameters;
+
+class BlobDownloadClient final : public WebCore::ResourceHandleClient {
+public:
+ explicit BlobDownloadClient(Download&);
+
+private:
+ // ResourceHandleClient
+ void didReceiveResponse(WebCore::ResourceHandle*, WebCore::ResourceResponse&&) final;
+ void didReceiveBuffer(WebCore::ResourceHandle*, Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) final;
+ void didFinishLoading(WebCore::ResourceHandle*, double finishTime) final;
+ void didFail(WebCore::ResourceHandle*, const WebCore::ResourceError&) final;
+
+ Download& m_download;
+ String m_destinationPath;
+ WebCore::PlatformFileHandle m_destinationFile { WebCore::invalidPlatformFileHandle };
+};
+
+}
Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp (206355 => 206356)
--- trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/Download.cpp 2016-09-25 02:39:38 UTC (rev 206356)
@@ -27,6 +27,7 @@
#include "Download.h"
#include "AuthenticationManager.h"
+#include "BlobDownloadClient.h"
#include "Connection.h"
#include "DataReference.h"
#include "DownloadManager.h"
@@ -44,18 +45,21 @@
#if USE(NETWORK_SESSION) && PLATFORM(COCOA)
Download::Download(DownloadManager& downloadManager, DownloadID downloadID, NSURLSessionDownloadTask* download, const WebCore::SessionID& sessionID, const String& suggestedName)
-#else
+ : m_downloadManager(downloadManager)
+ , m_downloadID(downloadID)
+ , m_download(download)
+ , m_suggestedName(suggestedName)
+{
+ ASSERT(m_downloadID.downloadID());
+
+ m_downloadManager.didCreateDownload();
+}
+#endif
+
Download::Download(DownloadManager& downloadManager, DownloadID downloadID, const ResourceRequest& request, const String& suggestedName)
-#endif
: m_downloadManager(downloadManager)
, m_downloadID(downloadID)
-#if !USE(NETWORK_SESSION)
, m_request(request)
-#endif
-#if USE(NETWORK_SESSION) && PLATFORM(COCOA)
- , m_download(download)
- , m_sessionID(sessionID)
-#endif
, m_suggestedName(suggestedName)
{
ASSERT(m_downloadID.downloadID());
@@ -70,12 +74,26 @@
m_downloadManager.didDestroyDownload();
}
-#if !USE(NETWORK_SESSION)
+void Download::start()
+{
+ if (m_request.url().protocolIsBlob()) {
+ m_downloadClient = std::make_unique<BlobDownloadClient>(*this);
+ m_resourceHandle = ResourceHandle::create(nullptr, m_request, m_downloadClient.get(), false, false);
+ didStart();
+ return;
+ }
+
+#if USE(NETWORK_SESSION)
+ ASSERT_NOT_REACHED();
+#else
+ startNetworkLoad();
+#endif
+}
+
void Download::didStart()
{
send(Messages::DownloadProxy::DidStart(m_request, m_suggestedName));
}
-#endif
#if !USE(NETWORK_SESSION)
void Download::didReceiveAuthenticationChallenge(const AuthenticationChallenge& authenticationChallenge)
@@ -82,6 +100,7 @@
{
m_downloadManager.downloadsAuthenticationManager().didReceiveAuthenticationChallenge(*this, authenticationChallenge);
}
+#endif
void Download::didReceiveResponse(const ResourceResponse& response)
{
@@ -89,7 +108,6 @@
send(Messages::DownloadProxy::DidReceiveResponse(response));
}
-#endif
void Download::didReceiveData(uint64_t length)
{
@@ -110,7 +128,6 @@
return result;
}
-#if !USE(NETWORK_SESSION)
String Download::decideDestinationWithSuggestedFilename(const String& filename, bool& allowOverwrite)
{
String destination;
@@ -124,7 +141,6 @@
return destination;
}
-#endif
void Download::didCreateDestination(const String& path)
{
Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h (206355 => 206356)
--- trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/Download.h 2016-09-25 02:39:38 UTC (rev 206356)
@@ -29,8 +29,11 @@
#include "DownloadID.h"
#include "MessageSender.h"
#include "SandboxExtension.h"
+#include <WebCore/ResourceHandle.h>
+#include <WebCore/ResourceHandleClient.h>
#include <WebCore/ResourceRequest.h>
#include <WebCore/SessionID.h>
+#include <memory>
#include <wtf/Noncopyable.h>
#if PLATFORM(COCOA)
@@ -44,12 +47,6 @@
#endif
#endif
-#if PLATFORM(GTK) || PLATFORM(EFL)
-#include <WebCore/ResourceHandle.h>
-#include <WebCore/ResourceHandleClient.h>
-#include <memory>
-#endif
-
#if USE(CFNETWORK)
#include <CFNetwork/CFURLDownloadPriv.h>
#endif
@@ -77,13 +74,14 @@
public:
#if USE(NETWORK_SESSION) && PLATFORM(COCOA)
Download(DownloadManager&, DownloadID, NSURLSessionDownloadTask*, const WebCore::SessionID& sessionID, const String& suggestedFilename = { });
-#else
+#endif
Download(DownloadManager&, DownloadID, const WebCore::ResourceRequest&, const String& suggestedFilename = { });
-#endif
+
~Download();
+ void start();
+
#if !USE(NETWORK_SESSION)
- void start();
void startWithHandle(WebCore::ResourceHandle*, const WebCore::ResourceResponse&);
#endif
void resume(const IPC::DataReference& resumeData, const String& path, const SandboxExtension::Handle&);
@@ -90,19 +88,19 @@
void cancel();
DownloadID downloadID() const { return m_downloadID; }
+ const String& suggestedName() const { return m_suggestedName; }
+ const WebCore::ResourceRequest& request() const { return m_request; }
#if USE(NETWORK_SESSION)
void setSandboxExtension(RefPtr<SandboxExtension>&& sandboxExtension) { m_sandboxExtension = WTFMove(sandboxExtension); }
#else
+ void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&);
+#endif
void didStart();
- void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&);
void didReceiveResponse(const WebCore::ResourceResponse&);
-#endif
void didReceiveData(uint64_t length);
bool shouldDecodeSourceDataOfMIMEType(const String& mimeType);
-#if !USE(NETWORK_SESSION)
String decideDestinationWithSuggestedFilename(const String& filename, bool& allowOverwrite);
-#endif
void didCreateDestination(const String& path);
void didFinish();
void platformDidFinish();
@@ -114,6 +112,10 @@
IPC::Connection* messageSenderConnection() override;
uint64_t messageSenderDestinationID() override;
+#if !USE(NETWORK_SESSION)
+ void startNetworkLoad();
+#endif
+
void platformInvalidate();
bool isAlwaysOnLoggingAllowed() const;
@@ -120,9 +122,7 @@
DownloadManager& m_downloadManager;
DownloadID m_downloadID;
-#if !USE(NETWORK_SESSION)
WebCore::ResourceRequest m_request;
-#endif
RefPtr<SandboxExtension> m_sandboxExtension;
@@ -138,10 +138,8 @@
#if USE(CFNETWORK)
RetainPtr<CFURLDownloadRef> m_download;
#endif
-#if PLATFORM(GTK) || PLATFORM(EFL)
std::unique_ptr<WebCore::ResourceHandleClient> m_downloadClient;
RefPtr<WebCore::ResourceHandle> m_resourceHandle;
-#endif
String m_suggestedName;
bool m_hasReceivedData { false };
};
Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp (206355 => 206356)
--- trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/DownloadManager.cpp 2016-09-25 02:39:38 UTC (rev 206356)
@@ -47,21 +47,23 @@
void DownloadManager::startDownload(SessionID sessionID, DownloadID downloadID, const ResourceRequest& request, const String& suggestedName)
{
#if USE(NETWORK_SESSION)
- auto* networkSession = SessionTracker::networkSession(sessionID);
- if (!networkSession)
+ if (!request.url().protocolIsBlob()) {
+ auto* networkSession = SessionTracker::networkSession(sessionID);
+ if (!networkSession)
+ return;
+ NetworkLoadParameters parameters;
+ parameters.sessionID = sessionID;
+ parameters.request = request;
+ parameters.clientCredentialPolicy = ClientCredentialPolicy::MayAskClientForCredentials;
+ m_pendingDownloads.add(downloadID, std::make_unique<PendingDownload>(WTFMove(parameters), downloadID, *networkSession, suggestedName));
return;
- NetworkLoadParameters parameters;
- parameters.sessionID = sessionID;
- parameters.request = request;
- parameters.clientCredentialPolicy = ClientCredentialPolicy::MayAskClientForCredentials;
- m_pendingDownloads.add(downloadID, std::make_unique<PendingDownload>(WTFMove(parameters), downloadID, *networkSession, suggestedName));
-#else
+ }
+#endif
auto download = std::make_unique<Download>(*this, downloadID, request, suggestedName);
download->start();
ASSERT(!m_downloads.contains(downloadID));
m_downloads.add(downloadID, WTFMove(download));
-#endif
}
#if USE(NETWORK_SESSION)
Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/ios/DownloadIOS.mm (206355 => 206356)
--- trunk/Source/WebKit2/NetworkProcess/Downloads/ios/DownloadIOS.mm 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/ios/DownloadIOS.mm 2016-09-25 02:39:38 UTC (rev 206356)
@@ -122,7 +122,7 @@
};
}
-void Download::start()
+void Download::startNetworkLoad()
{
notImplemented();
}
Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/mac/DownloadMac.mm (206355 => 206356)
--- trunk/Source/WebKit2/NetworkProcess/Downloads/mac/DownloadMac.mm 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/mac/DownloadMac.mm 2016-09-25 02:39:38 UTC (rev 206356)
@@ -49,7 +49,7 @@
namespace WebKit {
-void Download::start()
+void Download::startNetworkLoad()
{
ASSERT(!m_nsURLDownload);
ASSERT(!m_delegate);
Modified: trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.cpp (206355 => 206356)
--- trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.cpp 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/NetworkProcess/Downloads/soup/DownloadSoup.cpp 2016-09-25 02:39:38 UTC (rev 206356)
@@ -207,7 +207,7 @@
bool m_allowOverwrite;
};
-void Download::start()
+void Download::startNetworkLoad()
{
ASSERT(!m_downloadClient);
ASSERT(!m_resourceHandle);
Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp (206355 => 206356)
--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2016-09-25 02:39:38 UTC (rev 206356)
@@ -189,7 +189,8 @@
if (NetworkProcessProxy* networkProcess = m_processPool->networkProcess())
networkProcess->connection()->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite), 0);
}
-#else
+#endif
+
void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle)
{
allowOverwrite = false;
@@ -206,7 +207,6 @@
if (!destination.isNull())
SandboxExtension::createHandle(destination, SandboxExtension::ReadWrite, sandboxExtensionHandle);
}
-#endif
void DownloadProxy::didCreateDestination(const String& path)
{
Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h (206355 => 206356)
--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h 2016-09-25 02:39:38 UTC (rev 206356)
@@ -82,9 +82,7 @@
void didReceiveResponse(const WebCore::ResourceResponse&);
void didReceiveData(uint64_t length);
void shouldDecodeSourceDataOfMIMEType(const String& mimeType, bool& result);
-#if !USE(NETWORK_SESSION)
void decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle);
-#endif
void didCreateDestination(const String& path);
void didFinish();
void didFail(const WebCore::ResourceError&, const IPC::DataReference& resumeData);
Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in (206355 => 206356)
--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in 2016-09-25 02:39:38 UTC (rev 206356)
@@ -32,9 +32,7 @@
DidReceiveResponse(WebCore::ResourceResponse response)
DidReceiveData(uint64_t length)
ShouldDecodeSourceDataOfMIMEType(String mimeType) -> (bool result)
-#if !USE(NETWORK_SESSION)
DecideDestinationWithSuggestedFilename(String filename) -> (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
-#endif
DidCreateDestination(String path)
DidFinish()
DidFail(WebCore::ResourceError error, IPC::DataReference resumeData)
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (206355 => 206356)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-09-25 01:00:02 UTC (rev 206355)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-09-25 02:39:38 UTC (rev 206356)
@@ -1213,6 +1213,8 @@
839902021BE9A02B000F3653 /* NetworkLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 839901FF1BE9A01B000F3653 /* NetworkLoad.cpp */; };
839902031BE9A02B000F3653 /* NetworkLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 839901FE1BE9A01B000F3653 /* NetworkLoad.h */; };
83BDCCB91AC5FDB6003F6441 /* NetworkCacheStatistics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BDCCB81AC5FDB6003F6441 /* NetworkCacheStatistics.cpp */; };
+ 83BFAC421D96137C00433490 /* BlobDownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BFAC401D96136000433490 /* BlobDownloadClient.h */; };
+ 83BFAC431D96137C00433490 /* BlobDownloadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BFAC411D96136000433490 /* BlobDownloadClient.cpp */; };
83D454D71BE9D3C4006C93BD /* NetworkLoadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D454D61BE9D3C4006C93BD /* NetworkLoadClient.h */; };
84477853176FCC0800CDC7BB /* InjectedBundleHitTestResultMediaType.h in Headers */ = {isa = PBXBuildFile; fileRef = 84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */; };
868160D0187645570021E79D /* WindowServerConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 868160CF187645370021E79D /* WindowServerConnection.mm */; };
@@ -3308,6 +3310,8 @@
839901FE1BE9A01B000F3653 /* NetworkLoad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkLoad.h; path = NetworkProcess/NetworkLoad.h; sourceTree = "<group>"; };
839901FF1BE9A01B000F3653 /* NetworkLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkLoad.cpp; path = NetworkProcess/NetworkLoad.cpp; sourceTree = "<group>"; };
83BDCCB81AC5FDB6003F6441 /* NetworkCacheStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheStatistics.cpp; sourceTree = "<group>"; };
+ 83BFAC401D96136000433490 /* BlobDownloadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlobDownloadClient.h; path = NetworkProcess/Downloads/BlobDownloadClient.h; sourceTree = "<group>"; };
+ 83BFAC411D96136000433490 /* BlobDownloadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BlobDownloadClient.cpp; path = NetworkProcess/Downloads/BlobDownloadClient.cpp; sourceTree = "<group>"; };
83D454D61BE9D3C4006C93BD /* NetworkLoadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkLoadClient.h; path = NetworkProcess/NetworkLoadClient.h; sourceTree = "<group>"; };
84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleHitTestResultMediaType.h; sourceTree = "<group>"; };
868160CD18763D4B0021E79D /* WindowServerConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WindowServerConnection.h; sourceTree = "<group>"; };
@@ -5738,6 +5742,8 @@
5C1427081C23F85200D41183 /* cocoa */,
5C14270C1C23F87700D41183 /* ios */,
5C14270B1C23F87100D41183 /* mac */,
+ 83BFAC401D96136000433490 /* BlobDownloadClient.h */,
+ 83BFAC411D96136000433490 /* BlobDownloadClient.cpp */,
5C1426F31C23F84300D41183 /* Download.cpp */,
5C1426F41C23F84300D41183 /* Download.h */,
5C1426F71C23F84300D41183 /* DownloadID.h */,
@@ -7612,6 +7618,7 @@
2984F57D164B915F004BC0C6 /* CustomProtocolManagerProxyMessages.h in Headers */,
515E772C184008B90007203F /* DatabaseProcessCreationParameters.h in Headers */,
512A9761180E031D0039A149 /* DatabaseProcessMessages.h in Headers */,
+ 83BFAC421D96137C00433490 /* BlobDownloadClient.h in Headers */,
517DD5BF180DA7D30081660B /* DatabaseProcessProxy.h in Headers */,
512A976A180E09B80039A149 /* DatabaseProcessProxyMessages.h in Headers */,
51032F1E180F791700961BB7 /* DatabaseToWebProcessConnectionMessages.h in Headers */,
@@ -9149,6 +9156,7 @@
0F0C365E18C110A500F607D7 /* LayerRepresentation.mm in Sources */,
1A92DC1312F8BAB90017AF65 /* LayerTreeContext.cpp in Sources */,
1AFDE64519510B5500C48FFA /* LegacyBundleForClass.mm in Sources */,
+ 83BFAC431D96137C00433490 /* BlobDownloadClient.cpp in Sources */,
1AFDE65D1954E8D500C48FFA /* LegacySessionStateCoding.cpp in Sources */,
2D1087601D2C573E00B85F82 /* LoadParameters.cpp in Sources */,
2D1087631D2C641B00B85F82 /* LoadParametersCocoa.mm in Sources */,