Title: [133247] trunk/Source/WebKit/blackberry
Revision
133247
Author
[email protected]
Date
2012-11-01 18:17:27 -0700 (Thu, 01 Nov 2012)

Log Message

[BlackBerry] Add a prompt to enable global location services
https://bugs.webkit.org/show_bug.cgi?id=100992

PR 227897

Patch by Otto Derek Cheung <[email protected]> on 2012-11-01
Reviewed by Rob Buis.

Adding a dialog to let the user know location services isn't enabled.
Currently, the browser app does not check whether the global setting for
location service is enabled. This patch adds a dialog to allow the user
to open the settings app and change that setting. This infobar will only
show once per session. If the user fails to turn on location services after
the first prompt, all geolocation requests will automatically fail.

Also, adapting GeolocationClientBlackBerry to the removal of GeoTracker.
The class now talks directly to the geo handler singleton.

* Api/WebPageClient.h:
* WebCoreSupport/GeolocationClientBlackBerry.cpp:
(GeolocationClientBlackBerry::GeolocationClientBlackBerry):
(GeolocationClientBlackBerry::geolocationDestroyed):
(GeolocationClientBlackBerry::startUpdating):
(GeolocationClientBlackBerry::stopUpdating):
(GeolocationClientBlackBerry::requestPermission):
(GeolocationClientBlackBerry::setEnableHighAccuracy):
* WebCoreSupport/GeolocationClientBlackBerry.h:
(WebCore::GeolocationClientBlackBerry::requiresHighAccuracy):
(GeolocationClientBlackBerry):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (133246 => 133247)


--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-11-02 00:59:08 UTC (rev 133246)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-11-02 01:17:27 UTC (rev 133247)
@@ -160,6 +160,8 @@
 
     virtual void cursorChanged(Platform::CursorType, const char* url, int x, int y) = 0;
 
+    virtual void requestGlobalLocalServicePermission(Platform::GeoTrackerListener*, const BlackBerry::Platform::String& origin) = 0;
+
     virtual void requestGeolocationPermission(Platform::GeoTrackerListener*, const BlackBerry::Platform::String& origin) = 0;
     virtual void cancelGeolocationPermission() = 0;
     virtual Platform::NetworkStreamFactory* networkStreamFactory() = 0;

Modified: trunk/Source/WebKit/blackberry/ChangeLog (133246 => 133247)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-11-02 00:59:08 UTC (rev 133246)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-11-02 01:17:27 UTC (rev 133247)
@@ -1,3 +1,34 @@
+2012-11-01  Otto Derek Cheung  <[email protected]>
+
+        [BlackBerry] Add a prompt to enable global location services
+        https://bugs.webkit.org/show_bug.cgi?id=100992
+        
+        PR 227897
+
+        Reviewed by Rob Buis.
+
+        Adding a dialog to let the user know location services isn't enabled.
+        Currently, the browser app does not check whether the global setting for
+        location service is enabled. This patch adds a dialog to allow the user
+        to open the settings app and change that setting. This infobar will only
+        show once per session. If the user fails to turn on location services after
+        the first prompt, all geolocation requests will automatically fail.
+
+        Also, adapting GeolocationClientBlackBerry to the removal of GeoTracker.
+        The class now talks directly to the geo handler singleton.
+
+        * Api/WebPageClient.h:
+        * WebCoreSupport/GeolocationClientBlackBerry.cpp:
+        (GeolocationClientBlackBerry::GeolocationClientBlackBerry):
+        (GeolocationClientBlackBerry::geolocationDestroyed):
+        (GeolocationClientBlackBerry::startUpdating):
+        (GeolocationClientBlackBerry::stopUpdating):
+        (GeolocationClientBlackBerry::requestPermission):
+        (GeolocationClientBlackBerry::setEnableHighAccuracy):
+        * WebCoreSupport/GeolocationClientBlackBerry.h:
+        (WebCore::GeolocationClientBlackBerry::requiresHighAccuracy):
+        (GeolocationClientBlackBerry):
+
 2012-11-01  Michael Matovsky  <[email protected]>
 
         [BlackBerry] Web page view state should be preserved for pages loaded from page cache

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.cpp (133246 => 133247)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.cpp	2012-11-02 00:59:08 UTC (rev 133246)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.cpp	2012-11-02 01:17:27 UTC (rev 133247)
@@ -39,30 +39,28 @@
 
 GeolocationClientBlackBerry::GeolocationClientBlackBerry(BlackBerry::WebKit::WebPagePrivate* webPagePrivate)
     : m_webPagePrivate(webPagePrivate)
-    , m_tracker(0)
     , m_accuracy(false)
+    , m_isActive(false)
 {
 }
 
 void GeolocationClientBlackBerry::geolocationDestroyed()
 {
-    if (m_tracker)
-        m_tracker->destroy();
     delete this;
 }
 
 void GeolocationClientBlackBerry::startUpdating()
 {
-    if (m_tracker)
-        m_tracker->resume();
-    else
-        m_tracker = BlackBerry::Platform::GeoTracker::create(this, m_accuracy);
+    if (!m_isActive)
+        BlackBerry::Platform::GeolocationHandler::instance()->addListener(this, false);
+    m_isActive = true;
 }
 
 void GeolocationClientBlackBerry::stopUpdating()
 {
-    if (m_tracker)
-        m_tracker->suspend();
+    if (m_isActive)
+        BlackBerry::Platform::GeolocationHandler::instance()->removeListener(this);
+    m_isActive = false;
 }
 
 GeolocationPosition* GeolocationClientBlackBerry::lastPosition()
@@ -75,16 +73,32 @@
     Frame* frame = location->frame();
     if (!frame)
         return;
+
+    // FIXME: The geolocation setting for WebSettings is always true. Nothing ever toggles that setting.
     if (!m_webPagePrivate->m_webSettings->isGeolocationEnabled()) {
         location->setIsAllowed(false);
         return;
     }
+
     DOMWindow* window = frame->document()->domWindow();
     if (!window)
         return;
 
     const BlackBerry::Platform::String origin = frameOrigin(frame);
     m_pendingPermissionGeolocation = location;
+
+    // Check global location setting, if it is off then we request an infobar that invokes a location settings card.
+    // If it's on, then we request an infobar that allows the site to have permission to use geolocation.
+    if (!BlackBerry::Platform::GeolocationHandler::instance()->isGlobalServiceActive()) {
+        // We only want to ask them once per session. If we get here again, automatically fail the request.
+        if (!BlackBerry::Platform::GeolocationHandler::instance()->didAskUserForGlobalPermission()) {
+            m_webPagePrivate->m_client->requestGlobalLocalServicePermission(this, origin);
+            BlackBerry::Platform::GeolocationHandler::instance()->setAskedUserForGlobalPermission();
+        } else
+            onPermission(false);
+        return;
+    }
+
     m_webPagePrivate->m_client->requestGeolocationPermission(this, origin);
 }
 
@@ -115,12 +129,7 @@
 
 void GeolocationClientBlackBerry::setEnableHighAccuracy(bool newAccuracy)
 {
-    if (m_accuracy == newAccuracy)
-        return;
-
+    // FIXME: we have to implement high accuracy on our side too
     m_accuracy = newAccuracy;
-
-    if (m_tracker)
-        m_tracker->setRequiresHighAccuracy(m_accuracy);
 }
 

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.h (133246 => 133247)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.h	2012-11-02 00:59:08 UTC (rev 133246)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.h	2012-11-02 01:17:27 UTC (rev 133247)
@@ -44,18 +44,18 @@
     virtual void requestPermission(Geolocation*);
     virtual void cancelPermissionRequest(Geolocation*);
 
+    virtual bool requiresHighAccuracy() { return m_accuracy; }
     virtual void onLocationUpdate(double timestamp, double latitude, double longitude, double accuracy, double altitude, bool altitudeValid, double altitudeAccuracy,
                                   bool altitudeAccuracyValid, double speed, bool speedValid, double heading, bool headingValid);
     virtual void onLocationError(const char* error);
     virtual void onPermission(bool isAllowed);
-    BlackBerry::Platform::GeoTracker* tracker() const { return m_tracker; }
 
 private:
     BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
-    BlackBerry::Platform::GeoTracker* m_tracker;
     RefPtr<Geolocation> m_pendingPermissionGeolocation;
     RefPtr<GeolocationPosition> m_lastPosition;
     bool m_accuracy;
+    bool m_isActive;
 };
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to