[Qt] [WK2] Move PageUIClient related code to QtWebPageUIClient
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Nov 2011 13:21:18 +0000 (13:21 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Nov 2011 13:21:18 +0000 (13:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72910

Reviewed by Andreas Kling.

Split PageUIClient related code from QtWebPageProxy/ClientImpl. The new
QtWebPageUIClient registers itself with WKPageRef and it's owned by the
QQuickWebViewPrivate. This is a move to clean up QtWebPageProxy object.

* Target.pri:
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::QQuickWebViewPrivate):
(QQuickWebViewPrivate::chooseFiles):
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qquickwebview_p_p.h:
* UIProcess/qt/ClientImpl.cpp:
* UIProcess/qt/ClientImpl.h:
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::init):
* UIProcess/qt/QtWebPageProxy.h:
* UIProcess/qt/QtWebPageUIClient.cpp: Added.
(QtWebPageUIClient::QtWebPageUIClient):
(QtWebPageUIClient::runJavaScriptAlert):
(QtWebPageUIClient::runJavaScriptConfirm):
(QtWebPageUIClient::runJavaScriptPrompt):
(QtWebPageUIClient::runOpenPanel):
(QtWebPageUIClient::setStatusText):
(QtWebPageUIClient::mouseDidMoveOverElement):
(toQtWebPageUIClient):
(createNullWKString):
* UIProcess/qt/QtWebPageUIClient.h: Added.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
Source/WebKit2/UIProcess/qt/ClientImpl.cpp
Source/WebKit2/UIProcess/qt/ClientImpl.h
Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp
Source/WebKit2/UIProcess/qt/QtWebPageProxy.h
Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h [new file with mode: 0644]

index dd7d364..6d0d064 100644 (file)
@@ -1,3 +1,37 @@
+2011-11-22  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        [Qt] [WK2] Move PageUIClient related code to QtWebPageUIClient
+        https://bugs.webkit.org/show_bug.cgi?id=72910
+
+        Reviewed by Andreas Kling.
+
+        Split PageUIClient related code from QtWebPageProxy/ClientImpl. The new
+        QtWebPageUIClient registers itself with WKPageRef and it's owned by the
+        QQuickWebViewPrivate. This is a move to clean up QtWebPageProxy object.
+
+        * Target.pri:
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::QQuickWebViewPrivate):
+        (QQuickWebViewPrivate::chooseFiles):
+        * UIProcess/API/qt/qquickwebview_p.h:
+        * UIProcess/API/qt/qquickwebview_p_p.h:
+        * UIProcess/qt/ClientImpl.cpp:
+        * UIProcess/qt/ClientImpl.h:
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::init):
+        * UIProcess/qt/QtWebPageProxy.h:
+        * UIProcess/qt/QtWebPageUIClient.cpp: Added.
+        (QtWebPageUIClient::QtWebPageUIClient):
+        (QtWebPageUIClient::runJavaScriptAlert):
+        (QtWebPageUIClient::runJavaScriptConfirm):
+        (QtWebPageUIClient::runJavaScriptPrompt):
+        (QtWebPageUIClient::runOpenPanel):
+        (QtWebPageUIClient::setStatusText):
+        (QtWebPageUIClient::mouseDidMoveOverElement):
+        (toQtWebPageUIClient):
+        (createNullWKString):
+        * UIProcess/qt/QtWebPageUIClient.h: Added.
+
 2011-11-22  Eunmi Lee  <eunmi15.lee@samsung.com>
 
         [WK2] Modify EFL port's WebEventFactory to use EflKeyboardUtilities's
index 00b8d0b..935d9c5 100644 (file)
@@ -323,6 +323,7 @@ HEADERS += \
     UIProcess/qt/QtDialogRunner.h \
     UIProcess/qt/QtDownloadManager.h \
     UIProcess/qt/QtWebPageProxy.h \
+    UIProcess/qt/QtWebPageUIClient.h \
     UIProcess/qt/qwkhistory.h \
     UIProcess/qt/qwkhistory_p.h \
     UIProcess/qt/QtSGUpdateQueue.h \
@@ -628,6 +629,7 @@ SOURCES += \
     UIProcess/qt/QtDialogRunner.cpp \
     UIProcess/qt/QtDownloadManager.cpp \
     UIProcess/qt/QtWebPageProxy.cpp \
+    UIProcess/qt/QtWebPageUIClient.cpp \
     UIProcess/qt/qwkhistory.cpp \
     UIProcess/qt/QtSGUpdateQueue.cpp \
     UIProcess/qt/QtSGTileNode.cpp \
index f146c2b..a6f4fb7 100644 (file)
@@ -58,6 +58,8 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport, WKContextRef
     pageProxy->init();
 
     QObject::connect(pageProxy.data(), SIGNAL(updateNavigationState()), q_ptr, SIGNAL(navigationStateChanged()));
+
+    pageUIClient.reset(new QtWebPageUIClient(pageProxy->pageRef(), q_ptr));
 }
 
 void QQuickWebViewPrivate::enableMouseEvents()
@@ -274,7 +276,7 @@ QString QQuickWebViewPrivate::runJavaScriptPrompt(const QString& message, const
     return dialogRunner.result();
 }
 
-void QQuickWebViewPrivate::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, QtWebPageProxy::FileChooserType type)
+void QQuickWebViewPrivate::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, QtWebPageUIClient::FileChooserType type)
 {
 #ifndef QT_NO_FILEDIALOG
     Q_Q(QQuickWebView);
index 5c8f236..7c8841a 100644 (file)
@@ -135,6 +135,7 @@ private:
     QQuickWebViewExperimental* m_experimental;
 
     friend class QtWebPageProxy;
+    friend class QtWebPageUIClient;
     friend class WTR::PlatformWebView;
     friend class QQuickWebViewExperimental;
 };
index 3ae2561..529e253 100644 (file)
@@ -24,6 +24,7 @@
 #include "QtPolicyInterface.h"
 #include "QtViewportInteractionEngine.h"
 #include "QtWebPageProxy.h"
+#include "QtWebPageUIClient.h"
 
 #include "qquickwebview_p.h"
 #include "qquickwebpage_p.h"
@@ -72,7 +73,7 @@ public:
     // QtPolicyInterface.
     virtual QtPolicyInterface::PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers);
 
-    void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, QtWebPageProxy::FileChooserType);
+    void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, QtWebPageUIClient::FileChooserType);
     void runJavaScriptAlert(const QString&);
     bool runJavaScriptConfirm(const QString&);
     QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
@@ -110,6 +111,8 @@ private:
 
     void setViewInAttachedProperties(QObject*);
 
+    QScopedPointer<QtWebPageUIClient> pageUIClient;
+
     QScopedPointer<QQuickWebPage> pageView;
     QScopedPointer<QtViewportInteractionEngine> interactionEngine;
 
index 104d342..0863ec7 100644 (file)
@@ -31,8 +31,6 @@
 #include <WKFrame.h>
 #include <WKFramePolicyListener.h>
 #include <WKHitTestResult.h>
-#include <WKOpenPanelParameters.h>
-#include <WKOpenPanelResultListener.h>
 #include <WKPage.h>
 #include <WKString.h>
 #include <WKType.h>
@@ -152,61 +150,6 @@ static void qt_wk_didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrame
     toQtWebPageProxy(clientInfo)->didFinishFirstNonEmptyLayout();
 }
 
-static void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
-{
-    QString qAlertText = WKStringCopyQString(alertText);
-    toQtWebPageProxy(clientInfo)->runJavaScriptAlert(qAlertText);
-}
-
-static bool qt_wk_runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo)
-{
-    QString qMessage = WKStringCopyQString(message);
-    return toQtWebPageProxy(clientInfo)->runJavaScriptConfirm(qMessage);
-}
-
-static inline WKStringRef createNullWKString()
-{
-    RefPtr<WebString> webString = WebString::createNull();
-    return toAPI(webString.release().leakRef());
-}
-
-static WKStringRef qt_wk_runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo)
-{
-    QString qMessage = WKStringCopyQString(message);
-    QString qDefaultValue = WKStringCopyQString(defaultValue);
-    bool ok = false;
-    QString result = toQtWebPageProxy(clientInfo)->runJavaScriptPrompt(qMessage, qDefaultValue, ok);
-    if (!ok)
-        return createNullWKString();
-    return WKStringCreateWithQString(result);
-}
-
-static void qt_wk_setStatusText(WKPageRef, WKStringRef text, const void *clientInfo)
-{
-    QString qText = WKStringCopyQString(text);
-    toQtWebPageProxy(clientInfo)->didChangeStatusText(qText);
-}
-
-static void qt_wk_runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
-{
-    Vector<String> wkSelectedFileNames = toImpl(parameters)->selectedFileNames();
-
-    QStringList selectedFileNames;
-    if (!wkSelectedFileNames.isEmpty())
-        for (unsigned i = 0; wkSelectedFileNames.size(); ++i)
-            selectedFileNames += wkSelectedFileNames.at(i);
-
-    QtWebPageProxy::FileChooserType allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? QtWebPageProxy::MultipleFilesSelection : QtWebPageProxy::SingleFileSelection;
-    toQtWebPageProxy(clientInfo)->chooseFiles(listener, selectedFileNames, allowMultipleFiles);
-}
-
-static void qt_wk_mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
-{
-    const QUrl absoluteLinkUrl = WKURLCopyQUrl(WKHitTestResultCopyAbsoluteLinkURL(hitTestResult));
-    const QString linkTitle = WKStringCopyQString(WKHitTestResultCopyLinkTitle(hitTestResult));
-    toQtWebPageProxy(clientInfo)->didMouseMoveOverElement(absoluteLinkUrl, linkTitle);
-}
-
 static Qt::MouseButton toQtMouseButton(WKEventMouseButton button)
 {
     switch (button) {
@@ -321,21 +264,6 @@ void setupPageLoaderClient(QtWebPageProxy* qtWebPageProxy, WebPageProxy* webPage
     WKPageSetPageLoaderClient(qtWebPageProxy->pageRef(), &loadClient);
 }
 
-void setupPageUiClient(QtWebPageProxy* qtWebPageProxy, WebPageProxy* webPageProxy)
-{
-    WKPageUIClient uiClient;
-    memset(&uiClient, 0, sizeof(WKPageUIClient));
-    uiClient.version = kWKPageUIClientCurrentVersion;
-    uiClient.clientInfo = qtWebPageProxy;
-    uiClient.runJavaScriptAlert = qt_wk_runJavaScriptAlert;
-    uiClient.runJavaScriptConfirm = qt_wk_runJavaScriptConfirm;
-    uiClient.runJavaScriptPrompt = qt_wk_runJavaScriptPrompt;
-    uiClient.setStatusText = qt_wk_setStatusText;
-    uiClient.runOpenPanel = qt_wk_runOpenPanel;
-    uiClient.mouseDidMoveOverElement = qt_wk_mouseDidMoveOverElement;
-    WKPageSetPageUIClient(toAPI(webPageProxy), &uiClient);
-}
-
 void setupPagePolicyClient(QtPolicyInterface* policyInterface, WebPageProxy* webPageProxy)
 {
     WKPagePolicyClient policyClient;
index 4ef8975..875935e 100644 (file)
@@ -29,7 +29,6 @@ class WebPageProxy;
 }
 
 void setupPageLoaderClient(QtWebPageProxy*, WebKit::WebPageProxy*);
-void setupPageUiClient(QtWebPageProxy*, WebKit::WebPageProxy*);
 void setupPagePolicyClient(WebKit::QtPolicyInterface*, WebKit::WebPageProxy*);
 
 void setupContextInjectedBundleClient(WKContextRef);
index 63de4e2..f8d9bc6 100644 (file)
@@ -157,7 +157,6 @@ void QtWebPageProxy::init()
     m_webPageProxy->initializeWebPage();
 
     setupPageLoaderClient(this, m_webPageProxy.get());
-    setupPageUiClient(this, m_webPageProxy.get());
 
     if (m_policyInterface)
         setupPagePolicyClient(m_policyInterface, m_webPageProxy.get());
@@ -355,20 +354,6 @@ void QtWebPageProxy::handleDoubleTapEvent(const QTouchEvent::TouchPoint& point)
     m_webPageProxy->findZoomableAreaForPoint(point.pos().toPoint());
 }
 
-void QtWebPageProxy::didChangeStatusText(const QString& newMessage)
-{
-    emit m_qmlWebView->statusBarMessageChanged(newMessage);
-}
-
-void QtWebPageProxy::didMouseMoveOverElement(const QUrl& linkURL, const QString& linkTitle)
-{
-    if (linkURL == lastHoveredURL && linkTitle == lastHoveredTitle)
-        return;
-    lastHoveredURL = linkURL;
-    lastHoveredTitle = linkTitle;
-    emit m_qmlWebView->linkHovered(lastHoveredURL, lastHoveredTitle);
-}
-
 void QtWebPageProxy::showContextMenu(QSharedPointer<QMenu> menu)
 {
     // Remove the active menu in case this function is called twice.
@@ -401,26 +386,6 @@ void QtWebPageProxy::hideContextMenu()
         activeMenu->hide();
 }
 
-void QtWebPageProxy::runJavaScriptAlert(const QString& alertText)
-{
-    m_qmlWebView->d_func()->runJavaScriptAlert(alertText);
-}
-
-bool QtWebPageProxy::runJavaScriptConfirm(const QString& message)
-{
-    return m_qmlWebView->d_func()->runJavaScriptConfirm(message);
-}
-
-QString QtWebPageProxy::runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok)
-{
-    return m_qmlWebView->d_func()->runJavaScriptPrompt(message, defaultValue, ok);
-}
-
-void QtWebPageProxy::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, FileChooserType type)
-{
-    m_qmlWebView->d_func()->chooseFiles(listenerRef, selectedFileNames, type);
-}
-
 void QtWebPageProxy::timerEvent(QTimerEvent* ev)
 {
     int timerId = ev->timerId();
index 67cd055..c1812e9 100644 (file)
@@ -74,11 +74,6 @@ public:
         WebActionCount
     };
 
-    enum FileChooserType {
-        SingleFileSelection,
-        MultipleFilesSelection
-    };
-
     QtWebPageProxy(QQuickWebPage*, QQuickWebView*, WebKit::QtViewportInteractionEngine* = 0, WebKit::QtPolicyInterface* = 0, WKContextRef = 0, WKPageGroupRef = 0);
     ~QtWebPageProxy();
 
@@ -210,19 +205,9 @@ public:
     void handleSingleTapEvent(const QTouchEvent::TouchPoint&);
     void handleDoubleTapEvent(const QTouchEvent::TouchPoint&);
 
-    void didChangeStatusText(const QString&);
-
     void showContextMenu(QSharedPointer<QMenu>);
     void hideContextMenu();
 
-    void runJavaScriptAlert(const QString&);
-    bool runJavaScriptConfirm(const QString&);
-    QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
-
-    void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType);
-
-    void didMouseMoveOverElement(const QUrl&, const QString&);
-
 public Q_SLOTS:
     void navigationStateChanged();
     void didReceiveDownloadResponse(QWebDownloadItem* downloadItem);
@@ -285,8 +270,6 @@ private:
     QBasicTimer m_tripleClickTimer;
 
     QSharedPointer<QMenu> activeMenu;
-    QUrl lastHoveredURL;
-    QString lastHoveredTitle;
 };
 
 #endif /* QtWebPageProxy_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp
new file mode 100644 (file)
index 0000000..6c83a1e
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "QtWebPageUIClient.h"
+
+#include "WKStringQt.h"
+#include "WKURLQt.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include <WKAPICast.h>
+#include <WKHitTestResult.h>
+#include <WKOpenPanelParameters.h>
+#include <WKOpenPanelResultListener.h>
+
+QtWebPageUIClient::QtWebPageUIClient(WKPageRef pageRef, QQuickWebView* webView)
+    : m_webView(webView)
+{
+    WKPageUIClient uiClient;
+    memset(&uiClient, 0, sizeof(WKPageUIClient));
+    uiClient.version = kWKPageUIClientCurrentVersion;
+    uiClient.clientInfo = this;
+    uiClient.runJavaScriptAlert = runJavaScriptAlert;
+    uiClient.runJavaScriptConfirm = runJavaScriptConfirm;
+    uiClient.runJavaScriptPrompt = runJavaScriptPrompt;
+    uiClient.setStatusText = setStatusText;
+    uiClient.runOpenPanel = runOpenPanel;
+    uiClient.mouseDidMoveOverElement = mouseDidMoveOverElement;
+    WKPageSetPageUIClient(pageRef, &uiClient);
+}
+
+void QtWebPageUIClient::runJavaScriptAlert(const QString& message)
+{
+    m_webView->d_func()->runJavaScriptAlert(message);
+}
+
+bool QtWebPageUIClient::runJavaScriptConfirm(const QString& message)
+{
+    return m_webView->d_func()->runJavaScriptConfirm(message);
+}
+
+QString QtWebPageUIClient::runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok)
+{
+    return m_webView->d_func()->runJavaScriptPrompt(message, defaultValue, ok);
+}
+
+void QtWebPageUIClient::runOpenPanel(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, FileChooserType type)
+{
+    m_webView->d_func()->chooseFiles(listenerRef, selectedFileNames, type);
+}
+
+void QtWebPageUIClient::setStatusText(const QString& newMessage)
+{
+    emit m_webView->statusBarMessageChanged(newMessage);
+}
+
+void QtWebPageUIClient::mouseDidMoveOverElement(const QUrl& linkURL, const QString& linkTitle)
+{
+    if (linkURL == m_lastHoveredURL && linkTitle == m_lastHoveredTitle)
+        return;
+    m_lastHoveredURL = linkURL;
+    m_lastHoveredTitle = linkTitle;
+    emit m_webView->linkHovered(m_lastHoveredURL, m_lastHoveredTitle);
+}
+
+static QtWebPageUIClient* toQtWebPageUIClient(const void* clientInfo)
+{
+    ASSERT(clientInfo);
+    return reinterpret_cast<QtWebPageUIClient*>(const_cast<void*>(clientInfo));
+}
+
+void QtWebPageUIClient::runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo)
+{
+    QString qAlertText = WKStringCopyQString(alertText);
+    toQtWebPageUIClient(clientInfo)->runJavaScriptAlert(qAlertText);
+}
+
+bool QtWebPageUIClient::runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo)
+{
+    QString qMessage = WKStringCopyQString(message);
+    return toQtWebPageUIClient(clientInfo)->runJavaScriptConfirm(qMessage);
+}
+
+static inline WKStringRef createNullWKString()
+{
+    RefPtr<WebString> webString = WebString::createNull();
+    return toAPI(webString.release().leakRef());
+}
+
+WKStringRef QtWebPageUIClient::runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo)
+{
+    QString qMessage = WKStringCopyQString(message);
+    QString qDefaultValue = WKStringCopyQString(defaultValue);
+    bool ok = false;
+    QString result = toQtWebPageUIClient(clientInfo)->runJavaScriptPrompt(qMessage, qDefaultValue, ok);
+    if (!ok)
+        return createNullWKString();
+    return WKStringCreateWithQString(result);
+}
+
+void QtWebPageUIClient::setStatusText(WKPageRef, WKStringRef text, const void *clientInfo)
+{
+    QString qText = WKStringCopyQString(text);
+    toQtWebPageUIClient(clientInfo)->setStatusText(qText);
+}
+
+void QtWebPageUIClient::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
+{
+    Vector<String> wkSelectedFileNames = toImpl(parameters)->selectedFileNames();
+
+    QStringList selectedFileNames;
+    for (size_t i = 0; i < wkSelectedFileNames.size(); ++i)
+        selectedFileNames += wkSelectedFileNames.at(i);
+
+    FileChooserType allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? MultipleFilesSelection : SingleFileSelection;
+    toQtWebPageUIClient(clientInfo)->runOpenPanel(listener, selectedFileNames, allowMultipleFiles);
+}
+
+void QtWebPageUIClient::mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
+{
+    const QUrl absoluteLinkUrl = WKURLCopyQUrl(WKHitTestResultCopyAbsoluteLinkURL(hitTestResult));
+    const QString linkTitle = WKStringCopyQString(WKHitTestResultCopyLinkTitle(hitTestResult));
+    toQtWebPageUIClient(clientInfo)->mouseDidMoveOverElement(absoluteLinkUrl, linkTitle);
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h b/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h
new file mode 100644 (file)
index 0000000..474a4e1
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef QtWebPageUIClient_h
+#define QtWebPageUIClient_h
+
+#include <QtCore/QString>
+#include <QtCore/QUrl>
+#include <WKPage.h>
+
+class QQuickWebView;
+
+class QtWebPageUIClient {
+public:
+    enum FileChooserType {
+        SingleFileSelection,
+        MultipleFilesSelection
+    };
+
+    QtWebPageUIClient(WKPageRef, QQuickWebView*);
+
+private:
+    void runJavaScriptAlert(const QString& message);
+    bool runJavaScriptConfirm(const QString& message);
+    QString runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok);
+    void setStatusText(const QString&);
+    void runOpenPanel(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType);
+    void mouseDidMoveOverElement(const QUrl& linkURL, const QString& linkTitle);
+
+    // WKPageUIClient callbacks.
+    static void runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo);
+    static bool runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo);
+    static WKStringRef runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo);
+    static void setStatusText(WKPageRef, WKStringRef, const void *clientInfo);
+    static void runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef, WKOpenPanelResultListenerRef, const void* clientInfo);
+    static void mouseDidMoveOverElement(WKPageRef, WKHitTestResultRef, WKEventModifiers, WKTypeRef userData, const void* clientInfo);
+
+    QQuickWebView* m_webView;
+    QUrl m_lastHoveredURL;
+    QString m_lastHoveredTitle;
+};
+
+#endif // QtWebPageUIClient_h