Changeset 133247 in webkit


Ignore:
Timestamp:
Nov 1, 2012 6:17:27 PM (11 years ago)
Author:
commit-queue@webkit.org
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 <otcheung@rim.com> 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):

Location:
trunk/Source/WebKit/blackberry
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/WebPageClient.h

    r133199 r133247  
    161161    virtual void cursorChanged(Platform::CursorType, const char* url, int x, int y) = 0;
    162162
     163    virtual void requestGlobalLocalServicePermission(Platform::GeoTrackerListener*, const BlackBerry::Platform::String& origin) = 0;
     164
    163165    virtual void requestGeolocationPermission(Platform::GeoTrackerListener*, const BlackBerry::Platform::String& origin) = 0;
    164166    virtual void cancelGeolocationPermission() = 0;
  • trunk/Source/WebKit/blackberry/ChangeLog

    r133199 r133247  
     12012-11-01  Otto Derek Cheung  <otcheung@rim.com>
     2
     3        [BlackBerry] Add a prompt to enable global location services
     4        https://bugs.webkit.org/show_bug.cgi?id=100992
     5       
     6        PR 227897
     7
     8        Reviewed by Rob Buis.
     9
     10        Adding a dialog to let the user know location services isn't enabled.
     11        Currently, the browser app does not check whether the global setting for
     12        location service is enabled. This patch adds a dialog to allow the user
     13        to open the settings app and change that setting. This infobar will only
     14        show once per session. If the user fails to turn on location services after
     15        the first prompt, all geolocation requests will automatically fail.
     16
     17        Also, adapting GeolocationClientBlackBerry to the removal of GeoTracker.
     18        The class now talks directly to the geo handler singleton.
     19
     20        * Api/WebPageClient.h:
     21        * WebCoreSupport/GeolocationClientBlackBerry.cpp:
     22        (GeolocationClientBlackBerry::GeolocationClientBlackBerry):
     23        (GeolocationClientBlackBerry::geolocationDestroyed):
     24        (GeolocationClientBlackBerry::startUpdating):
     25        (GeolocationClientBlackBerry::stopUpdating):
     26        (GeolocationClientBlackBerry::requestPermission):
     27        (GeolocationClientBlackBerry::setEnableHighAccuracy):
     28        * WebCoreSupport/GeolocationClientBlackBerry.h:
     29        (WebCore::GeolocationClientBlackBerry::requiresHighAccuracy):
     30        (GeolocationClientBlackBerry):
     31
    1322012-11-01  Michael Matovsky  <mmatovsky@rim.com>
    233
  • trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.cpp

    r132440 r133247  
    4040GeolocationClientBlackBerry::GeolocationClientBlackBerry(BlackBerry::WebKit::WebPagePrivate* webPagePrivate)
    4141    : m_webPagePrivate(webPagePrivate)
    42     , m_tracker(0)
    4342    , m_accuracy(false)
     43    , m_isActive(false)
    4444{
    4545}
     
    4747void GeolocationClientBlackBerry::geolocationDestroyed()
    4848{
    49     if (m_tracker)
    50         m_tracker->destroy();
    5149    delete this;
    5250}
     
    5452void GeolocationClientBlackBerry::startUpdating()
    5553{
    56     if (m_tracker)
    57         m_tracker->resume();
    58     else
    59         m_tracker = BlackBerry::Platform::GeoTracker::create(this, m_accuracy);
     54    if (!m_isActive)
     55        BlackBerry::Platform::GeolocationHandler::instance()->addListener(this, false);
     56    m_isActive = true;
    6057}
    6158
    6259void GeolocationClientBlackBerry::stopUpdating()
    6360{
    64     if (m_tracker)
    65         m_tracker->suspend();
     61    if (m_isActive)
     62        BlackBerry::Platform::GeolocationHandler::instance()->removeListener(this);
     63    m_isActive = false;
    6664}
    6765
     
    7674    if (!frame)
    7775        return;
     76
     77    // FIXME: The geolocation setting for WebSettings is always true. Nothing ever toggles that setting.
    7878    if (!m_webPagePrivate->m_webSettings->isGeolocationEnabled()) {
    7979        location->setIsAllowed(false);
    8080        return;
    8181    }
     82
    8283    DOMWindow* window = frame->document()->domWindow();
    8384    if (!window)
     
    8687    const BlackBerry::Platform::String origin = frameOrigin(frame);
    8788    m_pendingPermissionGeolocation = location;
     89
     90    // Check global location setting, if it is off then we request an infobar that invokes a location settings card.
     91    // If it's on, then we request an infobar that allows the site to have permission to use geolocation.
     92    if (!BlackBerry::Platform::GeolocationHandler::instance()->isGlobalServiceActive()) {
     93        // We only want to ask them once per session. If we get here again, automatically fail the request.
     94        if (!BlackBerry::Platform::GeolocationHandler::instance()->didAskUserForGlobalPermission()) {
     95            m_webPagePrivate->m_client->requestGlobalLocalServicePermission(this, origin);
     96            BlackBerry::Platform::GeolocationHandler::instance()->setAskedUserForGlobalPermission();
     97        } else
     98            onPermission(false);
     99        return;
     100    }
     101
    88102    m_webPagePrivate->m_client->requestGeolocationPermission(this, origin);
    89103}
     
    116130void GeolocationClientBlackBerry::setEnableHighAccuracy(bool newAccuracy)
    117131{
    118     if (m_accuracy == newAccuracy)
    119         return;
    120 
     132    // FIXME: we have to implement high accuracy on our side too
    121133    m_accuracy = newAccuracy;
    122 
    123     if (m_tracker)
    124         m_tracker->setRequiresHighAccuracy(m_accuracy);
    125134}
    126135
  • trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.h

    r132440 r133247  
    4545    virtual void cancelPermissionRequest(Geolocation*);
    4646
     47    virtual bool requiresHighAccuracy() { return m_accuracy; }
    4748    virtual void onLocationUpdate(double timestamp, double latitude, double longitude, double accuracy, double altitude, bool altitudeValid, double altitudeAccuracy,
    4849                                  bool altitudeAccuracyValid, double speed, bool speedValid, double heading, bool headingValid);
    4950    virtual void onLocationError(const char* error);
    5051    virtual void onPermission(bool isAllowed);
    51     BlackBerry::Platform::GeoTracker* tracker() const { return m_tracker; }
    5252
    5353private:
    5454    BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
    55     BlackBerry::Platform::GeoTracker* m_tracker;
    5655    RefPtr<Geolocation> m_pendingPermissionGeolocation;
    5756    RefPtr<GeolocationPosition> m_lastPosition;
    5857    bool m_accuracy;
     58    bool m_isActive;
    5959};
    6060}
Note: See TracChangeset for help on using the changeset viewer.