[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 12:54:30 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 63ddb60a17c98d57fe755029fd86bcfb06235abd
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Sep 1 12:31:19 2010 +0000

    2010-09-01  Mahesh Kulkarni  <mahesh.kulkarni at nokia.com>
    
            Reviewed by Laszlo Gombos.
    
            [Qt] QWebPage::allowGeolocationRequest should be async API
            https://bugs.webkit.org/show_bug.cgi?id=41364
    
            Enable all geolocation delayed permission layout test for Qt port
    
            * platform/qt/Skipped:
    2010-09-01  Mahesh Kulkarni  <mahesh.kulkarni at nokia.com>
    
            Reviewed by Laszlo Gombos.
    
            [Qt] QWebPage::allowGeolocationRequest should be async API
            https://bugs.webkit.org/show_bug.cgi?id=41364
    
            Adding GeolocationPermissionClientQt.cpp/h to build script
    
            * WebCore.pro:
    2010-09-01  Mahesh Kulkarni  <mahesh.kulkarni at nokia.com>
    
            Reviewed by Laszlo Gombos.
    
            [Qt] QWebPage::allowGeolocationRequest should be async API
            https://bugs.webkit.org/show_bug.cgi?id=41364
    
            Provides a new async API for geolocation permission. Using
            Notification API approach from qtwebkit. GeolocationPermissionClientQt
            maintains list of pending requests from WebCore and intimates them
            when client either allowes/denies the request. Also implements
            ChromeClientQt::cancelGeolocationPermissionRequestForFrame.
    
            * Api/qwebpage.cpp:
            (QWebPage::setUserPermission):
            * Api/qwebpage.h:
            * WebCoreSupport/ChromeClientQt.cpp:
            (WebCore::ChromeClientQt::requestGeolocationPermissionForFrame):
            (WebCore::ChromeClientQt::cancelGeolocationPermissionRequestForFrame):
            * WebCoreSupport/ChromeClientQt.h:
            * WebCoreSupport/GeolocationPermissionClientQt.cpp: Added.
            (WebCore::GeolocationPermissionClientQt::geolocationPermissionClient):
            (WebCore::GeolocationPermissionClientQt::GeolocationPermissionClientQt):
            (WebCore::GeolocationPermissionClientQt::~GeolocationPermissionClientQt):
            (WebCore::GeolocationPermissionClientQt::requestGeolocationPermissionForFrame):
            (WebCore::GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame):
            (WebCore::GeolocationPermissionClientQt::setPermission):
            * WebCoreSupport/GeolocationPermissionClientQt.h: Added.
            * tests/qwebpage/tst_qwebpage.cpp:
            (JSTestPage::requestPermission):
            (tst_QWebPage::geolocationRequestJS):
    2010-09-01  Mahesh Kulkarni  <mahesh.kulkarni at nokia.com>
    
            Reviewed by Laszlo Gombos.
    
            [Qt] QWebPage::allowGeolocationRequest should be async API
            https://bugs.webkit.org/show_bug.cgi?id=41364
    
            Implements new async API for geolocation permission similar to
            Notification. WebPage maintains list of geolocation permission request
            QtWebkit and set's when LayoutTestController gets the access from test JS
    
            * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
            (WebCore::WebPage::WebPage):
            (WebCore::WebPage::resetSettings):
            (WebCore::WebPage::requestPermission):
            (WebCore::WebPage::cancelPermission):
            (WebCore::WebPage::permissionSet):
            (WebCore::DumpRenderTree::DumpRenderTree):
            (WebCore::DumpRenderTree::processLine):
            (WebCore::DumpRenderTree::geolocationPermissionSet):
            * DumpRenderTree/qt/DumpRenderTreeQt.h:
            * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
            (LayoutTestController::reset):
            (LayoutTestController::setGeolocationPermission):
            (LayoutTestController::setGeolocationPermissionCommon):
            * DumpRenderTree/qt/LayoutTestControllerQt.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66597 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 30d13c5..cc1473b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-09-01  Mahesh Kulkarni  <mahesh.kulkarni at nokia.com>
+
+        Reviewed by Laszlo Gombos.
+
+        [Qt] QWebPage::allowGeolocationRequest should be async API
+        https://bugs.webkit.org/show_bug.cgi?id=41364
+
+        Enable all geolocation delayed permission layout test for Qt port
+
+        * platform/qt/Skipped:
+
 2010-09-01  Pavel Podivilov  <podivilov at chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index 030bcbe..fe69f06 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -5435,13 +5435,6 @@ svg/custom/getscreenctm-in-mixed-content2.xhtml
 fast/events/keydown-numpad-keys.html
 fast/events/special-key-events-in-input-text.html
 
-# [Qt] DumpRenderTree lacks functionality for new Geolocation delayed permission tests
-# https://bugs.webkit.org/show_bug.cgi?id=41364
-fast/dom/Geolocation/delayed-permission-allowed.html
-fast/dom/Geolocation/delayed-permission-denied.html
-fast/dom/Geolocation/delayed-permission-allowed-for-multiple-requests.html
-fast/dom/Geolocation/delayed-permission-denied-for-multiple-requests.html
-
 # Still working out flakiness issues with the perf tests.
 # https://bugs.webkit.org/show_bug.cgi?id=44199
 perf/
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 211b7ba..6ad9f9a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,14 @@
+2010-09-01  Mahesh Kulkarni  <mahesh.kulkarni at nokia.com>
+
+        Reviewed by Laszlo Gombos.
+
+        [Qt] QWebPage::allowGeolocationRequest should be async API
+        https://bugs.webkit.org/show_bug.cgi?id=41364
+
+        Adding GeolocationPermissionClientQt.cpp/h to build script
+
+        * WebCore.pro:
+
 2010-09-01  Andreas Kling  <andreas.kling at nokia.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index fa45f2a..3f23cdd 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -2219,6 +2219,7 @@ HEADERS += \
     $$PWD/../WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h \
     $$PWD/../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h \
     $$PWD/../WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h \
+    $$PWD/../WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h \
     $$PWD/../WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h \
     $$PWD/../WebKit/qt/WebCoreSupport/PageClientQt.h \
     $$PWD/../WebKit/qt/WebCoreSupport/QtPlatformPlugin.h \
@@ -2311,6 +2312,7 @@ SOURCES += \
     ../WebKit/qt/WebCoreSupport/EditCommandQt.cpp \
     ../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp \
     ../WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.cpp \
+    ../WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp \
     ../WebKit/qt/WebCoreSupport/InspectorClientQt.cpp \
     ../WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp \
     ../WebKit/qt/WebCoreSupport/PageClientQt.cpp \
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index 544cbdd..ec415bb 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -81,6 +81,7 @@
 #include "Cache.h"
 #include "runtime/InitializeThreading.h"
 #include "PageGroup.h"
+#include "GeolocationPermissionClientQt.h"
 #include "NotificationPresenterClientQt.h"
 #include "PageClientQt.h"
 #include "WorkerThread.h"
@@ -2082,30 +2083,6 @@ bool QWebPage::shouldInterruptJavaScript()
 #endif
 }
 
-/*!
-    \fn bool QWebPage::allowGeolocationRequest()
-    \since 4.7
-
-    This function is called whenever a JavaScript program running inside \a frame tries to access user location through navigator.geolocation.
-
-    If the user wants to allow access to location then it should return true; otherwise false.
-
-    The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons.
-
-    \warning Because of binary compatibility constraints, this function is not virtual. If you want to
-    provide your own implementation in a QWebPage subclass, reimplement the allowGeolocationRequest()
-    slot in your subclass instead. QtWebKit will dynamically detect the slot and call it.
-*/
-bool QWebPage::allowGeolocationRequest(QWebFrame *frame)
-{
-#ifdef QT_NO_MESSAGEBOX
-    return false;
-#else
-    QWidget* parent = (d->client) ? d->client->ownerWidget() : 0;
-    return QMessageBox::Yes == QMessageBox::information(parent, tr("Location Request by- %1").arg(frame->url().host()), tr("The page wants to access your location information. Do you want to allow the request?"), QMessageBox::Yes, QMessageBox::No);
-#endif
-}
-
 void QWebPage::setUserPermission(QWebFrame* frame, PermissionDomain domain, PermissionPolicy policy)
 {
     switch (domain) {
@@ -2115,6 +2092,12 @@ void QWebPage::setUserPermission(QWebFrame* frame, PermissionDomain domain, Perm
             NotificationPresenterClientQt::notificationPresenter()->allowNotificationForFrame(frame);
 #endif
         break;
+    case GeolocationPermissionDomain:
+#if ENABLE(GEOLOCATION)
+        GeolocationPermissionClientQt::geolocationPermissionClient()->setPermission(frame, policy);
+#endif
+        break;
+
     default:
         break;
     }
diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h
index 14f3b8b..dda4a6a 100644
--- a/WebKit/qt/Api/qwebpage.h
+++ b/WebKit/qt/Api/qwebpage.h
@@ -57,6 +57,7 @@ namespace WebCore {
     class InspectorClientQt;
     class InspectorFrontendClientQt;
     class NotificationPresenterClientQt;
+    class GeolocationPermissionClientQt;
     class ResourceHandle;
     class HitTestResult;
     class QNetworkReplyHandler;
@@ -202,7 +203,8 @@ public:
     };
 
     enum PermissionDomain {
-        NotificationsPermissionDomain
+        NotificationsPermissionDomain,
+        GeolocationPermissionDomain
     };
 
     class ViewportHints {
@@ -351,7 +353,6 @@ public:
 
 public Q_SLOTS:
     bool shouldInterruptJavaScript();
-    bool allowGeolocationRequest(QWebFrame *frame);
 
 Q_SIGNALS:
     void loadStarted();
@@ -424,6 +425,7 @@ private:
     friend class WebCore::InspectorClientQt;
     friend class WebCore::InspectorFrontendClientQt;
     friend class WebCore::NotificationPresenterClientQt;
+    friend class WebCore::GeolocationPermissionClientQt;
     friend class WebCore::ResourceHandle;
     friend class WebCore::QNetworkReplyHandler;
     friend class DumpRenderTreeSupportQt;
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 284c29b..996435b 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,35 @@
+2010-09-01  Mahesh Kulkarni  <mahesh.kulkarni at nokia.com>
+
+        Reviewed by Laszlo Gombos.
+
+        [Qt] QWebPage::allowGeolocationRequest should be async API
+        https://bugs.webkit.org/show_bug.cgi?id=41364
+
+        Provides a new async API for geolocation permission. Using
+        Notification API approach from qtwebkit. GeolocationPermissionClientQt 
+        maintains list of pending requests from WebCore and intimates them
+        when client either allowes/denies the request. Also implements
+        ChromeClientQt::cancelGeolocationPermissionRequestForFrame.  
+
+        * Api/qwebpage.cpp:
+        (QWebPage::setUserPermission):
+        * Api/qwebpage.h:
+        * WebCoreSupport/ChromeClientQt.cpp:
+        (WebCore::ChromeClientQt::requestGeolocationPermissionForFrame):
+        (WebCore::ChromeClientQt::cancelGeolocationPermissionRequestForFrame):
+        * WebCoreSupport/ChromeClientQt.h:
+        * WebCoreSupport/GeolocationPermissionClientQt.cpp: Added.
+        (WebCore::GeolocationPermissionClientQt::geolocationPermissionClient):
+        (WebCore::GeolocationPermissionClientQt::GeolocationPermissionClientQt):
+        (WebCore::GeolocationPermissionClientQt::~GeolocationPermissionClientQt):
+        (WebCore::GeolocationPermissionClientQt::requestGeolocationPermissionForFrame):
+        (WebCore::GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame):
+        (WebCore::GeolocationPermissionClientQt::setPermission):
+        * WebCoreSupport/GeolocationPermissionClientQt.h: Added.
+        * tests/qwebpage/tst_qwebpage.cpp:
+        (JSTestPage::requestPermission):
+        (tst_QWebPage::geolocationRequestJS):
+
 2010-08-31  Dave Hyatt  <hyatt at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index e239d51..8b01d4d 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -41,6 +41,7 @@
 #if USE(ACCELERATED_COMPOSITING)
 #include "GraphicsLayerQt.h"
 #endif
+#include "GeolocationPermissionClientQt.h"
 #include "HitTestResult.h"
 #include "Icon.h"
 #include "NotImplemented.h"
@@ -567,10 +568,18 @@ void ChromeClientQt::setCursor(const Cursor& cursor)
 
 void ChromeClientQt::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
 {
-    bool allow = false;
+#if ENABLE(GEOLOCATION)
     QWebFrame* webFrame = QWebFramePrivate::kit(frame);
-    QMetaObject::invokeMethod(m_webPage, "allowGeolocationRequest", Qt::DirectConnection, Q_RETURN_ARG(bool, allow), Q_ARG(QWebFrame*, webFrame));
-    geolocation->setIsAllowed(allow);
+    GeolocationPermissionClientQt::geolocationPermissionClient()->requestGeolocationPermissionForFrame(webFrame, geolocation);
+#endif
+}
+
+void ChromeClientQt::cancelGeolocationPermissionRequestForFrame(Frame* frame, Geolocation* geolocation)
+{
+#if ENABLE(GEOLOCATION)
+    QWebFrame* webFrame = QWebFramePrivate::kit(frame);
+    GeolocationPermissionClientQt::geolocationPermissionClient()->cancelGeolocationPermissionRequestForFrame(webFrame, geolocation);
+#endif
 }
 
 #if USE(ACCELERATED_COMPOSITING)
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
index 55edc50..d18f993 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.h
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -168,7 +168,7 @@ namespace WebCore {
         virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const {}
 
         virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
-        virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) { }
+        virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*);
 
         virtual bool selectItemWritingDirectionIsNatural();
         virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const;
diff --git a/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp b/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp
new file mode 100644
index 0000000..5fb9ab7
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GeolocationPermissionClientQt.h"
+
+#include "Geolocation.h"
+
+#include "qwebframe.h"
+#include "qwebkitglobal.h"
+#include "qwebpage.h"
+
+namespace WebCore {
+
+#if ENABLE(GEOLOCATION)
+
+static GeolocationPermissionClientQt* s_geolocationPermission;
+
+GeolocationPermissionClientQt* GeolocationPermissionClientQt::geolocationPermissionClient()
+{
+    if (s_geolocationPermission)
+        return s_geolocationPermission;
+
+    s_geolocationPermission = new GeolocationPermissionClientQt();
+    return s_geolocationPermission;
+}
+
+GeolocationPermissionClientQt::GeolocationPermissionClientQt()
+{
+}
+
+GeolocationPermissionClientQt::~GeolocationPermissionClientQt()
+{
+}
+
+void GeolocationPermissionClientQt::requestGeolocationPermissionForFrame(QWebFrame* webFrame, Geolocation* listener)
+{
+    m_pendingPermissionRequests.insert(webFrame, listener);
+
+    QWebPage* page = webFrame->page();
+    emit page->requestPermissionFromUser(webFrame, QWebPage::GeolocationPermissionDomain);
+}
+
+
+void GeolocationPermissionClientQt::cancelGeolocationPermissionRequestForFrame(QWebFrame* webFrame, Geolocation* listener)
+{
+    m_pendingPermissionRequests.remove(webFrame);
+
+    QWebPage* page = webFrame->page();
+    emit page->cancelRequestsForPermission(webFrame, QWebPage::GeolocationPermissionDomain);
+}
+
+void GeolocationPermissionClientQt::setPermission(QWebFrame* webFrame, QWebPage::PermissionPolicy permission)
+{  
+    if (!m_pendingPermissionRequests.contains(webFrame)) 
+        return;
+
+    Geolocation* listener = m_pendingPermissionRequests.value(webFrame);
+
+    if (permission == QWebPage::PermissionGranted)
+        listener->setIsAllowed(true);
+    else if (permission == QWebPage::PermissionDenied)
+        listener->setIsAllowed(false);
+    else
+        return;
+
+    m_pendingPermissionRequests.remove(webFrame);
+}
+
+#endif // ENABLE(GEOLOCATION)
+}
diff --git a/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h b/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h
new file mode 100644
index 0000000..abe9c76
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GeolocationPermissionClientQt_h
+#define GeolocationPermissionClientQt_h
+
+#include "Geolocation.h"
+#include "qwebpage.h"
+
+#include <QHash>
+
+class QWebFrame;
+class QWebPage;
+
+namespace WebCore {
+
+class GeolocationPermissionClientQt {
+public:
+    GeolocationPermissionClientQt();
+    ~GeolocationPermissionClientQt();
+
+    void requestGeolocationPermissionForFrame(QWebFrame*, Geolocation*);
+    void cancelGeolocationPermissionRequestForFrame(QWebFrame*, Geolocation*);
+    void setPermission(QWebFrame*, QWebPage::PermissionPolicy);
+
+    static GeolocationPermissionClientQt* geolocationPermissionClient();
+private:
+    QHash<QWebFrame*, Geolocation*> m_pendingPermissionRequests;
+};
+
+}
+
+#endif
diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index cc436ec..9a6c35f 100644
--- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -217,9 +217,12 @@ public slots:
     bool shouldInterruptJavaScript() {
         return true;
     }
-    bool allowGeolocationRequest(QWebFrame *frame) 
+    void requestPermission(QWebFrame* frame, QWebPage::PermissionDomain domain)
     {
-        return m_allowGeolocation;
+        if (m_allowGeolocation)
+            setUserPermission(frame, domain, PermissionGranted);
+        else 
+            setUserPermission(frame, domain, PermissionDenied);
     }
 
 public:
@@ -244,6 +247,9 @@ void tst_QWebPage::infiniteLoopJS()
 void tst_QWebPage::geolocationRequestJS()
 {
     JSTestPage* newPage = new JSTestPage(m_view);
+    connect(newPage, SIGNAL(requestPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), 
+            newPage, SLOT(requestPermission(QWebFrame*, QWebPage::PermissionDomain)));
+
     newPage->setGeolocationPermission(false);
     m_view->setPage(newPage);
     m_view->setHtml(QString("<html><body>test</body></html>"), QUrl());
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 0981782..2a0ee8c 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,30 @@
+2010-09-01  Mahesh Kulkarni  <mahesh.kulkarni at nokia.com>
+
+        Reviewed by Laszlo Gombos.
+
+        [Qt] QWebPage::allowGeolocationRequest should be async API
+        https://bugs.webkit.org/show_bug.cgi?id=41364
+
+        Implements new async API for geolocation permission similar to
+        Notification. WebPage maintains list of geolocation permission request
+        QtWebkit and set's when LayoutTestController gets the access from test JS
+
+        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
+        (WebCore::WebPage::WebPage):
+        (WebCore::WebPage::resetSettings):
+        (WebCore::WebPage::requestPermission):
+        (WebCore::WebPage::cancelPermission):
+        (WebCore::WebPage::permissionSet):
+        (WebCore::DumpRenderTree::DumpRenderTree):
+        (WebCore::DumpRenderTree::processLine):
+        (WebCore::DumpRenderTree::geolocationPermissionSet):
+        * DumpRenderTree/qt/DumpRenderTreeQt.h:
+        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
+        (LayoutTestController::reset):
+        (LayoutTestController::setGeolocationPermission):
+        (LayoutTestController::setGeolocationPermissionCommon):
+        * DumpRenderTree/qt/LayoutTestControllerQt.h:
+
 2010-09-01  Andras Becsi  <abecsi at webkit.org>
 
         Reviewed by Antti Koivisto.
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
index 632e357..00ccdb5 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
@@ -159,7 +159,7 @@ WebPage::WebPage(QObject* parent, DumpRenderTree* drt)
 
     connect(this, SIGNAL(requestPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(requestPermission(QWebFrame*, QWebPage::PermissionDomain)));
     connect(this, SIGNAL(checkPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&)), this, SLOT(checkPermission(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&)));
-    connect(this, SIGNAL(cancelRequestsForPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(cancelRequestsForPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)));
+    connect(this, SIGNAL(cancelRequestsForPermission(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(cancelPermission(QWebFrame*, QWebPage::PermissionDomain)));
 }
 
 WebPage::~WebPage()
@@ -202,6 +202,8 @@ void WebPage::resetSettings()
 
     QWebSettings::setMaximumPagesInCache(0); // reset to default
     settings()->setUserStyleSheetUrl(QUrl()); // reset to default
+
+    m_pendingGeolocationRequests.clear();
 }
 
 QWebPage *WebPage::createWindow(QWebPage::WebWindowType)
@@ -224,6 +226,15 @@ void WebPage::requestPermission(QWebFrame* frame, QWebPage::PermissionDomain dom
         if (!m_drt->layoutTestController()->ignoreReqestForPermission())
             setUserPermission(frame, domain, PermissionGranted);
         break;
+    case GeolocationPermissionDomain:
+        if (m_drt->layoutTestController()->isGeolocationPermissionSet())
+            if (m_drt->layoutTestController()->geolocationPermission())
+                setUserPermission(frame, domain, PermissionGranted);
+            else
+                setUserPermission(frame, domain, PermissionDenied);
+        else
+            m_pendingGeolocationRequests.append(frame);
+        break;
     default:
         break;
     }
@@ -243,8 +254,35 @@ void WebPage::checkPermission(QWebFrame* frame, QWebPage::PermissionDomain domai
     }
 }
 
-void WebPage::cancelRequestsForPermission(QWebFrame*, QWebPage::PermissionDomain)
+void WebPage::cancelPermission(QWebFrame* frame, QWebPage::PermissionDomain domain)
 {
+    switch (domain) {
+    case GeolocationPermissionDomain:
+        m_pendingGeolocationRequests.removeOne(frame);
+        break;
+    default:
+        break;
+    }
+}
+
+void WebPage::permissionSet(QWebPage::PermissionDomain domain)
+{
+    switch (domain) {
+    case GeolocationPermissionDomain:
+        {
+        Q_ASSERT(m_drt->layoutTestController()->isGeolocationPermissionSet());
+        foreach (QWebFrame* frame, m_pendingGeolocationRequests)
+            if (m_drt->layoutTestController()->geolocationPermission())
+                setUserPermission(frame, domain, PermissionGranted);
+            else
+                setUserPermission(frame, domain, PermissionDenied);
+
+        m_pendingGeolocationRequests.clear();
+        break;
+        }
+    default:
+        break;
+    }
 }
 
 static QString urlSuitableForTestResult(const QString& url)
@@ -367,11 +405,6 @@ QObject* WebPage::createPlugin(const QString& classId, const QUrl& url, const QS
 #endif
 }
 
-bool WebPage::allowGeolocationRequest(QWebFrame *)
-{
-    return m_drt->layoutTestController()->geolocationPermission();
-}
-
 void WebPage::setViewGeometry(const QRect& rect)
 {
     if (WebViewGraphicsBased* v = qobject_cast<WebViewGraphicsBased*>(view()))
@@ -431,6 +464,9 @@ DumpRenderTree::DumpRenderTree()
     connect(m_controller, SIGNAL(showPage()), this, SLOT(showPage()));
     connect(m_controller, SIGNAL(hidePage()), this, SLOT(hidePage()));
 
+    // async geolocation permission set by controller
+    connect(m_controller, SIGNAL(geolocationPermissionSet()), this, SLOT(geolocationPermissionSet()));
+
     connect(m_controller, SIGNAL(done()), this, SLOT(dump()));
     m_eventSender = new EventSender(m_page);
     m_textInputController = new TextInputController(m_page);
@@ -673,7 +709,6 @@ void DumpRenderTree::processLine(const QString &input)
                 emit ready();
                 return;
             }
-
         }
 
         open(QUrl::fromLocalFile(fi.absoluteFilePath()));
@@ -1026,6 +1061,11 @@ int DumpRenderTree::windowCount() const
     return windows.count() + 1;
 }
 
+void DumpRenderTree::geolocationPermissionSet() 
+{
+    m_page->permissionSet(QWebPage::GeolocationPermissionDomain);
+}
+
 void DumpRenderTree::switchFocus(bool focused)
 {
     QFocusEvent event((focused) ? QEvent::FocusIn : QEvent::FocusOut, Qt::ActiveWindowFocusReason);
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h
index 54aa484..3d34443 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h
@@ -127,6 +127,7 @@ private Q_SLOTS:
     void hidePage();
     void dryRunPrint(QWebFrame*);
     void loadNextTestInStandAloneMode();
+    void geolocationPermissionSet();
 
 private:
     void setStandAloneMode(bool flag) { m_standAloneMode = flag; }
@@ -191,12 +192,13 @@ public:
 
     QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&);
 
+    void permissionSet(QWebPage::PermissionDomain domain);
+
 public slots:
     bool shouldInterruptJavaScript() { return false; }
-    bool allowGeolocationRequest(QWebFrame *frame);
     void requestPermission(QWebFrame* frame, QWebPage::PermissionDomain domain);
     void checkPermission(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy);
-    void cancelRequestsForPermission(QWebFrame* frame, QWebPage::PermissionDomain domain);
+    void cancelPermission(QWebFrame* frame, QWebPage::PermissionDomain domain);
 
 protected:
     bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, NavigationType type);
@@ -207,6 +209,7 @@ private slots:
 
 private:
     QWebInspector* m_webInspector;
+    QList<QWebFrame*> m_pendingGeolocationRequests;
     DumpRenderTree *m_drt;
 };
 
diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
index 74baf37..b783141 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
@@ -68,6 +68,8 @@ void LayoutTestController::reset()
     m_userStyleSheetEnabled = false;
     m_desktopNotificationAllowedOrigins.clear();
     m_ignoreDesktopNotification = false;
+    m_isGeolocationPermissionSet = false;
+    m_geolocationPermission = false;
 
     DumpRenderTreeSupportQt::dumpEditingCallbacks(false);
     DumpRenderTreeSupportQt::dumpFrameLoader(false);
@@ -715,6 +717,12 @@ void LayoutTestController::setMockDeviceOrientation(bool canProvideAlpha, double
 
 void LayoutTestController::setGeolocationPermission(bool allow)
 {
+    setGeolocationPermissionCommon(allow);
+    emit geolocationPermissionSet();
+}
+
+void LayoutTestController::setGeolocationPermissionCommon(bool allow)
+{
      m_isGeolocationPermissionSet = true;
      m_geolocationPermission = allow;
 }
diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
index 207e093..7e58f44 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
@@ -85,6 +85,7 @@ signals:
 
     void showPage();
     void hidePage();
+    void geolocationPermissionSet();
 
 public slots:
     void maybeDump(bool ok);
@@ -239,6 +240,9 @@ private slots:
     void processWork();
 
 private:
+    void setGeolocationPermissionCommon(bool allow);
+
+private:
     bool m_hasDumped;
     bool m_textDump;
     bool m_dumpBackForwardList;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list