WinLauncher fails to download files.
authorpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jun 2015 18:23:18 +0000 (18:23 +0000)
committerpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jun 2015 18:23:18 +0000 (18:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146242

Reviewed by Alex Christensen.

Source/WebKit/win:

Don't start download when there is no download delegate.

* WebView.cpp:
(WebView::downloadURL):

Tools:

Added WinLauncher download delegate.

* WinLauncher/Common.cpp:
* WinLauncher/WebDownloadDelegate.cpp: Added.
(WebDownloadDelegate::WebDownloadDelegate):
(WebDownloadDelegate::~WebDownloadDelegate):
(WebDownloadDelegate::QueryInterface):
(WebDownloadDelegate::AddRef):
(WebDownloadDelegate::Release):
(WebDownloadDelegate::decideDestinationWithSuggestedFilename):
(WebDownloadDelegate::didCancelAuthenticationChallenge):
(WebDownloadDelegate::didCreateDestination):
(WebDownloadDelegate::didFailWithError):
(WebDownloadDelegate::didReceiveAuthenticationChallenge):
(WebDownloadDelegate::didReceiveDataOfLength):
(WebDownloadDelegate::didReceiveResponse):
(WebDownloadDelegate::shouldDecodeSourceDataOfMIMEType):
(WebDownloadDelegate::willResumeWithResponse):
(WebDownloadDelegate::willSendRequest):
(WebDownloadDelegate::didBegin):
(WebDownloadDelegate::didFinish):
* WinLauncher/WebDownloadDelegate.h: Added.
* WinLauncher/WinLauncher.cpp:
(WinLauncher::setAccessibilityDelegate):
(WinLauncher::setResourceLoadDelegate):
(WinLauncher::setDownloadDelegate):
(WinLauncher::mainFrame):
* WinLauncher/WinLauncher.h:
(WinLauncher::standardPreferences):
(WinLauncher::privatePreferences):
* WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj:
* WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters:
* WinLauncher/WinMain.cpp:
(wWinMain):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186004 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/win/ChangeLog
Source/WebKit/win/WebView.cpp
Tools/ChangeLog
Tools/WinLauncher/Common.cpp
Tools/WinLauncher/WebDownloadDelegate.cpp [new file with mode: 0644]
Tools/WinLauncher/WebDownloadDelegate.h [new file with mode: 0644]
Tools/WinLauncher/WinLauncher.cpp
Tools/WinLauncher/WinLauncher.h
Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj
Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters
Tools/WinLauncher/WinMain.cpp

index bc26b7b..6a08563 100644 (file)
@@ -1,3 +1,15 @@
+2015-06-26  Per Arne Vollan  <peavo@outlook.com>
+
+        WinLauncher fails to download files.
+        https://bugs.webkit.org/show_bug.cgi?id=146242
+
+        Reviewed by Alex Christensen.
+
+        Don't start download when there is no download delegate.
+
+        * WebView.cpp:
+        (WebView::downloadURL):
+
 2015-06-26  Hyungwook Lee  <hyungwook.lee@navercorp.com>
 
         [Win] Implement WebViewGroup to support WebView::addxxxToGroup().
index f5d0945..80946fe 100644 (file)
@@ -6543,6 +6543,9 @@ HRESULT WebView::addVisitedLinks(BSTR* visitedURLs, unsigned visitedURLCount)
 
 void WebView::downloadURL(const URL& url)
 {
+    if (!m_downloadDelegate)
+        return;
+
     // It's the delegate's job to ref the WebDownload to keep it alive - otherwise it will be
     // destroyed when this function returns.
 #if USE(CURL)
index 7cee00a..1971048 100644 (file)
@@ -1,3 +1,45 @@
+2015-06-26  Per Arne Vollan  <peavo@outlook.com>
+
+        WinLauncher fails to download files.
+        https://bugs.webkit.org/show_bug.cgi?id=146242
+
+        Reviewed by Alex Christensen.
+
+        Added WinLauncher download delegate.
+
+        * WinLauncher/Common.cpp:
+        * WinLauncher/WebDownloadDelegate.cpp: Added.
+        (WebDownloadDelegate::WebDownloadDelegate):
+        (WebDownloadDelegate::~WebDownloadDelegate):
+        (WebDownloadDelegate::QueryInterface):
+        (WebDownloadDelegate::AddRef):
+        (WebDownloadDelegate::Release):
+        (WebDownloadDelegate::decideDestinationWithSuggestedFilename):
+        (WebDownloadDelegate::didCancelAuthenticationChallenge):
+        (WebDownloadDelegate::didCreateDestination):
+        (WebDownloadDelegate::didFailWithError):
+        (WebDownloadDelegate::didReceiveAuthenticationChallenge):
+        (WebDownloadDelegate::didReceiveDataOfLength):
+        (WebDownloadDelegate::didReceiveResponse):
+        (WebDownloadDelegate::shouldDecodeSourceDataOfMIMEType):
+        (WebDownloadDelegate::willResumeWithResponse):
+        (WebDownloadDelegate::willSendRequest):
+        (WebDownloadDelegate::didBegin):
+        (WebDownloadDelegate::didFinish):
+        * WinLauncher/WebDownloadDelegate.h: Added.
+        * WinLauncher/WinLauncher.cpp:
+        (WinLauncher::setAccessibilityDelegate):
+        (WinLauncher::setResourceLoadDelegate):
+        (WinLauncher::setDownloadDelegate):
+        (WinLauncher::mainFrame):
+        * WinLauncher/WinLauncher.h:
+        (WinLauncher::standardPreferences):
+        (WinLauncher::privatePreferences):
+        * WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj:
+        * WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters:
+        * WinLauncher/WinMain.cpp:
+        (wWinMain):
+
 2015-06-26  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [EFL] Bump libseccomp version to 2.2.1
index 90cfc5b..b8657c7 100644 (file)
@@ -30,6 +30,7 @@
 #include "DOMDefaultImpl.h"
 #include "PrintWebUIDelegate.h"
 #include "ResourceLoadDelegate.h"
+#include "WebDownloadDelegate.h"
 #include "WinLauncher.h"
 #include "WinLauncherReplace.h"
 #include <WebKit/WebKitCOMAPI.h>
diff --git a/Tools/WinLauncher/WebDownloadDelegate.cpp b/Tools/WinLauncher/WebDownloadDelegate.cpp
new file mode 100644 (file)
index 0000000..b7fabd2
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+* Copyright (C) 2015 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. ``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
+* 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 "stdafx.h"
+#include "WebDownloadDelegate.h"
+
+#include <shlobj.h>
+
+WebDownloadDelegate::WebDownloadDelegate()
+    : m_refCount(1)
+{
+}
+
+WebDownloadDelegate::~WebDownloadDelegate()
+{
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::QueryInterface(REFIID riid, void** ppvObject)
+{
+    *ppvObject = 0;
+
+    if (IsEqualGUID(riid, IID_IUnknown))
+        *ppvObject = static_cast<IWebDownloadDelegate*>(this);
+    else if (IsEqualGUID(riid, IID_IWebDownloadDelegate))
+        *ppvObject = static_cast<IWebDownloadDelegate*>(this);
+    else
+        return E_NOINTERFACE;
+
+    AddRef();
+    return S_OK;
+}
+
+ULONG STDMETHODCALLTYPE WebDownloadDelegate::AddRef(void)
+{
+    m_refCount++;
+    return m_refCount;
+}
+
+ULONG STDMETHODCALLTYPE WebDownloadDelegate::Release(void)
+{
+    m_refCount--;
+    int refCount = m_refCount;
+    if (!refCount)
+        delete this;
+    return refCount;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::decideDestinationWithSuggestedFilename(IWebDownload* download, BSTR filename)
+{
+    wchar_t desktopDirectory[MAX_PATH];
+    if (FAILED(SHGetFolderPathW(0, CSIDL_DESKTOP, 0, 0, desktopDirectory)))
+        return E_FAIL;
+
+    _bstr_t destination = _bstr_t(desktopDirectory) + L"\\" + ::PathFindFileNameW(filename);
+
+    if (::PathFileExists(destination))
+        return E_FAIL;
+
+    download->setDestination(destination, TRUE);
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::didCancelAuthenticationChallenge(IWebDownload* download, IWebURLAuthenticationChallenge* challenge)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::didCreateDestination(IWebDownload* download, BSTR destination)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::didFailWithError(IWebDownload* download, IWebError* error)
+{
+    download->Release();
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::didReceiveAuthenticationChallenge(IWebDownload* download, IWebURLAuthenticationChallenge* challenge)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::didReceiveDataOfLength(IWebDownload* download, unsigned length)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::didReceiveResponse(IWebDownload* download, IWebURLResponse* response)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::shouldDecodeSourceDataOfMIMEType(IWebDownload* download, BSTR encodingType, BOOL* shouldDecode)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::willResumeWithResponse(IWebDownload* download, IWebURLResponse* response, long long fromByte)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::willSendRequest(IWebDownload* download, IWebMutableURLRequest* request, IWebURLResponse* redirectResponse, IWebMutableURLRequest** finalRequest)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::didBegin(IWebDownload* download)
+{
+    download->AddRef();
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebDownloadDelegate::didFinish(IWebDownload* download)
+{
+    download->Release();
+    return S_OK;
+}
diff --git a/Tools/WinLauncher/WebDownloadDelegate.h b/Tools/WinLauncher/WebDownloadDelegate.h
new file mode 100644 (file)
index 0000000..c967bd2
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+* Copyright (C) 2015 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. ``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
+* 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.
+*/
+
+#ifndef WebDownloadDelegate_h
+#define WebDownloadDelegate_h
+
+#include <WebKit/WebKit.h>
+#include <WebKit/WebKitCOMAPI.h>
+
+class WebDownloadDelegate : public IWebDownloadDelegate {
+public:
+    WebDownloadDelegate();
+    virtual ~WebDownloadDelegate();
+
+    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
+    virtual ULONG STDMETHODCALLTYPE AddRef(void);
+    virtual ULONG STDMETHODCALLTYPE Release(void);
+
+    virtual HRESULT STDMETHODCALLTYPE decideDestinationWithSuggestedFilename(IWebDownload*, BSTR filename);
+    virtual HRESULT STDMETHODCALLTYPE didCancelAuthenticationChallenge(IWebDownload*, IWebURLAuthenticationChallenge*);
+    virtual HRESULT STDMETHODCALLTYPE didCreateDestination(IWebDownload*, BSTR destination);
+    virtual HRESULT STDMETHODCALLTYPE didFailWithError(IWebDownload*, IWebError*);
+    virtual HRESULT STDMETHODCALLTYPE didReceiveAuthenticationChallenge(IWebDownload*, IWebURLAuthenticationChallenge*);
+    virtual HRESULT STDMETHODCALLTYPE didReceiveDataOfLength(IWebDownload*, unsigned length);
+    virtual HRESULT STDMETHODCALLTYPE didReceiveResponse(IWebDownload*, IWebURLResponse*);
+    virtual HRESULT STDMETHODCALLTYPE shouldDecodeSourceDataOfMIMEType(IWebDownload*, BSTR encodingType, BOOL* shouldDecode);
+    virtual HRESULT STDMETHODCALLTYPE willResumeWithResponse(IWebDownload*, IWebURLResponse*, long long fromByte);
+    virtual HRESULT STDMETHODCALLTYPE willSendRequest(IWebDownload*, IWebMutableURLRequest*, IWebURLResponse* redirectResponse, IWebMutableURLRequest** finalRequest);
+    virtual HRESULT STDMETHODCALLTYPE didBegin(IWebDownload*);
+    virtual HRESULT STDMETHODCALLTYPE didFinish(IWebDownload*);
+
+private:
+    int m_refCount;
+};
+
+#endif
index c32ab90..e1a67c8 100644 (file)
@@ -140,13 +140,18 @@ HRESULT WinLauncher::setAccessibilityDelegate(IAccessibilityDelegate* accessibil
     return m_webView->setAccessibilityDelegate(accessibilityDelegate);
 }
 
-
 HRESULT WinLauncher::setResourceLoadDelegate(IWebResourceLoadDelegate* resourceLoadDelegate)
 {
     m_resourceLoadDelegate = resourceLoadDelegate;
     return m_webView->setResourceLoadDelegate(resourceLoadDelegate);
 }
 
+HRESULT WinLauncher::setDownloadDelegate(IWebDownloadDelegatePtr downloadDelegate)
+{
+    m_downloadDelegate = downloadDelegate;
+    return m_webView->setDownloadDelegate(downloadDelegate);
+}
+
 IWebFramePtr WinLauncher::mainFrame()
 {
     IWebFramePtr framePtr;
index 1bac282..5d41850 100644 (file)
@@ -42,6 +42,7 @@ typedef _com_ptr_t<_com_IIID<IWebInspector, &__uuidof(IWebInspector)>> IWebInspe
 typedef _com_ptr_t<_com_IIID<IWebCoreStatistics, &__uuidof(IWebCoreStatistics)>> IWebCoreStatisticsPtr;
 typedef _com_ptr_t<_com_IIID<IWebCache, &__uuidof(IWebCache)>> IWebCachePtr;
 typedef _com_ptr_t<_com_IIID<IWebResourceLoadDelegate, &__uuidof(IWebResourceLoadDelegate)>> IWebResourceLoadDelegatePtr;
+typedef _com_ptr_t<_com_IIID<IWebDownloadDelegate, &__uuidof(IWebDownloadDelegate)>> IWebDownloadDelegatePtr;
 
 class WinLauncher {
 public:
@@ -65,6 +66,7 @@ public:
     HRESULT setUIDelegate(IWebUIDelegate*);
     HRESULT setAccessibilityDelegate(IAccessibilityDelegate*);
     HRESULT setResourceLoadDelegate(IWebResourceLoadDelegate*);
+    HRESULT setDownloadDelegate(IWebDownloadDelegatePtr);
 
     IWebPreferencesPtr standardPreferences() { return m_standardPreferences;  }
     IWebPreferencesPrivatePtr privatePreferences() { return m_prefsPrivate; }
@@ -105,6 +107,7 @@ private:
     IWebUIDelegatePtr m_uiDelegate;
     IAccessibilityDelegatePtr m_accessibilityDelegate;
     IWebResourceLoadDelegatePtr m_resourceLoadDelegate;
+    IWebDownloadDelegatePtr m_downloadDelegate;
 
     IWebCoreStatisticsPtr m_statistics;
     IWebCachePtr m_webCache;
index 1dcbbab..f987a6d 100644 (file)
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">Create</PrecompiledHeader>
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">Create</PrecompiledHeader>
     </ClCompile>
+    <ClCompile Include="..\WebDownloadDelegate.cpp" />
     <ClCompile Include="..\WinLauncher.cpp" />
     <ClCompile Include="..\WinLauncherWebHost.cpp" />
     <ClCompile Include="..\WinMain.cpp" />
     <ClInclude Include="..\PrintWebUIDelegate.h" />
     <ClInclude Include="..\ResourceLoadDelegate.h" />
     <ClInclude Include="..\stdafx.h" />
+    <ClInclude Include="..\WebDownloadDelegate.h" />
     <ClInclude Include="..\WinLauncher.h" />
     <ClInclude Include="..\WinLauncherReplace.h" />
     <ClInclude Include="..\WinLauncherWebHost.h" />
index 8a172f5..b05a41e 100644 (file)
@@ -55,6 +55,9 @@
     <ClCompile Include="..\PageLoadTestClient.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\WebDownloadDelegate.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\DOMDefaultImpl.h">
@@ -87,6 +90,9 @@
     <ClInclude Include="..\PageLoadTestClient.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\WebDownloadDelegate.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="WinLauncherLib.rc">
index fe2d6b3..ecd94bd 100644 (file)
@@ -97,6 +97,9 @@ int WINAPI wWinMain(HINSTANCE, HINSTANCE, PWSTR, int nCmdShow)
 
     WinLauncherWebHost* webHost = nullptr;
 
+    IWebDownloadDelegatePtr downloadDelegate;
+    downloadDelegate.Attach(new WebDownloadDelegate());
+
     gWinLauncher = new WinLauncher(hMainWnd, hURLBarWnd, usesLayeredWebView, pageLoadTesting);
     if (!gWinLauncher)
         goto exit;
@@ -136,6 +139,10 @@ int WINAPI wWinMain(HINSTANCE, HINSTANCE, PWSTR, int nCmdShow)
     if (FAILED(hr))
         goto exit;
 
+    hr = gWinLauncher->setDownloadDelegate(downloadDelegate);
+    if (FAILED(hr))
+        goto exit;
+
     hr = gWinLauncher->prepareViews(hMainWnd, clientRect, requestedURL.GetBSTR(), gViewWindow);
     if (FAILED(hr) || !gViewWindow)
         goto exit;