Diff
Modified: trunk/ChangeLog (101455 => 101456)
--- trunk/ChangeLog 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/ChangeLog 2011-11-30 08:41:19 UTC (rev 101456)
@@ -1,3 +1,16 @@
+2011-11-30 Adenilson Cavalcanti <adenilson.si...@openbossa.org>
+
+ [Qt][WK2] Implement permission API for Qt port
+ https://bugs.webkit.org/show_bug.cgi?id=59200
+
+ Permission API hookup for Geolocation, it allows to receive in WebView
+ a signal when a permission request is done (e.g. to grant permission
+ for accessing geolocation information) and set it accordingly.
+
+ Reviewed by Simon Hausmann.
+
+ * Source/qtwebkit-export.map:
+
2011-11-29 Kevin Ollivier <kev...@theolliviers.com>
[wx] Unreviewed build fix for Leopard compilation.
Modified: trunk/Source/WebKit/qt/ChangeLog (101455 => 101456)
--- trunk/Source/WebKit/qt/ChangeLog 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/Source/WebKit/qt/ChangeLog 2011-11-30 08:41:19 UTC (rev 101456)
@@ -1,3 +1,17 @@
+2011-11-30 Adenilson Cavalcanti <adenilson.si...@openbossa.org>
+
+ [Qt][WK2] Implement permission API for Qt port
+ https://bugs.webkit.org/show_bug.cgi?id=59200
+
+ Permission API hookup for Geolocation, it allows to receive in WebView
+ a signal when a permission request is done (e.g. to grant permission
+ for accessing geolocation information) and set it accordingly.
+
+ Reviewed by Simon Hausmann.
+
+ * declarative/plugin.cpp:
+ (WebKitQmlPlugin::registerTypes):
+
2011-11-29 Simon Hausmann <simon.hausm...@nokia.com>
[Qt] Make WebKit/qt build with V8 and Qt 5
Modified: trunk/Source/WebKit/qt/declarative/plugin.cpp (101455 => 101456)
--- trunk/Source/WebKit/qt/declarative/plugin.cpp 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/Source/WebKit/qt/declarative/plugin.cpp 2011-11-30 08:41:19 UTC (rev 101456)
@@ -25,6 +25,7 @@
#if defined(HAVE_WEBKIT2)
#include "qquickwebpage_p.h"
#include "qquickwebview_p.h"
+#include "qwebpermissionrequest_p.h"
#include "qwebpreferences_p.h"
#include <QtNetwork/qnetworkreply.h>
@@ -51,6 +52,7 @@
qmlRegisterUncreatableType<QWebPreferences>(uri, 3, 0, "WebPreferences", QObject::tr("Cannot create separate instance of WebPreferences"));
qmlRegisterUncreatableType<QQuickWebPage>(uri, 3, 0, "WebPage", QObject::tr("Cannot create separate instance of WebPage, use WebView"));
qmlRegisterUncreatableType<QNetworkReply>(uri, 3, 0, "NetworkReply", QObject::tr("Cannot create separate instance of NetworkReply"));
+ qmlRegisterUncreatableType<QWebPermissionRequest>(uri, 3, 0, "PermissionRequest", QObject::tr("Cannot create separate instance of PermissionRequest"));
#endif
}
};
Modified: trunk/Source/WebKit2/ChangeLog (101455 => 101456)
--- trunk/Source/WebKit2/ChangeLog 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/Source/WebKit2/ChangeLog 2011-11-30 08:41:19 UTC (rev 101456)
@@ -1,3 +1,38 @@
+2011-11-30 Adenilson Cavalcanti <adenilson.si...@openbossa.org>
+
+ [Qt][WK2] Implement permission API for Qt port
+ https://bugs.webkit.org/show_bug.cgi?id=59200
+
+ Permission API hookup for Geolocation, it allows to receive in WebView
+ a signal when a permission request is done (e.g. to grant permission
+ for accessing geolocation information) and set it accordingly.
+
+ Reviewed by Simon Hausmann.
+
+ * Target.pri:
+ * UIProcess/API/qt/qquickwebview_p.h:
+ * UIProcess/API/qt/qwebpermissionrequest.cpp: Added.
+ (QWebPermissionRequestPrivate::QWebPermissionRequestPrivate):
+ (QWebPermissionRequestPrivate::~QWebPermissionRequestPrivate):
+ (QWebPermissionRequest::create):
+ (QWebPermissionRequest::QWebPermissionRequest):
+ (QWebPermissionRequest::~QWebPermissionRequest):
+ (QWebPermissionRequest::type):
+ (QWebPermissionRequest::setAllow):
+ (QWebPermissionRequest::allow):
+ (QWebPermissionRequest::scheme):
+ (QWebPermissionRequest::host):
+ (QWebPermissionRequest::port):
+ * UIProcess/API/qt/qwebpermissionrequest_p.h: Added.
+ * UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml: Added.
+ * UIProcess/API/qt/tests/qmltests/common/geolocation.html: Added.
+ * UIProcess/API/qt/tests/qmltests/qmltests.pro:
+ * UIProcess/qt/QtWebPageUIClient.cpp:
+ (QtWebPageUIClient::QtWebPageUIClient):
+ (QtWebPageUIClient::permissionRequest):
+ (QtWebPageUIClient::policyForGeolocationPermissionRequest):
+ * UIProcess/qt/QtWebPageUIClient.h:
+
2011-11-30 Alexey Proskuryakov <a...@apple.com>
-[WKView attributedSubstringForProposedRange:actualRange:] doesn't update actualRange when it's out of bounds
Modified: trunk/Source/WebKit2/Target.pri (101455 => 101456)
--- trunk/Source/WebKit2/Target.pri 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/Source/WebKit2/Target.pri 2011-11-30 08:41:19 UTC (rev 101456)
@@ -174,6 +174,7 @@
UIProcess/API/qt/qwebpreferences_p_p.h \
UIProcess/API/qt/qwebdownloaditem_p.h \
UIProcess/API/qt/qwebdownloaditem_p_p.h \
+ UIProcess/API/qt/qwebpermissionrequest_p.h \
UIProcess/API/qt/qquickwebpage_p.h \
UIProcess/API/qt/qquickwebpage_p_p.h \
UIProcess/API/qt/qquickwebview_p.h \
@@ -482,6 +483,7 @@
UIProcess/API/cpp/qt/WKStringQt.cpp \
UIProcess/API/cpp/qt/WKURLQt.cpp \
UIProcess/API/qt/qwebdownloaditem.cpp \
+ UIProcess/API/qt/qwebpermissionrequest.cpp \
UIProcess/API/qt/qquickwebpage.cpp \
UIProcess/API/qt/qquickwebview.cpp \
UIProcess/API/qt/qwebpreferences.cpp \
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h (101455 => 101456)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h 2011-11-30 08:41:19 UTC (rev 101456)
@@ -31,6 +31,7 @@
class QQuickWebViewExperimental;
class QWebDownloadItem;
class QWebPreferences;
+class QWebPermissionRequest;
namespace WTR {
class PlatformWebView;
@@ -192,12 +193,14 @@
void confirmDialogChanged();
void promptDialogChanged();
void downloadRequested(QWebDownloadItem* downloadItem);
+ void permissionRequested(QWebPermissionRequest* permission);
private:
QQuickWebView* q_ptr;
QQuickWebViewPrivate* d_ptr;
friend class QtWebPageProxy;
+ friend class QtWebPageUIClient;
Q_DECLARE_PRIVATE(QQuickWebView)
Q_DECLARE_PUBLIC(QQuickWebView)
Added: trunk/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp (0 => 101456)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp 2011-11-30 08:41:19 UTC (rev 101456)
@@ -0,0 +1,106 @@
+/*
+ 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 library 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 library; 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 "qwebpermissionrequest_p.h"
+
+#include "WKStringQt.h"
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKRetainPtr.h>
+
+
+class QWebPermissionRequestPrivate : public QSharedData {
+public:
+ QWebPermissionRequestPrivate(WKSecurityOriginRef securityOrigin, WKGeolocationPermissionRequestRef permissionRequest)
+ : origin(securityOrigin)
+ , type(QWebPermissionRequest::Geolocation)
+ , request(permissionRequest)
+ , allow(false)
+ {
+ }
+ ~QWebPermissionRequestPrivate()
+ {
+ }
+
+ WKRetainPtr<WKSecurityOriginRef> origin;
+ QWebPermissionRequest::RequestType type;
+ WKRetainPtr<WKGeolocationPermissionRequestRef> request;
+ bool allow;
+};
+
+QWebPermissionRequest* QWebPermissionRequest::create(WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef request)
+{
+ return new QWebPermissionRequest(origin, request);
+}
+
+QWebPermissionRequest::QWebPermissionRequest(WKSecurityOriginRef securityOrigin, WKGeolocationPermissionRequestRef permissionRequest, QObject* parent)
+ : QObject(parent)
+ , d(new QWebPermissionRequestPrivate(securityOrigin, permissionRequest))
+{
+}
+
+QWebPermissionRequest::~QWebPermissionRequest()
+{
+}
+
+QWebPermissionRequest::RequestType QWebPermissionRequest::type() const
+{
+ return d->type;
+}
+
+void QWebPermissionRequest::setAllow(bool accepted)
+{
+ d->allow = accepted;
+ switch (type()) {
+ case Geolocation: {
+ if (accepted)
+ WKGeolocationPermissionRequestAllow(d->request.get());
+ else
+ WKGeolocationPermissionRequestDeny(d->request.get());
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ deleteLater();
+}
+
+bool QWebPermissionRequest::allow() const
+{
+ return d->allow;
+}
+
+QString QWebPermissionRequest::scheme() const
+{
+ WKRetainPtr<WKStringRef> url = ""
+ return WKStringCopyQString(url.get());
+}
+
+QString QWebPermissionRequest::host() const
+{
+ WKRetainPtr<WKStringRef> origin = adoptWK(WKSecurityOriginCopyHost(d->origin.get()));
+ return WKStringCopyQString(origin.get());
+}
+
+int QWebPermissionRequest::port() const
+{
+ return static_cast<int>(WKSecurityOriginGetPort(d->origin.get()));
+}
Added: trunk/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h (0 => 101456)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h 2011-11-30 08:41:19 UTC (rev 101456)
@@ -0,0 +1,67 @@
+/*
+ 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 library 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 library; 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 qwebpermissionrequest_p_h
+#define qwebpermissionrequest_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QtCore/QObject>
+#include <QtCore/qshareddata.h>
+#include <WebKit2/WKGeolocationPermissionRequest.h>
+#include <WebKit2/WKSecurityOrigin.h>
+
+class QWebPermissionRequestPrivate;
+
+class QWEBKIT_EXPORT QWebPermissionRequest : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool allow READ allow WRITE setAllow)
+ Q_PROPERTY(RequestType type READ type)
+ Q_PROPERTY(QString scheme READ scheme)
+ Q_PROPERTY(QString host READ host)
+ Q_PROPERTY(int port READ port)
+ Q_ENUMS(RequestType)
+
+public:
+ enum RequestType {
+ Geolocation
+ };
+
+ static QWebPermissionRequest* create(WKSecurityOriginRef, WKGeolocationPermissionRequestRef);
+ virtual ~QWebPermissionRequest();
+
+ RequestType type() const;
+ bool allow() const;
+ QString scheme() const;
+ QString host() const;
+ int port() const;
+
+public Q_SLOTS:
+ void setAllow(bool);
+
+private:
+ friend class QWebPermissionRequestPrivate;
+ QWebPermissionRequest(WKSecurityOriginRef securityOrigin, WKGeolocationPermissionRequestRef permissionRequest, QObject* parent = 0);
+
+private:
+ QExplicitlySharedDataPointer<QWebPermissionRequestPrivate> d;
+};
+
+
+#endif // qwebpermissionrequest_h
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml (0 => 101456)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml 2011-11-30 08:41:19 UTC (rev 101456)
@@ -0,0 +1,55 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+WebView {
+ id: webView
+ width: 200
+ height: 200
+
+ property bool expectedPermission: false
+
+ SignalSpy {
+ id: spy
+ target: experimental
+ signalName: "permissionRequested"
+ }
+
+ experimental.onPermissionRequested: {
+ //Must be false by default
+ if (!permission.allow) {
+ permission.allow = true
+ } else
+ console.log("Fail: permission must be set to false")
+
+ if (permission.type == PermissionRequest.Geolocation) {
+ console.log("Permission is geotype")
+ }
+ }
+
+ TestCase {
+ name: "WebViewGeopermission"
+
+ // Delayed windowShown to workaround problems with Qt5 in debug mode.
+ when: false
+ Timer {
+ running: parent.windowShown
+ repeat: false
+ interval: 1
+ onTriggered: parent.when = true
+ }
+
+ function init() {
+ spy.clear()
+ }
+
+ function test_permissionRequest() {
+ skip("Waiting for qtlocation being included in the bot")
+ compare(spy.count, 0)
+ webView.load(Qt.resolvedUrl("../common/geolocation.html"))
+ spy.wait()
+ compare(spy.count, 1)
+ }
+ }
+}
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html (0 => 101456)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html 2011-11-30 08:41:19 UTC (rev 101456)
@@ -0,0 +1,29 @@
+<head>
+<title>Geolocation Permission API Test</title>
+<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"/>
+<script>
+var watchId = 0;
+
+function successHandler(location) {
+ var message = document.getElementById("message"), html = [];
+ html.push("<img width='256' height='256' src='' />");
+ html.push("<p>Longitude: ", location.coords.longitude, "</p>");
+ html.push("<p>Latitude: ", location.coords.latitude, "</p>");
+ html.push("<p>Accuracy: ", location.coords.accuracy, " meters</p>");
+ message.innerHTML = html.join("");
+}
+
+function errorHandler(error) {
+ alert('Attempt to get location failed: ' + error.message);
+}
+
+<!-- One shot example -->
+navigator.geolocation.getCurrentPosition(successHandler, errorHandler);
+
+</script>
+</head>
+<body>
+<div id="message">Location unknown</div>
+</body>
+</html>
+
Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro (101455 => 101456)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro 2011-11-30 08:41:19 UTC (rev 101456)
@@ -25,6 +25,7 @@
WebView/tst_preferences.qml \
WebView/tst_loadHtml.qml \
WebView/tst_download.qml \
+ WebView/tst_geopermission.qml \
DesktopBehavior/tst_linkHovered.qml \
DesktopBehavior/tst_messaging.qml \
DesktopBehavior/tst_navigationRequested.qml \
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp (101455 => 101456)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp 2011-11-30 08:41:19 UTC (rev 101456)
@@ -25,6 +25,7 @@
#include "WKURLQt.h"
#include "qquickwebview_p.h"
#include "qquickwebview_p_p.h"
+#include "qwebpermissionrequest_p.h"
#include <WKAPICast.h>
#include <WKHitTestResult.h>
#include <WKOpenPanelParameters.h>
@@ -43,6 +44,7 @@
uiClient.setStatusText = setStatusText;
uiClient.runOpenPanel = runOpenPanel;
uiClient.mouseDidMoveOverElement = mouseDidMoveOverElement;
+ uiClient.decidePolicyForGeolocationPermissionRequest = policyForGeolocationPermissionRequest;
WKPageSetPageUIClient(pageRef, &uiClient);
}
@@ -80,6 +82,12 @@
emit m_webView->linkHovered(m_lastHoveredURL, m_lastHoveredTitle);
}
+void QtWebPageUIClient::permissionRequest(QWebPermissionRequest* request)
+{
+ request->setParent(m_webView);
+ emit m_webView->experimental()->permissionRequested(request);
+}
+
static QtWebPageUIClient* toQtWebPageUIClient(const void* clientInfo)
{
ASSERT(clientInfo);
@@ -139,3 +147,13 @@
const QString linkTitle = WKStringCopyQString(adoptWK(WKHitTestResultCopyLinkTitle(hitTestResult)).get());
toQtWebPageUIClient(clientInfo)->mouseDidMoveOverElement(absoluteLinkUrl, linkTitle);
}
+
+void QtWebPageUIClient::policyForGeolocationPermissionRequest(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef request, const void* clientInfo)
+{
+ if (!request)
+ return;
+
+ QWebPermissionRequest* req = QWebPermissionRequest::create(origin, request);
+ toQtWebPageUIClient(clientInfo)->permissionRequest(req);
+}
+
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h (101455 => 101456)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h 2011-11-30 08:41:19 UTC (rev 101456)
@@ -23,9 +23,13 @@
#include <QtCore/QString>
#include <QtCore/QUrl>
+#include <WKFrame.h>
+#include <WKGeolocationPermissionRequest.h>
#include <WKPage.h>
+#include <WKSecurityOrigin.h>
class QQuickWebView;
+class QWebPermissionRequest;
class QtWebPageUIClient {
public:
@@ -43,6 +47,7 @@
void setStatusText(const QString&);
void runOpenPanel(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType);
void mouseDidMoveOverElement(const QUrl& linkURL, const QString& linkTitle);
+ void permissionRequest(QWebPermissionRequest*);
// WKPageUIClient callbacks.
static void runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo);
@@ -51,6 +56,7 @@
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);
+ static void policyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKGeolocationPermissionRequestRef, const void*);
QQuickWebView* m_webView;
QUrl m_lastHoveredURL;
Modified: trunk/Source/qtwebkit-export.map (101455 => 101456)
--- trunk/Source/qtwebkit-export.map 2011-11-30 08:17:19 UTC (rev 101455)
+++ trunk/Source/qtwebkit-export.map 2011-11-30 08:41:19 UTC (rev 101456)
@@ -127,7 +127,11 @@
*QQuickWebPage;
non-virtual?thunk?to?QQuickWebPage*;
QQuickWebPage::*;
+ *QWebPermissionRequest;
+ non-virtual?thunk?to?QWebPermissionRequest*;
+ QWebPermissionRequest::*;
+
# WebKit 2 C API mangled in C++
WKStringCopyQString*;
WKStringCreateWithQString*;