Skip to content
Permalink
Browse files
Move WebContextMenuClient's downloading code to WebView
        This will allow other code to trigger downloads using this code, and
        matches Mac.

        Reviewed by Darin Adler.

        * WebCoreSupport/WebContextMenuClient.cpp:
        (WebContextMenuClient::downloadURL): Moved code from here...
        * WebView.cpp:
        (WebView::downloadURL): ...to here. Also tightened up the code a
        little bit and removed an unnecessary LOG_ERROR.

        * WebView.h: Added downloadURL.

Canonical link: https://commits.webkit.org/36107@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@44271 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aroben committed May 29, 2009
1 parent 0d92ab8 commit df47344c128718f768df2486a2a3316147f8407a
Showing 4 changed files with 29 additions and 14 deletions.
@@ -1,3 +1,20 @@
2009-05-29 Adam Roben <aroben@apple.com>

Move WebContextMenuClient's downloading code to WebView

This will allow other code to trigger downloads using this code, and
matches Mac.

Reviewed by Darin Adler.

* WebCoreSupport/WebContextMenuClient.cpp:
(WebContextMenuClient::downloadURL): Moved code from here...
* WebView.cpp:
(WebView::downloadURL): ...to here. Also tightened up the code a
little bit and removed an unnecessary LOG_ERROR.

* WebView.h: Added downloadURL.

2009-05-29 Brent Fulgham <bfulgham@webkit.org>

Reviewed by Darin Adler.
@@ -26,7 +26,6 @@
#include "config.h"
#include "WebContextMenuClient.h"

#include "WebDownload.h"
#include "WebElementPropertyBag.h"
#include "WebLocalizableStrings.h"
#include "WebView.h"
@@ -133,19 +132,7 @@ void WebContextMenuClient::contextMenuItemSelected(ContextMenuItem* item, const

void WebContextMenuClient::downloadURL(const KURL& url)
{
COMPtr<IWebDownloadDelegate> downloadDelegate;
if (FAILED(m_webView->downloadDelegate(&downloadDelegate))) {
// If the WebView doesn't successfully provide a download delegate we'll pass a null one
// into the WebDownload - which may or may not decide to use a DefaultDownloadDelegate
LOG_ERROR("Failed to get downloadDelegate from WebView");
downloadDelegate = 0;
}

// Its the delegate's job to ref the WebDownload to keep it alive - otherwise it will be destroyed
// when this method returns
COMPtr<WebDownload> download;
download.adoptRef(WebDownload::createInstance(url, downloadDelegate.get()));
download->start();
m_webView->downloadURL(url);
}

void WebContextMenuClient::searchWithGoogle(const Frame* frame)
@@ -32,6 +32,7 @@
#include "MarshallingHelpers.h"
#include "WebDatabaseManager.h"
#include "WebDocumentLoader.h"
#include "WebDownload.h"
#include "WebEditorClient.h"
#include "WebElementPropertyBag.h"
#include "WebFrame.h"
@@ -5190,6 +5191,14 @@ HRESULT WebView::setJavaScriptURLsAreAllowed(BOOL areAllowed)
return S_OK;
}

void WebView::downloadURL(const KURL& url)
{
// It's the delegate's job to ref the WebDownload to keep it alive - otherwise it will be
// destroyed when this function returns.
COMPtr<WebDownload> download(AdoptCOM, WebDownload::createInstance(url, m_downloadDelegate.get()));
download->start();
}

class EnumTextMatches : public IEnumTextMatches
{
long m_ref;
@@ -817,6 +817,8 @@ class WebView
bool onGetObject(WPARAM, LPARAM, LRESULT&) const;
static STDMETHODIMP AccessibleObjectFromWindow(HWND, DWORD objectID, REFIID, void** ppObject);

void downloadURL(const WebCore::KURL&);

private:
void setZoomMultiplier(float multiplier, bool isTextOnly);
float zoomMultiplier(bool isTextOnly);

0 comments on commit df47344

Please sign in to comment.