[Qt] [WK2] Move PagePolicyClient related code to QtWebPagePolicyClient
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Nov 2011 13:20:01 +0000 (13:20 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Nov 2011 13:20:01 +0000 (13:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72959

Reviewed by Andreas Kling.

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

QtPolicyInterface abstraction was not helping us as much as the separation of
the client code will. It was more useful when we had multiple WebViews.

* Target.pri:
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::QQuickWebViewPrivate):
(toPolicyAction):
(QQuickWebViewPrivate::navigationPolicyForURL):
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qquickwebview_p_p.h:
* UIProcess/qt/ClientImpl.cpp:
* UIProcess/qt/ClientImpl.h:
* UIProcess/qt/QtWebPagePolicyClient.cpp: Added.
(QtWebPagePolicyClient::QtWebPagePolicyClient):
(QtWebPagePolicyClient::decidePolicyForNavigationAction):
(toQtWebPagePolicyClient):
(toQtMouseButton):
(toQtKeyboardModifiers):
(QtWebPagePolicyClient::decidePolicyForResponse):
* UIProcess/qt/QtWebPagePolicyClient.h: Renamed from Source/WebKit2/UIProcess/qt/QtPolicyInterface.h.
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::QtWebPageProxy):
(QtWebPageProxy::init):
* UIProcess/qt/QtWebPageProxy.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@101071 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/QtWebPagePolicyClient.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h [moved from Source/WebKit2/UIProcess/qt/QtPolicyInterface.h with 55% similarity]
Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp
Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

index 8ffcb22..2508021 100644 (file)
@@ -1,3 +1,39 @@
+2011-11-22  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        [Qt] [WK2] Move PagePolicyClient related code to QtWebPagePolicyClient
+        https://bugs.webkit.org/show_bug.cgi?id=72959
+
+        Reviewed by Andreas Kling.
+
+        Split PagePolicyClient related code from QtWebPageProxy/ClientImpl. The new
+        QtWebPagePolicyClient registers itself with WKPageRef and it's owned by the
+        QQuickWebViewPrivate. This is a move to clean up QtWebPageProxy object.
+
+        QtPolicyInterface abstraction was not helping us as much as the separation of
+        the client code will. It was more useful when we had multiple WebViews.
+
+        * Target.pri:
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::QQuickWebViewPrivate):
+        (toPolicyAction):
+        (QQuickWebViewPrivate::navigationPolicyForURL):
+        * UIProcess/API/qt/qquickwebview_p.h:
+        * UIProcess/API/qt/qquickwebview_p_p.h:
+        * UIProcess/qt/ClientImpl.cpp:
+        * UIProcess/qt/ClientImpl.h:
+        * UIProcess/qt/QtWebPagePolicyClient.cpp: Added.
+        (QtWebPagePolicyClient::QtWebPagePolicyClient):
+        (QtWebPagePolicyClient::decidePolicyForNavigationAction):
+        (toQtWebPagePolicyClient):
+        (toQtMouseButton):
+        (toQtKeyboardModifiers):
+        (QtWebPagePolicyClient::decidePolicyForResponse):
+        * UIProcess/qt/QtWebPagePolicyClient.h: Renamed from Source/WebKit2/UIProcess/qt/QtPolicyInterface.h.
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::QtWebPageProxy):
+        (QtWebPageProxy::init):
+        * UIProcess/qt/QtWebPageProxy.h:
+
 2011-11-23  Raphael Kubo da Costa  <kubo@profusion.mobi>
 
         [CMake] Move the top-level logic to the top-level directory.
index a552d55..14c9c0c 100644 (file)
@@ -314,7 +314,6 @@ HEADERS += \
     UIProcess/WebResourceLoadClient.h \
     UIProcess/WebUIClient.h \
     UIProcess/qt/ClientImpl.h \
-    UIProcess/qt/QtPolicyInterface.h \
     UIProcess/qt/QtGestureRecognizer.h \
     UIProcess/qt/QtPanGestureRecognizer.h \
     UIProcess/qt/QtPinchGestureRecognizer.h \
@@ -323,6 +322,7 @@ HEADERS += \
     UIProcess/qt/QtDialogRunner.h \
     UIProcess/qt/QtDownloadManager.h \
     UIProcess/qt/QtWebPageLoadClient.h \
+    UIProcess/qt/QtWebPagePolicyClient.h \
     UIProcess/qt/QtWebPageProxy.h \
     UIProcess/qt/QtWebPageUIClient.h \
     UIProcess/qt/qwkhistory.h \
@@ -630,6 +630,7 @@ SOURCES += \
     UIProcess/qt/QtDialogRunner.cpp \
     UIProcess/qt/QtDownloadManager.cpp \
     UIProcess/qt/QtWebPageLoadClient.cpp \
+    UIProcess/qt/QtWebPagePolicyClient.cpp \
     UIProcess/qt/QtWebPageProxy.cpp \
     UIProcess/qt/QtWebPageUIClient.cpp \
     UIProcess/qt/qwkhistory.cpp \
index 4b2f2f3..513e98e 100644 (file)
@@ -51,14 +51,15 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport, WKContextRef
     pageView.reset(new QQuickWebPage(viewport));
 
     QQuickWebPagePrivate* const pageViewPrivate = pageView.data()->d;
-    setPageProxy(new QtWebPageProxy(pageView.data(), q_ptr, 0, this, contextRef, pageGroupRef));
+    setPageProxy(new QtWebPageProxy(pageView.data(), q_ptr, /* interactionEngine */ 0, contextRef, pageGroupRef));
     pageViewPrivate->setPageProxy(pageProxy.data());
 
     QWebPreferencesPrivate::get(pageProxy->preferences())->setAttribute(QWebPreferencesPrivate::AcceleratedCompositingEnabled, true);
     pageProxy->init();
 
-    pageUIClient.reset(new QtWebPageUIClient(pageProxy->pageRef(), q_ptr));
     pageLoadClient.reset(new QtWebPageLoadClient(pageProxy->pageRef(), q_ptr));
+    pagePolicyClient.reset(new QtWebPagePolicyClient(pageProxy->pageRef(), q_ptr));
+    pageUIClient.reset(new QtWebPageUIClient(pageProxy->pageRef(), q_ptr));
 }
 
 void QQuickWebViewPrivate::enableMouseEvents()
@@ -343,18 +344,18 @@ void QQuickWebViewPrivate::setViewInAttachedProperties(QObject* object)
     attached->setView(q);
 }
 
-static QtPolicyInterface::PolicyAction toPolicyAction(QQuickWebView::NavigationPolicy policy)
+static QtWebPagePolicyClient::PolicyAction toPolicyAction(QQuickWebView::NavigationPolicy policy)
 {
     switch (policy) {
     case QQuickWebView::UsePolicy:
-        return QtPolicyInterface::Use;
+        return QtWebPagePolicyClient::Use;
     case QQuickWebView::DownloadPolicy:
-        return QtPolicyInterface::Download;
+        return QtWebPagePolicyClient::Download;
     case QQuickWebView::IgnorePolicy:
-        return QtPolicyInterface::Ignore;
+        return QtWebPagePolicyClient::Ignore;
     }
     ASSERT_NOT_REACHED();
-    return QtPolicyInterface::Ignore;
+    return QtWebPagePolicyClient::Ignore;
 }
 
 static bool hasMetaMethod(QObject* object, const char* methodName)
@@ -371,17 +372,17 @@ static bool hasMetaMethod(QObject* object, const char* methodName)
     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.
 */
-QtPolicyInterface::PolicyAction QQuickWebViewPrivate::navigationPolicyForURL(const QUrl& url, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
+QtWebPagePolicyClient::PolicyAction QQuickWebViewPrivate::navigationPolicyForURL(const QUrl& url, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
 {
     Q_Q(QQuickWebView);
     // 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 QtPolicyInterface::Use;
+        return QtWebPagePolicyClient::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<QQuickWebView::NavigationPolicy>(ret.toInt()));
-    return QtPolicyInterface::Use;
+    return QtWebPagePolicyClient::Use;
 }
 
 void QQuickWebViewPrivate::setPageProxy(QtWebPageProxy* pageProxy)
index 2d107f6..7be2a89 100644 (file)
@@ -135,6 +135,7 @@ private:
     QQuickWebViewExperimental* m_experimental;
 
     friend class QtWebPageLoadClient;
+    friend class QtWebPagePolicyClient;
     friend class QtWebPageProxy;
     friend class QtWebPageUIClient;
     friend class WTR::PlatformWebView;
index 1e1ecbb..e320b38 100644 (file)
@@ -21,9 +21,9 @@
 #ifndef qquickwebview_p_p_h
 #define qquickwebview_p_p_h
 
-#include "QtPolicyInterface.h"
 #include "QtViewportInteractionEngine.h"
 #include "QtWebPageLoadClient.h"
+#include "QtWebPagePolicyClient.h"
 #include "QtWebPageProxy.h"
 #include "QtWebPageUIClient.h"
 
@@ -41,8 +41,7 @@ class QDeclarativeComponent;
 class QFileDialog;
 QT_END_NAMESPACE
 
-class QQuickWebViewPrivate : public WebKit::QtPolicyInterface {
-
+class QQuickWebViewPrivate {
     Q_DECLARE_PUBLIC(QQuickWebView)
     friend class QQuickWebViewExperimental;
 
@@ -71,8 +70,7 @@ public:
     void _q_onOpenPanelFinished(int result);
     void _q_onVisibleChanged();
 
-    // QtPolicyInterface.
-    virtual QtPolicyInterface::PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers);
+    QtWebPagePolicyClient::PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers);
 
     void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, QtWebPageUIClient::FileChooserType);
     void runJavaScriptAlert(const QString&);
@@ -112,8 +110,9 @@ private:
 
     void setViewInAttachedProperties(QObject*);
 
-    QScopedPointer<QtWebPageUIClient> pageUIClient;
     QScopedPointer<QtWebPageLoadClient> pageLoadClient;
+    QScopedPointer<QtWebPagePolicyClient> pagePolicyClient;
+    QScopedPointer<QtWebPageUIClient> pageUIClient;
 
     QScopedPointer<QQuickWebPage> pageView;
     QScopedPointer<QtViewportInteractionEngine> interactionEngine;
index 5c75d89..fd261c8 100644 (file)
 
 #include "WebPageProxy.h"
 #include "WKAPICast.h"
-#include "WKURLQt.h"
-#include <QtPolicyInterface.h>
 #include <WKArray.h>
-#include <WKFrame.h>
-#include <WKFramePolicyListener.h>
 #include <WKPage.h>
 #include <WKString.h>
 #include <WKType.h>
-#include <WKURLRequest.h>
 
 using namespace WebKit;
 
-static inline QtPolicyInterface* toQtPolicyInterface(const void* clientInfo)
-{
-    ASSERT(clientInfo);
-    return reinterpret_cast<QtPolicyInterface*>(const_cast<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;
-}
-
-static void qt_wk_decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
-{
-    QtPolicyInterface* policyInterface = toQtPolicyInterface(clientInfo);
-    WKURLRef requestURL = WKURLRequestCopyURL(request);
-    QUrl qUrl = WKURLCopyQUrl(requestURL);
-    WKRelease(requestURL);
-
-    QtPolicyInterface::PolicyAction action = policyInterface->navigationPolicyForURL(qUrl, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers));
-    switch (action) {
-    case QtPolicyInterface::Use:
-        WKFramePolicyListenerUse(listener);
-        break;
-    case QtPolicyInterface::Download:
-        WKFramePolicyListenerDownload(listener);
-        break;
-    case QtPolicyInterface::Ignore:
-        WKFramePolicyListenerIgnore(listener);
-        break;
-    }
-}
-
-static void qt_wk_decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
-{
-    String type = toImpl(response)->resourceResponse().mimeType();
-    type.makeLower();
-    bool canShowMIMEType = toImpl(frame)->canShowMIMEType(type);
-
-    if (WKPageGetMainFrame(page) == frame) {
-        if (canShowMIMEType) {
-            WKFramePolicyListenerUse(listener);
-            return;
-        }
-
-        // If we can't use (show) it then we should download it.
-        WKFramePolicyListenerDownload(listener);
-        return;
-    }
-
-    // We should ignore downloadable top-level content for subframes, with an exception for text/xml and application/xml so we can still support Acid3 test.
-    // It makes the browser intentionally behave differently when it comes to text(application)/xml content in subframes vs. mainframe.
-    if (!canShowMIMEType && !(type == "text/xml" || type == "application/xml")) {
-        WKFramePolicyListenerIgnore(listener);
-        return;
-    }
-
-    WKFramePolicyListenerUse(listener);
-}
-
 void qt_wk_didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*)
 {
     if (!WKStringIsEqualToUTF8CString(messageName, "MessageFromNavigatorQtObject"))
@@ -134,17 +48,6 @@ void qt_wk_didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef message
     toImpl(page)->didReceiveMessageFromNavigatorQtObject(toImpl(str)->string());
 }
 
-void setupPagePolicyClient(QtPolicyInterface* policyInterface, WebPageProxy* webPageProxy)
-{
-    WKPagePolicyClient policyClient;
-    memset(&policyClient, 0, sizeof(WKPagePolicyClient));
-    policyClient.version = kWKPagePolicyClientCurrentVersion;
-    policyClient.clientInfo = policyInterface;
-    policyClient.decidePolicyForNavigationAction = qt_wk_decidePolicyForNavigationAction;
-    policyClient.decidePolicyForResponse = qt_wk_decidePolicyForResponse;
-    WKPageSetPagePolicyClient(toAPI(webPageProxy), &policyClient);
-}
-
 void setupContextInjectedBundleClient(WKContextRef context)
 {
     WKContextInjectedBundleClient injectedBundleClient;
index d77aaba..5b2f438 100644 (file)
 
 #include <WebKit2/WKContext.h>
 
-namespace WebKit {
-class QtPolicyInterface;
-class WebPageProxy;
-}
-
-void setupPagePolicyClient(WebKit::QtPolicyInterface*, WebKit::WebPageProxy*);
-
 void setupContextInjectedBundleClient(WKContextRef);
 
 #endif /* ClientImpl_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp
new file mode 100644 (file)
index 0000000..2fafdfe
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * 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 "QtWebPagePolicyClient.h"
+
+#include "WKURLQt.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include <WKFramePolicyListener.h>
+#include <WKURLRequest.h>
+
+QtWebPagePolicyClient::QtWebPagePolicyClient(WKPageRef pageRef, QQuickWebView* webView)
+    : m_webView(webView)
+{
+    WKPagePolicyClient policyClient;
+    memset(&policyClient, 0, sizeof(WKPagePolicyClient));
+    policyClient.version = kWKPagePolicyClientCurrentVersion;
+    policyClient.clientInfo = this;
+    policyClient.decidePolicyForNavigationAction = decidePolicyForNavigationAction;
+    policyClient.decidePolicyForResponse = decidePolicyForResponse;
+    WKPageSetPagePolicyClient(pageRef, &policyClient);
+}
+
+QtWebPagePolicyClient::PolicyAction QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers)
+{
+    return m_webView->d_func()->navigationPolicyForURL(url, mouseButton, keyboardModifiers);
+}
+
+static inline QtWebPagePolicyClient* toQtWebPagePolicyClient(const void* clientInfo)
+{
+    ASSERT(clientInfo);
+    return reinterpret_cast<QtWebPagePolicyClient*>(const_cast<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;
+    case kWKEventMouseButtonNoButton:
+        return Qt::NoButton;
+    }
+    ASSERT_NOT_REACHED();
+    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 QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)
+{
+    WKURLRef requestURL = WKURLRequestCopyURL(request);
+    QUrl qUrl = WKURLCopyQUrl(requestURL);
+    WKRelease(requestURL);
+
+    PolicyAction action = toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers));
+    switch (action) {
+    case Use:
+        WKFramePolicyListenerUse(listener);
+        return;
+    case Download:
+        WKFramePolicyListenerDownload(listener);
+        return;
+    case Ignore:
+        WKFramePolicyListenerIgnore(listener);
+        return;
+    }
+    ASSERT_NOT_REACHED();
+}
+
+void QtWebPagePolicyClient::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void*)
+{
+    String type = toImpl(response)->resourceResponse().mimeType();
+    type.makeLower();
+    bool canShowMIMEType = toImpl(frame)->canShowMIMEType(type);
+
+    if (WKPageGetMainFrame(page) == frame) {
+        if (canShowMIMEType) {
+            WKFramePolicyListenerUse(listener);
+            return;
+        }
+
+        // If we can't use (show) it then we should download it.
+        WKFramePolicyListenerDownload(listener);
+        return;
+    }
+
+    // We should ignore downloadable top-level content for subframes, with an exception for text/xml and application/xml so we can still support Acid3 test.
+    // It makes the browser intentionally behave differently when it comes to text(application)/xml content in subframes vs. mainframe.
+    if (!canShowMIMEType && !(type == "text/xml" || type == "application/xml")) {
+        WKFramePolicyListenerIgnore(listener);
+        return;
+    }
+
+    WKFramePolicyListenerUse(listener);
+}
+
  *
  */
 
-#ifndef QtPolicyInterface_h
-#define QtPolicyInterface_h
+#ifndef QtWebPagePolicyClient_h
+#define QtWebPagePolicyClient_h
 
 #include <QtCore/QUrl>
+#include <WKPage.h>
 
-namespace WebKit {
+class QQuickWebView;
 
-class QtPolicyInterface {
+class QtWebPagePolicyClient {
 public:
+    QtWebPagePolicyClient(WKPageRef, QQuickWebView*);
+
     enum PolicyAction {
         Use,
         Download,
         Ignore
     };
 
-    virtual PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers) = 0;
-};
+private:
+    PolicyAction decidePolicyForNavigationAction(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers);
 
-}
+    // WKPagePolicyClient callbacks.
+    static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo);
+    static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo);
+
+    QQuickWebView* m_webView;
+};
 
-#endif // QtPolicyInterface_h
+#endif // QtWebPagePolicyClient_h
index c10773b..d2a6d1c 100644 (file)
@@ -44,7 +44,6 @@
 #include "NativeWebMouseEvent.h"
 #include "NativeWebWheelEvent.h"
 #include "NotImplemented.h"
-#include "QtPolicyInterface.h"
 #include "QtViewportInteractionEngine.h"
 #include "QtWebUndoCommand.h"
 #include "WebBackForwardList.h"
@@ -133,14 +132,13 @@ WebCore::DragOperation dropActionToDragOperation(Qt::DropActions actions)
     return (DragOperation)result;
 }
 
-QtWebPageProxy::QtWebPageProxy(QQuickWebPage* qmlWebPage, QQuickWebView* qmlWebView, QtViewportInteractionEngine* viewportInteractionEngine, QtPolicyInterface* policyInterface, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+QtWebPageProxy::QtWebPageProxy(QQuickWebPage* qmlWebPage, QQuickWebView* qmlWebView, QtViewportInteractionEngine* viewportInteractionEngine, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
     : m_qmlWebPage(qmlWebPage)
     , m_qmlWebView(qmlWebView)
     , m_interactionEngine(viewportInteractionEngine)
     , m_panGestureRecognizer(viewportInteractionEngine)
     , m_pinchGestureRecognizer(viewportInteractionEngine)
     , m_tapGestureRecognizer(viewportInteractionEngine, this)
-    , m_policyInterface(policyInterface)
     , m_context(contextRef ? toImpl(contextRef) : defaultWKContext())
     , m_undoStack(adoptPtr(new QUndoStack(this)))
     , m_navigatorQtObjectEnabled(false)
@@ -154,8 +152,6 @@ QtWebPageProxy::QtWebPageProxy(QQuickWebPage* qmlWebPage, QQuickWebView* qmlWebV
 void QtWebPageProxy::init()
 {
     m_webPageProxy->initializeWebPage();
-    if (m_policyInterface)
-        setupPagePolicyClient(m_policyInterface, m_webPageProxy.get());
 }
 
 QtWebPageProxy::~QtWebPageProxy()
index ca36820..b04ee0e 100644 (file)
@@ -27,7 +27,6 @@
 #include "QtDownloadManager.h"
 #include "QtPanGestureRecognizer.h"
 #include "QtPinchGestureRecognizer.h"
-#include "QtPolicyInterface.h"
 #include "QtTapGestureRecognizer.h"
 #include "ShareableBitmap.h"
 #include "ViewportArguments.h"
@@ -74,7 +73,7 @@ public:
         WebActionCount
     };
 
-    QtWebPageProxy(QQuickWebPage*, QQuickWebView*, WebKit::QtViewportInteractionEngine* = 0, WebKit::QtPolicyInterface* = 0, WKContextRef = 0, WKPageGroupRef = 0);
+    QtWebPageProxy(QQuickWebPage*, QQuickWebView*, WebKit::QtViewportInteractionEngine* = 0, WKContextRef = 0, WKPageGroupRef = 0);
     ~QtWebPageProxy();
 
     virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
@@ -213,7 +212,6 @@ protected:
     QtPanGestureRecognizer m_panGestureRecognizer;
     QtPinchGestureRecognizer m_pinchGestureRecognizer;
     QtTapGestureRecognizer m_tapGestureRecognizer;
-    WebKit::QtPolicyInterface* const m_policyInterface;
 
 private:
     bool handleKeyPressEvent(QKeyEvent*);