Changeset 102779 in webkit


Ignore:
Timestamp:
Dec 14, 2011 8:04:21 AM (12 years ago)
Author:
caio.oliveira@openbossa.org
Message:

[Qt] [WK2] Move download handling out of QtWebPageProxy
https://bugs.webkit.org/show_bug.cgi?id=74506

Reviewed by Kenneth Rohde Christiansen.

Also moves the creation of QtWebContext out of QtWebPageProxy.

  • UIProcess/API/qt/qquickwebview.cpp:

(QQuickWebViewPrivate::initialize):
(QQuickWebViewPrivate::handleDownloadRequest):
(QQuickWebViewPrivate::_q_onReceivedResponseFromDownload):

  • UIProcess/API/qt/qquickwebview_p.h:
  • UIProcess/API/qt/qquickwebview_p_p.h:
  • UIProcess/API/qt/qwebdownloaditem_p.h:
  • UIProcess/qt/QtPageClient.cpp:

(QtPageClient::handleDownloadRequest):

  • UIProcess/qt/QtPageClient.h:
  • UIProcess/qt/QtWebPageProxy.cpp:

(QtWebPageProxy::QtWebPageProxy):

  • UIProcess/qt/QtWebPageProxy.h:
Location:
trunk/Source/WebKit2
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r102771 r102779  
     12011-12-14  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        [Qt] [WK2] Move download handling out of QtWebPageProxy
     4        https://bugs.webkit.org/show_bug.cgi?id=74506
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Also moves the creation of QtWebContext out of QtWebPageProxy.
     9
     10        * UIProcess/API/qt/qquickwebview.cpp:
     11        (QQuickWebViewPrivate::initialize):
     12        (QQuickWebViewPrivate::handleDownloadRequest):
     13        (QQuickWebViewPrivate::_q_onReceivedResponseFromDownload):
     14        * UIProcess/API/qt/qquickwebview_p.h:
     15        * UIProcess/API/qt/qquickwebview_p_p.h:
     16        * UIProcess/API/qt/qwebdownloaditem_p.h:
     17        * UIProcess/qt/QtPageClient.cpp:
     18        (QtPageClient::handleDownloadRequest):
     19        * UIProcess/qt/QtPageClient.h:
     20        * UIProcess/qt/QtWebPageProxy.cpp:
     21        (QtWebPageProxy::QtWebPageProxy):
     22        * UIProcess/qt/QtWebPageProxy.h:
     23
    1242011-12-14  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
    225
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp

    r102771 r102779  
    2222#include "qquickwebview_p.h"
    2323
     24#include "DownloadProxy.h"
    2425#include "DrawingAreaProxyImpl.h"
    2526#include "QtDialogRunner.h"
     27#include "QtDownloadManager.h"
     28#include "QtWebContext.h"
    2629#include "QtWebPageEventHandler.h"
    2730#include "QtWebPageProxy.h"
     
    3336#include "qquickwebpage_p_p.h"
    3437#include "qquickwebview_p_p.h"
     38#include "qwebdownloaditem_p_p.h"
    3539#include "qwebnavigationhistory_p.h"
    3640#include "qwebnavigationhistory_p_p.h"
     
    3842
    3943#include <JavaScriptCore/InitializeThreading.h>
     44#include <QDeclarativeEngine>
    4045#include <QFileDialog>
    4146#include <QtQuick/QQuickCanvas>
     
    6671void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
    6772{
     73    context = contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext();
    6874    QQuickWebPagePrivate* const pageViewPrivate = pageView.data()->d;
    69     setPageProxy(new QtWebPageProxy(q_ptr, &pageClient, contextRef, pageGroupRef));
     75    setPageProxy(new QtWebPageProxy(q_ptr, &pageClient, context, pageGroupRef));
    7076    pageViewPrivate->initialize(webPageProxy());
    7177
     
    234240}
    235241
     242void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download)
     243{
     244    Q_Q(QQuickWebView);
     245    // This function is responsible for hooking up a DownloadProxy to our API layer
     246    // by creating a QWebDownloadItem. It will then wait for the QWebDownloadItem to be
     247    // ready (filled with the ResourceResponse information) so we can pass it through to
     248    // our WebViews.
     249    QWebDownloadItem* downloadItem = new QWebDownloadItem();
     250    downloadItem->d->downloadProxy = download;
     251
     252    q->connect(downloadItem->d, SIGNAL(receivedResponse(QWebDownloadItem*)), q, SLOT(_q_onReceivedResponseFromDownload(QWebDownloadItem*)));
     253    context->downloadManager()->addDownload(download, downloadItem);
     254}
     255
    236256void QQuickWebViewPrivate::updateVisibleContentRectAndScale()
    237257{
     
    262282{
    263283    webPageProxy()->viewStateDidChange(WebPageProxy::ViewIsVisible);
     284}
     285
     286void QQuickWebViewPrivate::_q_onReceivedResponseFromDownload(QWebDownloadItem* downloadItem)
     287{
     288    // Now that our downloadItem has everything we need we can emit downloadRequested.
     289    if (!downloadItem)
     290        return;
     291
     292    Q_Q(QQuickWebView);
     293    QDeclarativeEngine::setObjectOwnership(downloadItem, QDeclarativeEngine::JavaScriptOwnership);
     294    emit q->experimental()->downloadRequested(downloadItem);
    264295}
    265296
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h

    r102674 r102779  
    134134    Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFinished(int result));
    135135    Q_PRIVATE_SLOT(d_func(), void _q_onVisibleChanged());
     136    Q_PRIVATE_SLOT(d_func(), void _q_onReceivedResponseFromDownload(QWebDownloadItem*));
    136137    // Hides QObject::d_ptr allowing us to use the convenience macros.
    137138    QScopedPointer<QQuickWebViewPrivate> d_ptr;
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h

    r102771 r102779  
    3737#include <QtCore/QScopedPointer>
    3838#include <wtf/OwnPtr.h>
     39#include <wtf/RefPtr.h>
    3940
    4041namespace WebKit {
     42class DownloadProxy;
     43class QtWebContext;
    4144class WebPageProxy;
    4245}
     
    8588    void _q_onOpenPanelFinished(int result);
    8689    void _q_onVisibleChanged();
     90    void _q_onReceivedResponseFromDownload(QWebDownloadItem*);
    8791
    8892    void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, QtWebPageUIClient::FileChooserType);
     
    104108    void didRelaunchProcess();
    105109    PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
     110    void handleDownloadRequest(DownloadProxy*);
    106111
    107112private:
     
    135140    };
    136141
     142    RefPtr<QtWebContext> context;
     143
    137144    QtPageClient pageClient;
    138145    QtWebUndoController undoController;
  • trunk/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p.h

    r100602 r102779  
    8181
    8282    friend class WebKit::QtDownloadManager;
    83     friend class QtWebPageProxy;
     83    friend class QQuickWebViewPrivate;
    8484};
    8585
  • trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp

    r102765 r102779  
    9393void QtPageClient::handleDownloadRequest(DownloadProxy* download)
    9494{
    95     m_qtWebPageProxy->handleDownloadRequest(download);
     95    QQuickWebViewPrivate::get(m_webView)->handleDownloadRequest(download);
    9696}
    9797
  • trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h

    r102765 r102779  
    5151    virtual void didRelaunchProcess();
    5252    virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
     53    virtual void handleDownloadRequest(DownloadProxy*);
    5354
    5455    virtual void displayView();
     
    9091    virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
    9192    virtual void focusEditableArea(const WebCore::IntRect&, const WebCore::IntRect&);
    92     virtual void handleDownloadRequest(DownloadProxy*);
    9393
    9494#if ENABLE(TOUCH_EVENTS)
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r102771 r102779  
    2222#include "QtWebPageProxy.h"
    2323
    24 #include <qdeclarativeengine.h>
    2524#include <QtQuick/qquickcanvas.h>
    2625#include "qquickwebview_p.h"
    2726#include "qquickwebview_p_p.h"
    28 #include "qwebdownloaditem_p.h"
    29 #include "qwebdownloaditem_p_p.h"
    3027#include "qwebpreferences_p.h"
    3128#include "qwebpreferences_p_p.h"
    3229
    33 #include "DownloadProxy.h"
    34 #include "QtDownloadManager.h"
    3530#include "QtPageClient.h"
     31#include "QtWebContext.h"
    3632#include "WebBackForwardList.h"
    3733#include "WKStringQt.h"
     
    4339using namespace WebCore;
    4440
    45 QtWebPageProxy::QtWebPageProxy(QQuickWebView* qmlWebView, QtPageClient *pageClient, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
     41QtWebPageProxy::QtWebPageProxy(QQuickWebView* qmlWebView, QtPageClient *pageClient, PassRefPtr<QtWebContext> context, WKPageGroupRef pageGroupRef)
    4642    : m_qmlWebView(qmlWebView)
    47     , m_context(contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext())
     43    , m_context(context)
    4844    , m_navigatorQtObjectEnabled(false)
    4945{
     
    154150}
    155151
    156 void QtWebPageProxy::handleDownloadRequest(DownloadProxy* download)
    157 {
    158     // This function is responsible for hooking up a DownloadProxy to our API layer
    159     // by creating a QWebDownloadItem. It will then wait for the QWebDownloadItem to be
    160     // ready (filled with the ResourceResponse information) so we can pass it through to
    161     // our WebViews.
    162     QWebDownloadItem* downloadItem = new QWebDownloadItem();
    163     downloadItem->d->downloadProxy = download;
    164 
    165     connect(downloadItem->d, SIGNAL(receivedResponse(QWebDownloadItem*)), this, SLOT(didReceiveDownloadResponse(QWebDownloadItem*)));
    166     m_context->downloadManager()->addDownload(download, downloadItem);
    167 }
    168 
    169 void QtWebPageProxy::didReceiveDownloadResponse(QWebDownloadItem* downloadItem)
    170 {
    171     // Now that our downloadItem has everything we need we can emit downloadRequested.
    172     if (!downloadItem)
    173         return;
    174 
    175     QDeclarativeEngine::setObjectOwnership(downloadItem, QDeclarativeEngine::JavaScriptOwnership);
    176     emit m_qmlWebView->experimental()->downloadRequested(downloadItem);
    177 }
    178 
    179152#include "moc_QtWebPageProxy.cpp"
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

    r102771 r102779  
    2222#define QtWebPageProxy_h
    2323
    24 #include "QtWebContext.h"
    2524#include "WebPageProxy.h"
     25#include <wtf/PassRefPtr.h>
    2626#include <wtf/RefPtr.h>
    2727#include <QMenu>
     
    2929
    3030class QtPageClient;
    31 class QQuickWebPage;
    3231class QQuickWebView;
    33 class QWebDownloadItem;
    3432class QWebPreferences;
    3533
     
    4543
    4644public:
    47     QtWebPageProxy(QQuickWebView*, QtPageClient*, WKContextRef = 0, WKPageGroupRef = 0);
     45    QtWebPageProxy(QQuickWebView*, QtPageClient*, PassRefPtr<QtWebContext>, WKPageGroupRef = 0);
    4846    ~QtWebPageProxy();
    4947
     
    7169    }
    7270
    73     void handleDownloadRequest(DownloadProxy*);
    7471    void init();
    7572
    7673    void showContextMenu(QSharedPointer<QMenu>);
    7774    void hideContextMenu();
    78 
    79 public Q_SLOTS:
    80     void didReceiveDownloadResponse(QWebDownloadItem* downloadItem);
    8175
    8276public:
Note: See TracChangeset for help on using the changeset viewer.