Changeset 95631 in webkit


Ignore:
Timestamp:
Sep 21, 2011 8:10:43 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt][WK2] Implement Download support in WebProcess
https://bugs.webkit.org/show_bug.cgi?id=68153

Patch by Jesus Sanchez-Palencia <jesus.palencia@openbossa.org> on 2011-09-21
Reviewed by Andreas Kling.

Source/WebCore:

Refactored QNetworkReplyHandler::finish() in order to add
and use the static function QNetworkReplyHandler::errorForReply().
This will be used by our Download implementation in WebKit2 (WebProcess)
when handling ResourceError.

  • platform/network/qt/QNetworkReplyHandler.cpp:

(WebCore::QNetworkReplyHandler::finish):
(WebCore::QNetworkReplyHandler::errorForReply):

  • platform/network/qt/QNetworkReplyHandler.h:
  • platform/network/qt/ResourceRequest.h:

Source/WebKit2:

We implement the necessary functions of Download.h, and our QtFileDownloader
to handle all network communication and call the necessary functions of Download.

We use the download policy for any MIME type not supported by WebKit. This
behaves like Qt non-WebKit2 except that we don't force download when
we encounter Content-Disposition: attachment. We still use the "filename="
field for file name suggestion though.

Based on original patches by: Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>,
Jocelyn Turcotte <jocelyn.turcotte@nokia.com>, Simon Hausmann <simon.hausmann@nokia.com>
and Zalan Bujtas <zalan.bujtas@nokia.com>.

  • UIProcess/API/qt/qweberror.cpp: Adding DownloadError

(QWebError::type):

  • UIProcess/API/qt/qweberror.h: Adding DownloadError
  • WebKit2.pro:
  • WebProcess/Downloads/Download.cpp: Adding QtFileDownloader, Qt platform specific

(WebKit::Download::Download):

  • WebProcess/Downloads/Download.h: Adding QtFileDownloader, Qt platform specific
  • WebProcess/Downloads/qt/DownloadQt.cpp:

(WebKit::Download::start):
(WebKit::Download::startWithHandle):
(WebKit::Download::cancel):
(WebKit::Download::platformInvalidate):
(WebKit::Download::didDecideDestination):

  • WebProcess/Downloads/qt/QtFileDownloader.cpp: Added.

(WebKit::QtFileDownloader::QtFileDownloader):
(WebKit::QtFileDownloader::~QtFileDownloader):
(WebKit::QtFileDownloader::determineFilename):
(WebKit::QtFileDownloader::decidedDestination):
(WebKit::QtFileDownloader::abortDownloadWritingAndEmitError):
(WebKit::QtFileDownloader::onReadyRead):
(WebKit::QtFileDownloader::onFinished):
(WebKit::QtFileDownloader::onError):
(WebKit::QtFileDownloader::cancel):

  • WebProcess/Downloads/qt/QtFileDownloader.h: Added.
Location:
trunk/Source
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r95621 r95631  
     12011-09-21  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
     2
     3        [Qt][WK2] Implement Download support in WebProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=68153
     5
     6        Reviewed by Andreas Kling.
     7
     8        Refactored QNetworkReplyHandler::finish() in order to add
     9        and use the static function QNetworkReplyHandler::errorForReply().
     10        This will be used by our Download implementation in WebKit2 (WebProcess)
     11        when handling ResourceError.
     12
     13        * platform/network/qt/QNetworkReplyHandler.cpp:
     14        (WebCore::QNetworkReplyHandler::finish):
     15        (WebCore::QNetworkReplyHandler::errorForReply):
     16        * platform/network/qt/QNetworkReplyHandler.h:
     17        * platform/network/qt/ResourceRequest.h:
     18
    1192011-09-21  Pavel Feldman  <pfeldman@google.com>
    220
  • trunk/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp

    r91189 r95631  
    456456    if (!m_replyWrapper->reply()->error() || shouldIgnoreHttpError(m_replyWrapper->reply(), m_replyWrapper->responseContainsData()))
    457457        client->didFinishLoading(m_resourceHandle, 0);
    458     else {
    459         QUrl url = m_replyWrapper->reply()->url();
    460         int httpStatusCode = m_replyWrapper->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
    461 
    462         if (httpStatusCode) {
    463             ResourceError error("HTTP", httpStatusCode, url.toString(), m_replyWrapper->reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString());
    464             client->didFail(m_resourceHandle, error);
    465         } else {
    466             ResourceError error("QtNetwork", m_replyWrapper->reply()->error(), url.toString(), m_replyWrapper->reply()->errorString());
    467             client->didFail(m_resourceHandle, error);
    468         }
    469     }
     458    else
     459        client->didFail(m_resourceHandle, errorForReply(m_replyWrapper->reply()));
    470460
    471461    m_replyWrapper = nullptr;
     
    695685}
    696686
     687ResourceError QNetworkReplyHandler::errorForReply(QNetworkReply* reply)
     688{
     689    QUrl url = reply->url();
     690    int httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
     691
     692    if (httpStatusCode)
     693        return ResourceError("HTTP", httpStatusCode, url.toString(), reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString());
     694
     695    return ResourceError("QtNetwork", reply->error(), url.toString(), reply->errorString());
     696}
     697
    697698}
    698699
  • trunk/Source/WebCore/platform/network/qt/QNetworkReplyHandler.h

    r91189 r95631  
    3737
    3838class FormDataIODevice;
     39class ResourceError;
    3940class ResourceHandle;
    4041class ResourceRequest;
     
    134135    void sendResponseIfNeeded();
    135136
     137    static ResourceError errorForReply(QNetworkReply*);
     138
    136139private slots:
    137140    void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
  • trunk/Source/WebCore/platform/network/qt/ResourceRequest.h

    r68762 r95631  
    6060        }
    6161
    62         QNetworkRequest toNetworkRequest(QObject* originatingObject) const;
     62        QNetworkRequest toNetworkRequest(QObject* originatingObject = 0) const;
    6363
    6464    private:
  • trunk/Source/WebKit2/ChangeLog

    r95607 r95631  
     12011-09-21  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
     2
     3        [Qt][WK2] Implement Download support in WebProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=68153
     5
     6        Reviewed by Andreas Kling.
     7
     8        We implement the necessary functions of Download.h, and our QtFileDownloader
     9        to handle all network communication and call the necessary functions of Download.
     10
     11        We use the download policy for any MIME type not supported by WebKit. This
     12        behaves like Qt non-WebKit2 except that we don't force download when
     13        we encounter Content-Disposition: attachment. We still use the "filename="
     14        field for file name suggestion though.
     15
     16        Based on original patches by: Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>,
     17        Jocelyn Turcotte <jocelyn.turcotte@nokia.com>, Simon Hausmann <simon.hausmann@nokia.com>
     18        and Zalan Bujtas <zalan.bujtas@nokia.com>.
     19
     20        * UIProcess/API/qt/qweberror.cpp: Adding DownloadError
     21        (QWebError::type):
     22        * UIProcess/API/qt/qweberror.h: Adding DownloadError
     23        * WebKit2.pro:
     24        * WebProcess/Downloads/Download.cpp: Adding QtFileDownloader, Qt platform specific
     25        (WebKit::Download::Download):
     26        * WebProcess/Downloads/Download.h: Adding QtFileDownloader, Qt platform specific
     27        * WebProcess/Downloads/qt/DownloadQt.cpp:
     28        (WebKit::Download::start):
     29        (WebKit::Download::startWithHandle):
     30        (WebKit::Download::cancel):
     31        (WebKit::Download::platformInvalidate):
     32        (WebKit::Download::didDecideDestination):
     33        * WebProcess/Downloads/qt/QtFileDownloader.cpp: Added.
     34        (WebKit::QtFileDownloader::QtFileDownloader):
     35        (WebKit::QtFileDownloader::~QtFileDownloader):
     36        (WebKit::QtFileDownloader::determineFilename):
     37        (WebKit::QtFileDownloader::decidedDestination):
     38        (WebKit::QtFileDownloader::abortDownloadWritingAndEmitError):
     39        (WebKit::QtFileDownloader::onReadyRead):
     40        (WebKit::QtFileDownloader::onFinished):
     41        (WebKit::QtFileDownloader::onError):
     42        (WebKit::QtFileDownloader::cancel):
     43        * WebProcess/Downloads/qt/QtFileDownloader.h: Added.
     44
    1452011-09-21  Mark Rowe  <mrowe@apple.com>
    246
  • trunk/Source/WebKit2/UIProcess/API/qt/qweberror.cpp

    r90820 r95631  
    6666    if (errorDomain == "HTTP")
    6767        return QWebError::HttpError;
     68    if (errorDomain == "Download")
     69        return QWebError::DownloadError;
    6870    // FIXME: Redirection overflow currently puts the URL hostname in the errorDomain field.
    6971    //        We should expose that error somehow. Source is QNetworkReplyHandler::redirect().
  • trunk/Source/WebKit2/UIProcess/API/qt/qweberror.h

    r95492 r95631  
    3737        EngineError,
    3838        NetworkError,
    39         HttpError
     39        HttpError,
     40        DownloadError
    4041    };
    4142
  • trunk/Source/WebKit2/WebKit2.pro

    r95551 r95631  
    272272    WebProcess/Downloads/Download.h \
    273273    WebProcess/Downloads/DownloadManager.h \
     274    WebProcess/Downloads/qt/QtFileDownloader.h \
    274275    WebProcess/FullScreen/WebFullScreenManager.h \
    275276    WebProcess/FullScreen/qt/WebFullScreenManagerQt.h \
     
    514515    WebProcess/Downloads/DownloadManager.cpp \
    515516    WebProcess/Downloads/qt/DownloadQt.cpp \
     517    WebProcess/Downloads/qt/QtFileDownloader.cpp \
    516518    WebProcess/FullScreen/WebFullScreenManager.cpp \
    517519    WebProcess/FullScreen/qt/WebFullScreenManagerQt.cpp \
     
    525527    WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp \
    526528    WebProcess/InjectedBundle/InjectedBundleClient.cpp \
    527     WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp \   
     529    WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp \
    528530    WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp \
    529531    WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp \
  • trunk/Source/WebKit2/WebProcess/Downloads/Download.cpp

    r84610 r95631  
    5151#if USE(CFNETWORK)
    5252    , m_allowOverwrite(false)
     53#endif
     54#if PLATFORM(QT)
     55    , m_qtDownloader(0)
    5356#endif
    5457{
  • trunk/Source/WebKit2/WebProcess/Downloads/Download.h

    r84610 r95631  
    6060class SandboxExtension;
    6161class WebPage;
     62
     63#if PLATFORM(QT)
     64class QtFileDownloader;
     65#endif
    6266
    6367class Download : public CoreIPC::MessageSender<Download> {
     
    127131    RefPtr<DownloadAuthenticationClient> m_authenticationClient;
    128132#endif
     133#if PLATFORM(QT)
     134    QtFileDownloader* m_qtDownloader;
     135#endif
    129136};
    130137
  • trunk/Source/WebKit2/WebProcess/Downloads/qt/DownloadQt.cpp

    r82364 r95631  
    11/*
    22 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
     3 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2728#include "Download.h"
    2829
     30#include "QtFileDownloader.h"
     31#include "WebProcess.h"
    2932#include <WebCore/NotImplemented.h>
     33#include <WebCore/QNetworkReplyHandler.h>
     34#include <WebCore/ResourceHandle.h>
     35#include <WebCore/ResourceHandleInternal.h>
     36#include <WebCore/ResourceResponse.h>
    3037
    3138using namespace WebCore;
     
    3542void Download::start(WebPage* initiatingWebPage)
    3643{
    37     notImplemented();
     44    QNetworkAccessManager* manager = WebProcess::shared().networkAccessManager();
     45    ASSERT(manager);
     46    ASSERT(!m_qtDownloader);
     47
     48    m_qtDownloader = new QtFileDownloader(this, adoptPtr(manager->get(m_request.toNetworkRequest())));
    3849}
    3950
    40 void Download::startWithHandle(WebPage* initiatingPage, ResourceHandle*, const ResourceRequest& initialRequest, const ResourceResponse&)
     51void Download::startWithHandle(WebPage* initiatingPage, ResourceHandle* handle, const ResourceRequest& initialRequest, const ResourceResponse& resp)
    4152{
    42     notImplemented();
     53    ASSERT(!m_qtDownloader);
     54    m_qtDownloader = new QtFileDownloader(this, adoptPtr(handle->getInternal()->m_job->release()));
    4355}
    4456
    4557void Download::cancel()
    4658{
    47     notImplemented();
     59    ASSERT(m_qtDownloader);
     60    m_qtDownloader->cancel();
    4861}
    4962
    5063void Download::platformInvalidate()
    5164{
    52     notImplemented();
     65    ASSERT(m_qtDownloader);
     66    m_qtDownloader->deleteLater();
     67    m_qtDownloader = 0;
    5368}
    5469
    5570void Download::didDecideDestination(const String& destination, bool allowOverwrite)
    5671{
    57     notImplemented();
     72    m_qtDownloader->decidedDestination(destination, allowOverwrite);
    5873}
    5974
Note: See TracChangeset for help on using the changeset viewer.