Title: [102779] trunk/Source/WebKit2
Revision
102779
Author
[email protected]
Date
2011-12-14 08:04:21 -0800 (Wed, 14 Dec 2011)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (102778 => 102779)


--- trunk/Source/WebKit2/ChangeLog	2011-12-14 16:03:17 UTC (rev 102778)
+++ trunk/Source/WebKit2/ChangeLog	2011-12-14 16:04:21 UTC (rev 102779)
@@ -1,5 +1,28 @@
 2011-12-14  Caio Marcelo de Oliveira Filho  <[email protected]>
 
+        [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:
+
+2011-12-14  Caio Marcelo de Oliveira Filho  <[email protected]>
+
         [Qt] [WK2] Move QWebNavigationHistory to QQuickWebView
         https://bugs.webkit.org/show_bug.cgi?id=74442
 

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (102778 => 102779)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2011-12-14 16:03:17 UTC (rev 102778)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2011-12-14 16:04:21 UTC (rev 102779)
@@ -21,8 +21,11 @@
 #include "config.h"
 #include "qquickwebview_p.h"
 
+#include "DownloadProxy.h"
 #include "DrawingAreaProxyImpl.h"
 #include "QtDialogRunner.h"
+#include "QtDownloadManager.h"
+#include "QtWebContext.h"
 #include "QtWebPageEventHandler.h"
 #include "QtWebPageProxy.h"
 #include "UtilsQt.h"
@@ -32,11 +35,13 @@
 
 #include "qquickwebpage_p_p.h"
 #include "qquickwebview_p_p.h"
+#include "qwebdownloaditem_p_p.h"
 #include "qwebnavigationhistory_p.h"
 #include "qwebnavigationhistory_p_p.h"
 #include "qwebpreferences_p_p.h"
 
 #include <_javascript_Core/InitializeThreading.h>
+#include <QDeclarativeEngine>
 #include <QFileDialog>
 #include <QtQuick/QQuickCanvas>
 #include <WKOpenPanelResultListener.h>
@@ -65,8 +70,9 @@
 // Note: we delay this initialization to make sure that QQuickWebView has its d-ptr in-place.
 void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
 {
+    context = contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext();
     QQuickWebPagePrivate* const pageViewPrivate = pageView.data()->d;
-    setPageProxy(new QtWebPageProxy(q_ptr, &pageClient, contextRef, pageGroupRef));
+    setPageProxy(new QtWebPageProxy(q_ptr, &pageClient, context, pageGroupRef));
     pageViewPrivate->initialize(webPageProxy());
 
     pageLoadClient.reset(new QtWebPageLoadClient(pageProxy->pageRef(), q_ptr));
@@ -233,6 +239,20 @@
     return DrawingAreaProxyImpl::create(webPageProxy());
 }
 
+void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download)
+{
+    Q_Q(QQuickWebView);
+    // This function is responsible for hooking up a DownloadProxy to our API layer
+    // by creating a QWebDownloadItem. It will then wait for the QWebDownloadItem to be
+    // ready (filled with the ResourceResponse information) so we can pass it through to
+    // our WebViews.
+    QWebDownloadItem* downloadItem = new QWebDownloadItem();
+    downloadItem->d->downloadProxy = download;
+
+    q->connect(downloadItem->d, SIGNAL(receivedResponse(QWebDownloadItem*)), q, SLOT(_q_onReceivedResponseFromDownload(QWebDownloadItem*)));
+    context->downloadManager()->addDownload(download, downloadItem);
+}
+
 void QQuickWebViewPrivate::updateVisibleContentRectAndScale()
 {
     DrawingAreaProxy* drawingArea = webPageProxy()->drawingArea();
@@ -263,6 +283,17 @@
     webPageProxy()->viewStateDidChange(WebPageProxy::ViewIsVisible);
 }
 
+void QQuickWebViewPrivate::_q_onReceivedResponseFromDownload(QWebDownloadItem* downloadItem)
+{
+    // Now that our downloadItem has everything we need we can emit downloadRequested.
+    if (!downloadItem)
+        return;
+
+    Q_Q(QQuickWebView);
+    QDeclarativeEngine::setObjectOwnership(downloadItem, QDeclarativeEngine::_javascript_Ownership);
+    emit q->experimental()->downloadRequested(downloadItem);
+}
+
 void QQuickWebViewPrivate::updateViewportSize()
 {
     Q_Q(QQuickWebView);

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h (102778 => 102779)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h	2011-12-14 16:03:17 UTC (rev 102778)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h	2011-12-14 16:04:21 UTC (rev 102779)
@@ -133,6 +133,7 @@
     Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFilesSelected());
     Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFinished(int result));
     Q_PRIVATE_SLOT(d_func(), void _q_onVisibleChanged());
+    Q_PRIVATE_SLOT(d_func(), void _q_onReceivedResponseFromDownload(QWebDownloadItem*));
     // Hides QObject::d_ptr allowing us to use the convenience macros.
     QScopedPointer<QQuickWebViewPrivate> d_ptr;
     QQuickWebViewExperimental* m_experimental;

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h (102778 => 102779)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h	2011-12-14 16:03:17 UTC (rev 102778)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h	2011-12-14 16:04:21 UTC (rev 102779)
@@ -36,8 +36,11 @@
 #include <QtCore/QObject>
 #include <QtCore/QScopedPointer>
 #include <wtf/OwnPtr.h>
+#include <wtf/RefPtr.h>
 
 namespace WebKit {
+class DownloadProxy;
+class QtWebContext;
 class WebPageProxy;
 }
 class QtWebPageProxy;
@@ -84,6 +87,7 @@
     void _q_onOpenPanelFilesSelected();
     void _q_onOpenPanelFinished(int result);
     void _q_onVisibleChanged();
+    void _q_onReceivedResponseFromDownload(QWebDownloadItem*);
 
     void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, QtWebPageUIClient::FileChooserType);
     void runJavaScriptAlert(const QString&);
@@ -103,6 +107,7 @@
     void processDidCrash();
     void didRelaunchProcess();
     PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+    void handleDownloadRequest(DownloadProxy*);
 
 private:
     // This class is responsible for collecting and applying all properties
@@ -134,6 +139,8 @@
         QPoint position;
     };
 
+    RefPtr<QtWebContext> context;
+
     QtPageClient pageClient;
     QtWebUndoController undoController;
     OwnPtr<QWebNavigationHistory> navigationHistory;

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p.h (102778 => 102779)


--- trunk/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p.h	2011-12-14 16:03:17 UTC (rev 102778)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p.h	2011-12-14 16:04:21 UTC (rev 102779)
@@ -80,7 +80,7 @@
     QWebDownloadItemPrivate* d;
 
     friend class WebKit::QtDownloadManager;
-    friend class QtWebPageProxy;
+    friend class QQuickWebViewPrivate;
 };
 
 #endif // qwebdownloaditem_p_h

Modified: trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp (102778 => 102779)


--- trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp	2011-12-14 16:03:17 UTC (rev 102778)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp	2011-12-14 16:04:21 UTC (rev 102779)
@@ -92,7 +92,7 @@
 
 void QtPageClient::handleDownloadRequest(DownloadProxy* download)
 {
-    m_qtWebPageProxy->handleDownloadRequest(download);
+    QQuickWebViewPrivate::get(m_webView)->handleDownloadRequest(download);
 }
 
 void QtPageClient::setCursor(const WebCore::Cursor& cursor)

Modified: trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h (102778 => 102779)


--- trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h	2011-12-14 16:03:17 UTC (rev 102778)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h	2011-12-14 16:04:21 UTC (rev 102779)
@@ -50,6 +50,7 @@
     virtual void processDidCrash();
     virtual void didRelaunchProcess();
     virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+    virtual void handleDownloadRequest(DownloadProxy*);
 
     virtual void displayView();
     virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
@@ -89,7 +90,6 @@
     virtual void countStringMatchesInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { }
     virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
     virtual void focusEditableArea(const WebCore::IntRect&, const WebCore::IntRect&);
-    virtual void handleDownloadRequest(DownloadProxy*);
 
 #if ENABLE(TOUCH_EVENTS)
     virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp (102778 => 102779)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-12-14 16:03:17 UTC (rev 102778)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-12-14 16:04:21 UTC (rev 102779)
@@ -21,18 +21,14 @@
 #include "config.h"
 #include "QtWebPageProxy.h"
 
-#include <qdeclarativeengine.h>
 #include <QtQuick/qquickcanvas.h>
 #include "qquickwebview_p.h"
 #include "qquickwebview_p_p.h"
-#include "qwebdownloaditem_p.h"
-#include "qwebdownloaditem_p_p.h"
 #include "qwebpreferences_p.h"
 #include "qwebpreferences_p_p.h"
 
-#include "DownloadProxy.h"
-#include "QtDownloadManager.h"
 #include "QtPageClient.h"
+#include "QtWebContext.h"
 #include "WebBackForwardList.h"
 #include "WKStringQt.h"
 #include <WebKit2/WKFrame.h>
@@ -42,9 +38,9 @@
 using namespace WebKit;
 using namespace WebCore;
 
-QtWebPageProxy::QtWebPageProxy(QQuickWebView* qmlWebView, QtPageClient *pageClient, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+QtWebPageProxy::QtWebPageProxy(QQuickWebView* qmlWebView, QtPageClient *pageClient, PassRefPtr<QtWebContext> context, WKPageGroupRef pageGroupRef)
     : m_qmlWebView(qmlWebView)
-    , m_context(contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext())
+    , m_context(context)
     , m_navigatorQtObjectEnabled(false)
 {
     m_webPageProxy = m_context->createWebPage(pageClient, toImpl(pageGroupRef));
@@ -153,27 +149,4 @@
     WKPageSetPageAndTextZoomFactors(pageRef(), pageZoomFactor, textZoomFactor);
 }
 
-void QtWebPageProxy::handleDownloadRequest(DownloadProxy* download)
-{
-    // This function is responsible for hooking up a DownloadProxy to our API layer
-    // by creating a QWebDownloadItem. It will then wait for the QWebDownloadItem to be
-    // ready (filled with the ResourceResponse information) so we can pass it through to
-    // our WebViews.
-    QWebDownloadItem* downloadItem = new QWebDownloadItem();
-    downloadItem->d->downloadProxy = download;
-
-    connect(downloadItem->d, SIGNAL(receivedResponse(QWebDownloadItem*)), this, SLOT(didReceiveDownloadResponse(QWebDownloadItem*)));
-    m_context->downloadManager()->addDownload(download, downloadItem);
-}
-
-void QtWebPageProxy::didReceiveDownloadResponse(QWebDownloadItem* downloadItem)
-{
-    // Now that our downloadItem has everything we need we can emit downloadRequested.
-    if (!downloadItem)
-        return;
-
-    QDeclarativeEngine::setObjectOwnership(downloadItem, QDeclarativeEngine::_javascript_Ownership);
-    emit m_qmlWebView->experimental()->downloadRequested(downloadItem);
-}
-
 #include "moc_QtWebPageProxy.cpp"

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h (102778 => 102779)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-12-14 16:03:17 UTC (rev 102778)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-12-14 16:04:21 UTC (rev 102779)
@@ -21,16 +21,14 @@
 #ifndef QtWebPageProxy_h
 #define QtWebPageProxy_h
 
-#include "QtWebContext.h"
 #include "WebPageProxy.h"
+#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <QMenu>
 #include <QSharedPointer>
 
 class QtPageClient;
-class QQuickWebPage;
 class QQuickWebView;
-class QWebDownloadItem;
 class QWebPreferences;
 
 namespace WebKit {
@@ -44,7 +42,7 @@
     Q_OBJECT
 
 public:
-    QtWebPageProxy(QQuickWebView*, QtPageClient*, WKContextRef = 0, WKPageGroupRef = 0);
+    QtWebPageProxy(QQuickWebView*, QtPageClient*, PassRefPtr<QtWebContext>, WKPageGroupRef = 0);
     ~QtWebPageProxy();
 
     WKPageRef pageRef() const;
@@ -70,15 +68,11 @@
         m_webPageProxy->contextMenuItemSelected(data);
     }
 
-    void handleDownloadRequest(DownloadProxy*);
     void init();
 
     void showContextMenu(QSharedPointer<QMenu>);
     void hideContextMenu();
 
-public Q_SLOTS:
-    void didReceiveDownloadResponse(QWebDownloadItem* downloadItem);
-
 public:
     Q_SIGNAL void zoomableAreaFound(const QRect&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to