[Qt] [WK2] Provide API for intercept (and possible ignore) links clicked in QDesktopW...
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Aug 2011 19:15:05 +0000 (19:15 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Aug 2011 19:15:05 +0000 (19:15 +0000)
commit868dead1e1a93cd146c8fb56b94d1d659ff0b45c
tree1f5f5e402e935632ef17ab6dec6f55e714a6ec00
parentce5b0db11ba294551e8c6bda8489fc59b47d54f8
[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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93427 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp
Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp
Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h
Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_navigationPolicyForUrl.qml [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro
Source/WebKit2/UIProcess/qt/ClientImpl.cpp
Source/WebKit2/UIProcess/qt/ClientImpl.h
Source/WebKit2/UIProcess/qt/PolicyInterface.h [new file with mode: 0644]
Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp
Source/WebKit2/UIProcess/qt/QtWebPageProxy.h
Source/WebKit2/UIProcess/qt/qdesktopwebpageproxy.cpp
Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.cpp
Source/WebKit2/WebKit2.pro