Title: [93427] trunk/Source/WebKit2
Revision
93427
Author
caio.olive...@openbossa.org
Date
2011-08-19 12:15:05 -0700 (Fri, 19 Aug 2011)

Log Message

[Qt] [WK2] Provide API for intercept (and possible ignore) links clicked in QDesktopWebView
https://bugs.webkit.org/show_bug.cgi?id=65920

Reviewed by Benjamin Poulain.

This patch makes QDesktopWebView delegate the decision of whether a navigation
should proceed to a slot in QML. The user of the DesktopWebView must implement a
'navigationPolicyForUrl()' if it wants to use the feature.

Such feature is useful for implementing opening links in "new tab" by using a
specific mouse button or mouse button plus keyboard modifiers.

The patch introduces a internal Qt-level interface called PolicyInterface, that
is used by QtWebPageProxy to delegate policy calls. A concrete implementation is
provided for QDesktopWebView.

* Shared/qt/WebCoreArgumentCodersQt.cpp:
(CoreIPC::::encode):
(CoreIPC::::decode):
Implement the serialization of the Request URL, which is the only data
we exposing from the Request.

* WebKit2.pro:
* UIProcess/qt/PolicyInterface.h: Added.
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::QtWebPageProxy):
(QtWebPageProxy::init):
* UIProcess/qt/QtWebPageProxy.h:
Register a Policy Client in the WK2 C API only if there's a PolicyInterface available.

* UIProcess/qt/ClientImpl.h:
* UIProcess/qt/ClientImpl.cpp:
(toPolicyInterface):
(toQtMouseButton):
(toQtKeyboardModifiers):
(qt_wk_decidePolicyForNavigationAction):
Implement the callback for the Page Policy Client. It will translate the
arguments to Qt jargon and call PolicyInterface.

* UIProcess/qt/qdesktopwebpageproxy.cpp:
(QDesktopWebPageProxy::QDesktopWebPageProxy):
* UIProcess/API/qt/qdesktopwebview.h:
* UIProcess/API/qt/qdesktopwebview_p.h:
* UIProcess/API/qt/qdesktopwebview.cpp:
(toPolicyAction):
(hasMetaMethod):
(QDesktopWebViewPrivate::navigationPolicyForURL):
The concrete implementation for QDesktopWebView. Its private object implements
the PolicyInterface and try to call a possible function defined in QML (so return
value and arguments all QVariants). If there's no such a function, returns the
default UsePolicy, like if we haven't registered a PolicyClient in WK2 C API.

* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_navigationPolicyForUrl.qml: Added.
* UIProcess/API/qt/tests/qmltests/common/test2.html: Added.
* UIProcess/API/qt/tests/qmltests/qmltests.pro:
Add a test for DesktopWebView QML element making use of a button and a modifier to
ignore a navigation.

* UIProcess/qt/qtouchwebpageproxy.cpp:
(QTouchWebPageProxy::QTouchWebPageProxy):
For now, we don't have a PolicyInterface for QTouchWebView.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (93426 => 93427)


--- trunk/Source/WebKit2/ChangeLog	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/ChangeLog	2011-08-19 19:15:05 UTC (rev 93427)
@@ -1,3 +1,67 @@
+2011-08-19  Caio Marcelo de Oliveira Filho  <caio.olive...@openbossa.org>
+
+        [Qt] [WK2] Provide API for intercept (and possible ignore) links clicked in QDesktopWebView
+        https://bugs.webkit.org/show_bug.cgi?id=65920
+
+        Reviewed by Benjamin Poulain.
+
+        This patch makes QDesktopWebView delegate the decision of whether a navigation
+        should proceed to a slot in QML. The user of the DesktopWebView must implement a
+        'navigationPolicyForUrl()' if it wants to use the feature.
+
+        Such feature is useful for implementing opening links in "new tab" by using a
+        specific mouse button or mouse button plus keyboard modifiers.
+
+        The patch introduces a internal Qt-level interface called PolicyInterface, that
+        is used by QtWebPageProxy to delegate policy calls. A concrete implementation is
+        provided for QDesktopWebView.
+
+        * Shared/qt/WebCoreArgumentCodersQt.cpp:
+        (CoreIPC::::encode):
+        (CoreIPC::::decode):
+        Implement the serialization of the Request URL, which is the only data
+        we exposing from the Request.
+
+        * WebKit2.pro:
+        * UIProcess/qt/PolicyInterface.h: Added.
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::QtWebPageProxy):
+        (QtWebPageProxy::init):
+        * UIProcess/qt/QtWebPageProxy.h:
+        Register a Policy Client in the WK2 C API only if there's a PolicyInterface available.
+
+        * UIProcess/qt/ClientImpl.h:
+        * UIProcess/qt/ClientImpl.cpp:
+        (toPolicyInterface):
+        (toQtMouseButton):
+        (toQtKeyboardModifiers):
+        (qt_wk_decidePolicyForNavigationAction):
+        Implement the callback for the Page Policy Client. It will translate the
+        arguments to Qt jargon and call PolicyInterface.
+
+        * UIProcess/qt/qdesktopwebpageproxy.cpp:
+        (QDesktopWebPageProxy::QDesktopWebPageProxy):
+        * UIProcess/API/qt/qdesktopwebview.h:
+        * UIProcess/API/qt/qdesktopwebview_p.h:
+        * UIProcess/API/qt/qdesktopwebview.cpp:
+        (toPolicyAction):
+        (hasMetaMethod):
+        (QDesktopWebViewPrivate::navigationPolicyForURL):
+        The concrete implementation for QDesktopWebView. Its private object implements
+        the PolicyInterface and try to call a possible function defined in QML (so return
+        value and arguments all QVariants). If there's no such a function, returns the
+        default UsePolicy, like if we haven't registered a PolicyClient in WK2 C API.
+
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_navigationPolicyForUrl.qml: Added.
+        * UIProcess/API/qt/tests/qmltests/common/test2.html: Added.
+        * UIProcess/API/qt/tests/qmltests/qmltests.pro:
+        Add a test for DesktopWebView QML element making use of a button and a modifier to
+        ignore a navigation.
+
+        * UIProcess/qt/qtouchwebpageproxy.cpp:
+        (QTouchWebPageProxy::QTouchWebPageProxy):
+        For now, we don't have a PolicyInterface for QTouchWebView.
+
 2011-08-18  Anders Carlsson  <ander...@apple.com>
 
         WebProcess crashes during startup if libdispatch is initialized by WebProcessShim.dylib

Modified: trunk/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp (93426 => 93427)


--- trunk/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp	2011-08-19 19:15:05 UTC (rev 93427)
@@ -37,16 +37,21 @@
 
 void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder* encoder, const ResourceRequest& resourceRequest)
 {
-    notImplemented();
+    encoder->encode(resourceRequest.url().string());
 }
 
 bool ArgumentCoder<ResourceRequest>::decode(ArgumentDecoder* decoder, ResourceRequest& resourceRequest)
 {
-    notImplemented();
+    // FIXME: Add *more* coding implementation when we want to implement something that
+    // depends on this like the policy client.
 
-    // FIXME: Add real implementation when we want to implement something that
-    // depends on this like the policy client.
-    resourceRequest = WebCore::ResourceRequest();
+    ResourceRequest request;
+    String url;
+    if (!decoder->decode(url))
+        return false;
+    request.setURL(KURL(WebCore::ParsedURLString, url));
+
+    resourceRequest = request;
     return true;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp	2011-08-19 19:15:05 UTC (rev 93427)
@@ -381,4 +381,44 @@
     q->update();
 }
 
+static PolicyInterface::PolicyAction toPolicyAction(QDesktopWebView::NavigationPolicy policy)
+{
+    switch (policy) {
+    case QDesktopWebView::UsePolicy:
+        return PolicyInterface::Use;
+    case QDesktopWebView::DownloadPolicy:
+        return PolicyInterface::Download;
+    case QDesktopWebView::IgnorePolicy:
+        return PolicyInterface::Ignore;
+    }
+    ASSERT_NOT_REACHED();
+    return PolicyInterface::Ignore;
+}
+
+static bool hasMetaMethod(QObject* object, const char* methodName)
+{
+    int methodIndex = object->metaObject()->indexOfMethod(QMetaObject::normalizedSignature(methodName));
+    return methodIndex >= 0 && methodIndex < object->metaObject()->methodCount();
+}
+
+/*!
+    \qmlmethod NavigationPolicy DesktopWebView::navigationPolicyForUrl(url, button, modifiers)
+
+    This method should be implemented by the user of DesktopWebView element.
+
+    It will be called to decide the policy for a navigation: whether the WebView should ignore the navigation,
+    continue it or start a download. The return value must be one of the policies in the NavigationPolicy enumeration.
+*/
+PolicyInterface::PolicyAction QDesktopWebViewPrivate::navigationPolicyForURL(const QUrl& url, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
+{
+    // We need to check this first because invokeMethod() warns if the method doesn't exist for the object.
+    if (!hasMetaMethod(q, "navigationPolicyForUrl(QVariant,QVariant,QVariant)"))
+        return PolicyInterface::Use;
+
+    QVariant ret;
+    if (QMetaObject::invokeMethod(q, "navigationPolicyForUrl", Q_RETURN_ARG(QVariant, ret), Q_ARG(QVariant, url), Q_ARG(QVariant, button), Q_ARG(QVariant, QVariant(modifiers))))
+        return toPolicyAction(static_cast<QDesktopWebView::NavigationPolicy>(ret.toInt()));
+    return PolicyInterface::Use;
+}
+
 #include "moc_qdesktopwebview.cpp"

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h	2011-08-19 19:15:05 UTC (rev 93427)
@@ -54,8 +54,15 @@
     Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
     Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged)
     Q_PROPERTY(QWebNavigationController* navigation READ navigationController CONSTANT)
+    Q_ENUMS(NavigationPolicy)
 
 public:
+    enum NavigationPolicy {
+        UsePolicy,
+        DownloadPolicy,
+        IgnorePolicy
+    };
+
     QDesktopWebView(QSGItem* parent = 0);
     virtual ~QDesktopWebView();
 
@@ -111,4 +118,7 @@
     friend class QDesktopWebViewPrivate;
     QDesktopWebViewPrivate *d;
 };
+
+Q_DECLARE_METATYPE(QDesktopWebView::NavigationPolicy)
+
 #endif /* qdesktopwebview_h */

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h	2011-08-19 19:15:05 UTC (rev 93427)
@@ -27,7 +27,7 @@
 
 class QDesktopWebView;
 
-class QDesktopWebViewPrivate : public WebKit::ViewInterface
+class QDesktopWebViewPrivate : public WebKit::ViewInterface, public WebKit::PolicyInterface
 {
 public:
     QDesktopWebViewPrivate(QDesktopWebView*, WKContextRef = 0, WKPageGroupRef = 0);
@@ -72,6 +72,9 @@
     virtual void processDidCrash();
     virtual void didRelaunchProcess();
 
+    // PolicyInterface.
+    virtual PolicyInterface::PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers);
+
     QSharedPointer<QMenu> activeMenu;
 };
 

Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_navigationPolicyForUrl.qml (0 => 93427)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_navigationPolicyForUrl.qml	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_navigationPolicyForUrl.qml	2011-08-19 19:15:05 UTC (rev 93427)
@@ -0,0 +1,63 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit.experimental 5.0
+
+Item {
+    DesktopWebView {
+        id: webView
+        width: 200
+        height: 200
+        function navigationPolicyForUrl(url, button, modifiers) {
+            if (button == Qt.MiddleButton && modifiers & Qt.ControlModifier) {
+                otherWebView.load(url)
+                return DesktopWebView.IgnorePolicy
+            }
+            return DesktopWebView.UsePolicy
+        }
+    }
+
+    SignalSpy {
+        id: spy
+        target: webView
+        signalName: "loadSucceeded"
+    }
+
+    DesktopWebView {
+        id: otherWebView
+    }
+
+    SignalSpy {
+        id: otherSpy
+        target: otherWebView
+        signalName: "loadSucceeded"
+    }
+
+    TestCase {
+        name: "DesktopWebViewNavigationPolicyForUrl"
+        when: windowShown
+
+        function test_usePolicy() {
+            webView.load(Qt.resolvedUrl("../common/test2.html"))
+            spy.wait()
+            spy.clear()
+            compare(spy.count, 0)
+            mouseClick(webView, 100, 100, Qt.LeftButton)
+            spy.wait()
+            compare(spy.count, 1)
+            compare(webView.title, "Test page 1")
+        }
+
+        function test_ignorePolicy() {
+            webView.load(Qt.resolvedUrl("../common/test2.html"))
+            spy.wait()
+            spy.clear()
+            compare(spy.count, 0)
+            compare(otherSpy.count, 0)
+            mouseClick(webView, 100, 100, Qt.MiddleButton, Qt.ControlModifier)
+            otherSpy.wait()
+            compare(spy.count, 0)
+            compare(otherSpy.count, 1)
+            compare(otherWebView.title, "Test page 1")
+        }
+    }
+}

Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html (0 => 93427)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html	2011-08-19 19:15:05 UTC (rev 93427)
@@ -0,0 +1,6 @@
+<html>
+<head><title>Test page with huge link area</title></head>
+<body>
+<a href="" width=200 height=200></a>
+</body>
+</html>

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro	2011-08-19 19:15:05 UTC (rev 93427)
@@ -12,5 +12,6 @@
 
 OTHER_FILES += \
     DesktopWebView/tst_properties.qml \
+    DesktopWebView/tst_navigationPolicyForUrl.qml \
     TouchWebView/tst_properties.qml
 

Modified: trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp	2011-08-19 19:15:05 UTC (rev 93427)
@@ -26,11 +26,14 @@
 #include "WKURLQt.h"
 #include "qweberror.h"
 #include "qweberror_p.h"
+#include <PolicyInterface.h>
 #include <qwkcontext.h>
 #include <QtWebPageProxy.h>
 #include <ViewInterface.h>
 #include <WKFrame.h>
+#include <WKFramePolicyListener.h>
 #include <WKType.h>
+#include <WKURLRequest.h>
 
 using namespace WebKit;
 
@@ -54,6 +57,12 @@
     return reinterpret_cast<ViewInterface*>(const_cast<void*>(clientInfo));
 }
 
+static inline PolicyInterface* toPolicyInterface(const void* clientInfo)
+{
+    ASSERT(clientInfo);
+    return reinterpret_cast<PolicyInterface*>(const_cast<void*>(clientInfo));
+}
+
 static void dispatchLoadSucceeded(WKFrameRef frame, const void* clientInfo)
 {
     if (!WKFrameIsMainFrame(frame))
@@ -155,3 +164,51 @@
 void qt_wk_didRemoveAllIcons(WKIconDatabaseRef iconDatabase, const void* clientInfo)
 {
 }
+
+static Qt::MouseButton toQtMouseButton(WKEventMouseButton button)
+{
+    switch (button) {
+    case kWKEventMouseButtonLeftButton:
+        return Qt::LeftButton;
+    case kWKEventMouseButtonMiddleButton:
+        return Qt::MiddleButton;
+    case kWKEventMouseButtonRightButton:
+        return Qt::RightButton;
+    }
+    return Qt::NoButton;
+}
+
+static Qt::KeyboardModifiers toQtKeyboardModifiers(WKEventModifiers modifiers)
+{
+    Qt::KeyboardModifiers qtModifiers = Qt::NoModifier;
+    if (modifiers & kWKEventModifiersShiftKey)
+        qtModifiers |= Qt::ShiftModifier;
+    if (modifiers & kWKEventModifiersControlKey)
+        qtModifiers |= Qt::ControlModifier;
+    if (modifiers & kWKEventModifiersAltKey)
+        qtModifiers |= Qt::AltModifier;
+    if (modifiers & kWKEventModifiersMetaKey)
+        qtModifiers |= Qt::MetaModifier;
+    return qtModifiers;
+}
+
+void qt_wk_decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
+{
+    PolicyInterface* policyInterface = toPolicyInterface(clientInfo);
+    WKURLRef requestURL = WKURLRequestCopyURL(request);
+    QUrl qUrl = WKURLCopyQUrl(requestURL);
+    WKRelease(requestURL);
+
+    PolicyInterface::PolicyAction action = "" toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers));
+    switch (action) {
+    case PolicyInterface::Use:
+        WKFramePolicyListenerUse(listener);
+        break;
+    case PolicyInterface::Download:
+        WKFramePolicyListenerDownload(listener);
+        break;
+    case PolicyInterface::Ignore:
+        WKFramePolicyListenerIgnore(listener);
+        break;
+    }
+}

Modified: trunk/Source/WebKit2/UIProcess/qt/ClientImpl.h (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/qt/ClientImpl.h	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/qt/ClientImpl.h	2011-08-19 19:15:05 UTC (rev 93427)
@@ -45,6 +45,9 @@
 void qt_wk_didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef, const void* clientInfo);
 void qt_wk_didRemoveAllIcons(WKIconDatabaseRef, const void* clientInfo);
 
+// Policy client.
+void qt_wk_decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo);
+
 #ifdef __cplusplus
 }
 #endif

Added: trunk/Source/WebKit2/UIProcess/qt/PolicyInterface.h (0 => 93427)


--- trunk/Source/WebKit2/UIProcess/qt/PolicyInterface.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/qt/PolicyInterface.h	2011-08-19 19:15:05 UTC (rev 93427)
@@ -0,0 +1,41 @@
+/*
+ * 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 PolicyInterface_h
+#define PolicyInterface_h
+
+#include <QtCore/QUrl>
+
+namespace WebKit {
+
+class PolicyInterface {
+public:
+    enum PolicyAction {
+        Use,
+        Download,
+        Ignore
+    };
+
+    virtual PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers) = 0;
+};
+
+}
+
+#endif /* PolicyInterface_h */

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-08-19 19:15:05 UTC (rev 93427)
@@ -33,6 +33,7 @@
 #include "LocalizedStrings.h"
 #include "NativeWebKeyboardEvent.h"
 #include "NotImplemented.h"
+#include "PolicyInterface.h"
 #include "WebBackForwardList.h"
 #include "WebContext.h"
 #include "WebContextMenuProxyQt.h"
@@ -94,8 +95,9 @@
     return (DragOperation)result;
 }
 
-QtWebPageProxy::QtWebPageProxy(ViewInterface* viewInterface, QWKContext* c, WKPageGroupRef pageGroupRef)
+QtWebPageProxy::QtWebPageProxy(ViewInterface* viewInterface, PolicyInterface* policyInterface, QWKContext* c, WKPageGroupRef pageGroupRef)
     : m_viewInterface(viewInterface)
+    , m_policyInterface(policyInterface)
     , m_context(c)
     , m_preferences(0)
     , m_undoStack(adoptPtr(new QUndoStack(this)))
@@ -185,6 +187,18 @@
         0,  /* shouldInterruptJavaScript */
     };
     WKPageSetPageUIClient(toAPI(m_webPageProxy.get()), &uiClient);
+
+    if (m_policyInterface) {
+        WKPagePolicyClient policyClient = {
+            0,
+            m_policyInterface,
+            qt_wk_decidePolicyForNavigationAction,
+            0,  /* decidePolicyForNewWindowAction */
+            0,  /* decidePolicyForResponse */
+            0,  /* unableToImplementPolicy */
+        };
+        WKPageSetPagePolicyClient(toAPI(m_webPageProxy.get()), &policyClient);
+    }
 }
 
 QtWebPageProxy::~QtWebPageProxy()

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-08-19 19:15:05 UTC (rev 93427)
@@ -25,6 +25,7 @@
 
 #include "LayerTreeContext.h"
 #include "PageClient.h"
+#include "PolicyInterface.h"
 #include "qwebkittypes.h"
 #include "ShareableBitmap.h"
 #include "ViewportArguments.h"
@@ -70,7 +71,7 @@
         WebActionCount
     };
 
-    QtWebPageProxy(WebKit::ViewInterface* viewInterface, QWKContext*, WKPageGroupRef = 0);
+    QtWebPageProxy(WebKit::ViewInterface*, WebKit::PolicyInterface*, QWKContext*, WKPageGroupRef = 0);
     ~QtWebPageProxy();
 
     virtual bool handleEvent(QEvent*);
@@ -187,6 +188,7 @@
     virtual void paintContent(QPainter* painter, const QRect& area) = 0;
     RefPtr<WebKit::WebPageProxy> m_webPageProxy;
     WebKit::ViewInterface* const m_viewInterface;
+    WebKit::PolicyInterface* const m_policyInterface;
 
 private:
     bool handleKeyPressEvent(QKeyEvent*);

Modified: trunk/Source/WebKit2/UIProcess/qt/qdesktopwebpageproxy.cpp (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/qt/qdesktopwebpageproxy.cpp	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/qt/qdesktopwebpageproxy.cpp	2011-08-19 19:15:05 UTC (rev 93427)
@@ -47,8 +47,8 @@
     return result;
 }
 
-QDesktopWebPageProxy::QDesktopWebPageProxy(QDesktopWebViewPrivate* viewInterface, QWKContext* context, WKPageGroupRef pageGroup)
-    : QtWebPageProxy(viewInterface, context, pageGroup)
+QDesktopWebPageProxy::QDesktopWebPageProxy(QDesktopWebViewPrivate* desktopWebView, QWKContext* context, WKPageGroupRef pageGroup)
+    : QtWebPageProxy(desktopWebView, desktopWebView, context, pageGroup)
 {
     init();
 }

Modified: trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.cpp (93426 => 93427)


--- trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.cpp	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.cpp	2011-08-19 19:15:05 UTC (rev 93427)
@@ -28,7 +28,7 @@
 using namespace WebCore;
 
 QTouchWebPageProxy::QTouchWebPageProxy(TouchViewInterface* viewInterface, ViewportInteractionEngine* viewportInteractionEngine, QWKContext* context, WKPageGroupRef pageGroupRef)
-    : QtWebPageProxy(viewInterface, context, pageGroupRef)
+    : QtWebPageProxy(viewInterface, 0, context, pageGroupRef)
     , m_panGestureRecognizer(viewportInteractionEngine)
     , m_pinchGestureRecognizer(viewportInteractionEngine)
 {

Modified: trunk/Source/WebKit2/WebKit2.pro (93426 => 93427)


--- trunk/Source/WebKit2/WebKit2.pro	2011-08-19 19:08:10 UTC (rev 93426)
+++ trunk/Source/WebKit2/WebKit2.pro	2011-08-19 19:15:05 UTC (rev 93427)
@@ -237,6 +237,7 @@
     UIProcess/WebUIClient.h \
     UIProcess/qt/ClientImpl.h \
     UIProcess/qt/TouchViewInterface.h \
+    UIProcess/qt/PolicyInterface.h \
     UIProcess/qt/QtGestureRecognizer.h \
     UIProcess/qt/QtPanGestureRecognizer.h \
     UIProcess/qt/QtPinchGestureRecognizer.h \
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to