[Qt] Implement client based geolocation for qtport
authorossy@webkit.org <ossy@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Feb 2011 21:40:40 +0000 (21:40 +0000)
committerossy@webkit.org <ossy@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Feb 2011 21:40:40 +0000 (21:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=42629

Patch by Mahesh Kulkarni <mahesh.kulkarni@nokia.com> on 2011-02-18
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Implements client based geolocation for qtwebkit. Removed old code related to non-client based geolocation

No tests as yet. This will be raised as different bug as new mock client implementation need to be done.

* WebCore.pro:
* features.pri:
* platform/qt/GeolocationServiceQt.cpp: Removed.
* platform/qt/GeolocationServiceQt.h: Removed.

Source/WebKit/qt:

Implements client based geolocation for qtwebkit.
New client based geolocation contains permission API's as well,
so removed the implementation from ChromeClientQt.cpp.

* Api/qwebpage.cpp:
(QWebPagePrivate::QWebPagePrivate):
* WebCoreSupport/ChromeClientQt.cpp:
* WebCoreSupport/ChromeClientQt.h:
(WebCore::ChromeClientQt::requestGeolocationPermissionForFrame):
(WebCore::ChromeClientQt::cancelGeolocationPermissionRequestForFrame):
* WebCoreSupport/GeolocationClientQt.cpp: Added.
(WebCore::GeolocationClientQt::GeolocationClientQt):
(WebCore::GeolocationClientQt::~GeolocationClientQt):
(WebCore::GeolocationClientQt::geolocationDestroyed):
(WebCore::GeolocationClientQt::positionUpdated):
(WebCore::GeolocationClientQt::startUpdating):
(WebCore::GeolocationClientQt::stopUpdating):
(WebCore::GeolocationClientQt::setEnableHighAccuracy):
(WebCore::GeolocationClientQt::requestPermission):
(WebCore::GeolocationClientQt::cancelPermissionRequest):
* WebCoreSupport/GeolocationClientQt.h: Added.
(WebCore::GeolocationClientQt::lastPosition):

LayoutTests:

Disable Geolocation layout test case until client-based mock layout controller is implemented.

* platform/qt/Skipped:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79028 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/qt/Skipped
Source/WebCore/ChangeLog
Source/WebCore/WebCore.pro
Source/WebCore/features.pri
Source/WebCore/page/Geolocation.h
Source/WebCore/platform/GeolocationService.h
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.cpp [moved from Source/WebCore/platform/qt/GeolocationServiceQt.cpp with 50% similarity]
Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.h [moved from Source/WebCore/platform/qt/GeolocationServiceQt.h with 75% similarity]

index dd74258..012887b 100644 (file)
@@ -1,3 +1,14 @@
+2011-02-18  Mahesh Kulkarni  <mahesh.kulkarni@nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Implement client based geolocation for qtport
+        https://bugs.webkit.org/show_bug.cgi?id=42629
+
+        Disable Geolocation layout test case until client-based mock layout controller is implemented.
+
+        * platform/qt/Skipped:
+
 2011-02-18  Mihai Parparita  <mihaip@chromium.org>
 
         Unreviewed mac baseline update. Update some lingering failures after
 2011-02-18  Mihai Parparita  <mihaip@chromium.org>
 
         Unreviewed mac baseline update. Update some lingering failures after
index c984b1f..33089a6 100644 (file)
@@ -4742,3 +4742,7 @@ inspector/timeline/timeline-script-tag-1.html
 # [Qt]REGRESSION(r78846): editing/selection/mixed-editability-10.html
 # https://bugs.webkit.org/show_bug.cgi?id=54725
 editing/selection/mixed-editability-10.html
 # [Qt]REGRESSION(r78846): editing/selection/mixed-editability-10.html
 # https://bugs.webkit.org/show_bug.cgi?id=54725
 editing/selection/mixed-editability-10.html
+
+# ----- FIXME: QtWebkit supports client based and LayoutTest for the same is yet to be implemented. Tracked in #54334 ------ 
+fast/dom/Geolocation
+fast/dom/Window/window-properties-geolocation.html
index e324038..18d258f 100644 (file)
@@ -1,3 +1,19 @@
+2011-02-18  Mahesh Kulkarni  <mahesh.kulkarni@nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Implement client based geolocation for qtport
+        https://bugs.webkit.org/show_bug.cgi?id=42629
+
+        Implements client based geolocation for qtwebkit. Removed old code related to non-client based geolocation
+
+        No tests as yet. This will be raised as different bug as new mock client implementation need to be done.
+
+        * WebCore.pro:
+        * features.pri:
+        * platform/qt/GeolocationServiceQt.cpp: Removed.
+        * platform/qt/GeolocationServiceQt.h: Removed.
+
 2011-02-18  Yael Aharon  <yael.aharon@nokia.com>
 
         Reviewed by Dave Hyatt.
 2011-02-18  Yael Aharon  <yael.aharon@nokia.com>
 
         Reviewed by Dave Hyatt.
index bd0ed8f..69d674c 100644 (file)
@@ -3356,12 +3356,11 @@ contains(DEFINES, ENABLE_QT_BEARER=1) {
 }
 
 contains(DEFINES, ENABLE_GEOLOCATION=1) {
 }
 
 contains(DEFINES, ENABLE_GEOLOCATION=1) {
-    DEFINES += WTF_USE_PREEMPT_GEOLOCATION_PERMISSION
-    HEADERS += \
-        platform/qt/GeolocationServiceQt.h
-    SOURCES += \
-        platform/qt/GeolocationServiceQt.cpp
-
+     HEADERS += \
+        $$PWD/../WebKit/qt/WebCoreSupport/GeolocationClientQt.h
+     SOURCES += \
+        $$PWD/../WebKit/qt/WebCoreSupport/GeolocationClientQt.cpp
     CONFIG += mobility
     MOBILITY += location
 
     CONFIG += mobility
     MOBILITY += location
 
index b3f0e2d..4288d0f 100644 (file)
@@ -119,6 +119,7 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
 !CONFIG(QTDIR_build):!contains(DEFINES, ENABLE_GEOLOCATION=.) {
     contains(MOBILITY_CONFIG, location) {
        DEFINES += ENABLE_GEOLOCATION=1
 !CONFIG(QTDIR_build):!contains(DEFINES, ENABLE_GEOLOCATION=.) {
     contains(MOBILITY_CONFIG, location) {
        DEFINES += ENABLE_GEOLOCATION=1
+       DEFINES += ENABLE_CLIENT_BASED_GEOLOCATION=1
     }
 }
 
     }
 }
 
index d53c827..7c06ae4 100644 (file)
@@ -215,3 +215,4 @@ private:
 } // namespace WebCore
 
 #endif // Geolocation_h
 } // namespace WebCore
 
 #endif // Geolocation_h
+
index 9211f8d..1045bb3 100644 (file)
@@ -78,3 +78,4 @@ private:
 } // namespace WebCore
 
 #endif // GeolocationService_h
 } // namespace WebCore
 
 #endif // GeolocationService_h
+
index 075756d..30b2311 100644 (file)
@@ -62,6 +62,7 @@
 #include "FrameLoaderClientQt.h"
 #include "FrameTree.h"
 #include "FrameView.h"
 #include "FrameLoaderClientQt.h"
 #include "FrameTree.h"
 #include "FrameView.h"
+#include "GeolocationClientQt.h"
 #include "GeolocationPermissionClientQt.h"
 #include "HTMLFormElement.h"
 #include "HTMLFrameOwnerElement.h"
 #include "GeolocationPermissionClientQt.h"
 #include "HTMLFormElement.h"
 #include "HTMLFrameOwnerElement.h"
@@ -324,6 +325,9 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
     pageClients.deviceOrientationClient = new DeviceOrientationClientQt(q);
     pageClients.deviceMotionClient = new DeviceMotionClientQt(q);
 #endif
     pageClients.deviceOrientationClient = new DeviceOrientationClientQt(q);
     pageClients.deviceMotionClient = new DeviceMotionClientQt(q);
 #endif
+#if ENABLE(GEOLOCATION)
+    pageClients.geolocationClient = new GeolocationClientQt(q);
+#endif
     page = new Page(pageClients);
 
     settings = new QWebSettings(page->settings());
     page = new Page(pageClients);
 
     settings = new QWebSettings(page->settings());
index 733c4f2..74c906f 100644 (file)
@@ -1,3 +1,33 @@
+2011-02-18  Mahesh Kulkarni  <mahesh.kulkarni@nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Implement client based geolocation for qtport
+        https://bugs.webkit.org/show_bug.cgi?id=42629
+
+        Implements client based geolocation for qtwebkit.
+        New client based geolocation contains permission API's as well,
+        so removed the implementation from ChromeClientQt.cpp. 
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::QWebPagePrivate):
+        * WebCoreSupport/ChromeClientQt.cpp:
+        * WebCoreSupport/ChromeClientQt.h:
+        (WebCore::ChromeClientQt::requestGeolocationPermissionForFrame):
+        (WebCore::ChromeClientQt::cancelGeolocationPermissionRequestForFrame):
+        * WebCoreSupport/GeolocationClientQt.cpp: Added.
+        (WebCore::GeolocationClientQt::GeolocationClientQt):
+        (WebCore::GeolocationClientQt::~GeolocationClientQt):
+        (WebCore::GeolocationClientQt::geolocationDestroyed):
+        (WebCore::GeolocationClientQt::positionUpdated):
+        (WebCore::GeolocationClientQt::startUpdating):
+        (WebCore::GeolocationClientQt::stopUpdating):
+        (WebCore::GeolocationClientQt::setEnableHighAccuracy):
+        (WebCore::GeolocationClientQt::requestPermission):
+        (WebCore::GeolocationClientQt::cancelPermissionRequest):
+        * WebCoreSupport/GeolocationClientQt.h: Added.
+        (WebCore::GeolocationClientQt::lastPosition):
+
 2011-02-10  Luiz Agostini  <luiz.agostini@openbossa.org>
 
         Reviewed by Adam Roben.
 2011-02-10  Luiz Agostini  <luiz.agostini@openbossa.org>
 
         Reviewed by Adam Roben.
index b7a0350..fb9b96c 100644 (file)
@@ -42,7 +42,6 @@
 #if USE(ACCELERATED_COMPOSITING)
 #include "GraphicsLayer.h"
 #endif
 #if USE(ACCELERATED_COMPOSITING)
 #include "GraphicsLayer.h"
 #endif
-#include "GeolocationPermissionClientQt.h"
 #include "HitTestResult.h"
 #include "Icon.h"
 #include "NavigationAction.h"
 #include "HitTestResult.h"
 #include "Icon.h"
 #include "NavigationAction.h"
@@ -604,21 +603,6 @@ void ChromeClientQt::setCursor(const Cursor& cursor)
 #endif
 }
 
 #endif
 }
 
-void ChromeClientQt::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
-{
-#if ENABLE(GEOLOCATION)
-    QWebFrame* webFrame = QWebFramePrivate::kit(frame);
-    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)
 void ChromeClientQt::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
 
 #if USE(ACCELERATED_COMPOSITING)
 void ChromeClientQt::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
index 684ece8..f1b377c 100644 (file)
@@ -181,10 +181,10 @@ namespace WebCore {
 
         virtual void setCursor(const Cursor&);
 
 
         virtual void setCursor(const Cursor&);
 
-        virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const {}
+        virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const { }
 
 
-        virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
-        virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*);
+        virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) { }
+        virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) { }
 
         virtual bool selectItemWritingDirectionIsNatural();
         virtual bool selectItemAlignmentFollowsMenuWritingDirection();
 
         virtual bool selectItemWritingDirectionIsNatural();
         virtual bool selectItemAlignmentFollowsMenuWritingDirection();
  */
 
 #include "config.h"
  */
 
 #include "config.h"
-#include "GeolocationServiceQt.h"
+#include "GeolocationClientQt.h"
 
 #include "Geolocation.h"
 
 #include "Geolocation.h"
-#include "Geoposition.h"
-#include "PositionError.h"
-#include "PositionOptions.h"
+#include "GeolocationController.h"
+#include "GeolocationError.h"
+#include "GeolocationPermissionClientQt.h"
+#include "GeolocationPosition.h"
+#include "Page.h"
+#include "qwebframe.h"
+#include "qwebframe_p.h"
+#include "qwebpage.h"
+#include "qwebpage_p.h"
 
 using namespace QtMobility;
 
 namespace WebCore {
 
 
 using namespace QtMobility;
 
 namespace WebCore {
 
-GeolocationService::FactoryFunction* GeolocationService::s_factoryFunction = &GeolocationServiceQt::create;
+static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocation service";
 
 
-GeolocationService* GeolocationServiceQt::create(GeolocationServiceClient* client)
+GeolocationClientQt::GeolocationClientQt(QWebPage* page)
+    : m_page(page)
+    , m_lastPosition(0)
+    , m_location(0)
 {
 {
-    return new GeolocationServiceQt(client);
 }
 
 }
 
-GeolocationServiceQt::GeolocationServiceQt(GeolocationServiceClient* client)
-    : GeolocationService(client)
-    , m_lastPosition(0)
-    , m_lastError(0)
+GeolocationClientQt::~GeolocationClientQt()
 {
 {
-    m_location = QGeoPositionInfoSource::createDefaultSource(this);
-
-    if (m_location)
-        connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
+    delete m_location;
 }
 
 }
 
-GeolocationServiceQt::~GeolocationServiceQt()
+void GeolocationClientQt::geolocationDestroyed()
 {
 {
-    delete m_location;
+    delete this;
 }
 
 }
 
-void GeolocationServiceQt::positionUpdated(const QGeoPositionInfo &geoPosition)
+void GeolocationClientQt::positionUpdated(const QGeoPositionInfo &geoPosition)
 {
     if (!geoPosition.isValid())
 {
     if (!geoPosition.isValid())
-        errorOccurred();
+        return;
 
     QGeoCoordinate coord = geoPosition.coordinate();
     double latitude = coord.latitude();
 
     QGeoCoordinate coord = geoPosition.coordinate();
     double latitude = coord.latitude();
@@ -80,36 +82,61 @@ void GeolocationServiceQt::positionUpdated(const QGeoPositionInfo &geoPosition)
     bool providesSpeed = geoPosition.hasAttribute(QGeoPositionInfo::GroundSpeed);
     double speed = geoPosition.attribute(QGeoPositionInfo::GroundSpeed);
 
     bool providesSpeed = geoPosition.hasAttribute(QGeoPositionInfo::GroundSpeed);
     double speed = geoPosition.attribute(QGeoPositionInfo::GroundSpeed);
 
-    RefPtr<Coordinates> coordinates = Coordinates::create(latitude, longitude, providesAltitude, altitude,
-                                                          accuracy, providesAltitudeAccuracy, altitudeAccuracy,
-                                                          providesHeading, heading, providesSpeed, speed);
-
 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
-    m_lastPosition = Geoposition::create(coordinates.release(), geoPosition.timestamp().toMSecsSinceEpoch());
+    double timeStampInSeconds = geoPosition.timestamp().toMSecsSinceEpoch() / 1000;
 #else
 #else
-    QDateTime timestamp = geoPosition.timestamp();
-    m_lastPosition = Geoposition::create(coordinates.release(), (timestamp.toTime_t() * 1000.00) + timestamp.time().msec());
+    QDateTime datetime = geoPosition.timestamp();
+    double timeStampInSeconds = (datetime.toTime_t() + datetime.time().msec()) / 1000;
 #endif
 #endif
-    positionChanged();
+
+    m_lastPosition = GeolocationPosition::create(timeStampInSeconds, latitude, longitude,
+                                                 accuracy, providesAltitude, altitude,
+                                                 providesAltitudeAccuracy, altitudeAccuracy,
+                                                 providesHeading, heading, providesSpeed, speed);
+
+    WebCore::Page* page = QWebPagePrivate::core(m_page);
+    page->geolocationController()->positionChanged(m_lastPosition.get());
 }
 
 }
 
-bool GeolocationServiceQt::startUpdating(PositionOptions*)
+void GeolocationClientQt::startUpdating()
 {
 {
-    m_lastPosition = 0;
-
-    if (!m_location)
-        return false;
+    if (!m_location && (m_location = QGeoPositionInfoSource::createDefaultSource(this)))
+        connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
 
 
-    // TODO: handle enableHighAccuracy()
+    if (!m_location) {
+        WebCore::Page* page = QWebPagePrivate::core(m_page);
+        RefPtr<WebCore::GeolocationError> error = GeolocationError::create(GeolocationError::PositionUnavailable, failedToStartServiceErrorMessage);
+        page->geolocationController()->errorOccurred(error.get());
+        return;
+    }
 
     m_location->startUpdates();
 
     m_location->startUpdates();
-    return true;
 }
 
 }
 
-void GeolocationServiceQt::stopUpdating()
+void GeolocationClientQt::stopUpdating()
 {
     if (m_location)
         m_location->stopUpdates();
 }
 
 {
     if (m_location)
         m_location->stopUpdates();
 }
 
+
+void GeolocationClientQt::setEnableHighAccuracy(bool)
+{
+    // qtmobility 1.0 supports only GPS as of now so high accuracy is enabled by default
+}
+
+void GeolocationClientQt::requestPermission(Geolocation* geolocation)
+{
+    ASSERT(geolocation);
+    QWebFrame* webFrame = QWebFramePrivate::kit(geolocation->frame());
+    GeolocationPermissionClientQt::geolocationPermissionClient()->requestGeolocationPermissionForFrame(webFrame, geolocation);
+}
+
+void GeolocationClientQt::cancelPermissionRequest(Geolocation* geolocation)
+{
+    ASSERT(geolocation);
+    QWebFrame* webFrame = QWebFramePrivate::kit(geolocation->frame());
+    GeolocationPermissionClientQt::geolocationPermissionClient()->cancelGeolocationPermissionRequestForFrame(webFrame, geolocation);
+}
+
 } // namespace WebCore
 } // namespace WebCore
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef GeolocationServiceQt_h
-#define GeolocationServiceQt_h
+#ifndef GeolocationClientQt_h
+#define GeolocationClientQt_h
 
 
-#include "GeolocationService.h"
+#include "GeolocationClient.h"
 #include <QGeoPositionInfoSource>
 #include <wtf/RefPtr.h>
 
 #include <QGeoPositionInfoSource>
 #include <wtf/RefPtr.h>
 
 // QtMobility namespace in slots throws up error and its required to be fixed in qtmobility.
 using namespace QtMobility;
 
 // QtMobility namespace in slots throws up error and its required to be fixed in qtmobility.
 using namespace QtMobility;
 
+class QWebPage;
+
 namespace WebCore {
 
 // This class provides a implementation of a GeolocationService for qtWebkit.
 // It uses QtMobility (v1.0.0) location service to get positions
 namespace WebCore {
 
 // This class provides a implementation of a GeolocationService for qtWebkit.
 // It uses QtMobility (v1.0.0) location service to get positions
-class GeolocationServiceQt : public QObject, GeolocationService {
+class GeolocationClientQt : public QObject, public GeolocationClient {
     Q_OBJECT
 
 public:
     Q_OBJECT
 
 public:
-    static GeolocationService* create(GeolocationServiceClient*);
-
-    GeolocationServiceQt(GeolocationServiceClient*);
-    virtual ~GeolocationServiceQt();
+    GeolocationClientQt(QWebPage*);
+    virtual ~GeolocationClientQt();
 
 
-    virtual bool startUpdating(PositionOptions*);
+    virtual void geolocationDestroyed();
+    virtual void startUpdating();
     virtual void stopUpdating();
 
     virtual void stopUpdating();
 
-    virtual Geoposition* lastPosition() const { return m_lastPosition.get(); }
-    virtual PositionError* lastError() const { return m_lastError.get(); }
+    void setEnableHighAccuracy(bool);
+    virtual GeolocationPosition* lastPosition() { return m_lastPosition.get(); }
 
 
-public Q_SLOTS:
+    virtual void requestPermission(Geolocation*);
+    virtual void cancelPermissionRequest(Geolocation*);
+
+private Q_SLOTS:
     // QGeoPositionInfoSource
     void positionUpdated(const QGeoPositionInfo&);
 
 private:
     // QGeoPositionInfoSource
     void positionUpdated(const QGeoPositionInfo&);
 
 private:
-    RefPtr<Geoposition> m_lastPosition;
-    RefPtr<PositionError> m_lastError;
-
+    QWebPage* m_page;
+    RefPtr<GeolocationPosition> m_lastPosition;
     QtMobility::QGeoPositionInfoSource* m_location;
 };
 
 } // namespace WebCore
 
     QtMobility::QGeoPositionInfoSource* m_location;
 };
 
 } // namespace WebCore
 
-#endif // GeolocationServiceQt_h
+#endif // GeolocationClientQt_h