diff options
author | Steve Block <steveblock@google.com> | 2009-08-06 18:48:53 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2009-08-07 15:07:19 +0100 |
commit | 00bd0fc337f03c8595ccae3a2d3d56c6d8e97cc9 (patch) | |
tree | 130302b8c7706cb70541ba043d141d8e02889490 | |
parent | 0c9108c0f832d34e6468bf1b3ed4132053c6a0f3 (diff) | |
download | external_webkit-00bd0fc337f03c8595ccae3a2d3d56c6d8e97cc9.zip external_webkit-00bd0fc337f03c8595ccae3a2d3d56c6d8e97cc9.tar.gz external_webkit-00bd0fc337f03c8595ccae3a2d3d56c6d8e97cc9.tar.bz2 |
Fixes WebKit bug 26993.
Makes sure that if the Geolocation permissions request to the chrome is
implemented synchronously, watches are called back only once.
-rw-r--r-- | WebCore/page/Geolocation.cpp | 33 | ||||
-rw-r--r-- | WebCore/page/Geolocation.h | 1 |
2 files changed, 24 insertions, 10 deletions
diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp index 86a7f16..8bfa093 100644 --- a/WebCore/page/Geolocation.cpp +++ b/WebCore/page/Geolocation.cpp @@ -140,7 +140,7 @@ void Geolocation::setIsAllowed(bool allowed) if (isAllowed()) { startTimers(); - geolocationServicePositionChanged(m_service.get()); + makeSuccessCallbacks(); } else { WTF::RefPtr<WebCore::PositionError> error = WebCore::PositionError::create(PositionError::PERMISSION_DENIED, "User disallowed GeoLocation"); handleError(error.get()); @@ -264,17 +264,30 @@ void Geolocation::requestPermission() m_allowGeolocation = InProgress; } -void Geolocation::geolocationServicePositionChanged(GeolocationService* service) +void Geolocation::geolocationServicePositionChanged(GeolocationService*) { - ASSERT(service->lastPosition()); - - requestPermission(); - if (!isAllowed()) + ASSERT(m_service->lastPosition()); + + if (!isAllowed()) { + // requestPermission() will ask the chrome for permission. This may be + // implemented synchronously or asynchronously. In both cases, + // makeSucessCallbacks() will be called if permission is granted, so + // there's nothing more to do here. + requestPermission(); return; - - sendPositionToOneShots(service->lastPosition()); - sendPositionToWatchers(service->lastPosition()); - + } + + makeSuccessCallbacks(); +} + +void Geolocation::makeSuccessCallbacks() +{ + ASSERT(m_service->lastPosition()); + ASSERT(isAllowed()); + + sendPositionToOneShots(m_service->lastPosition()); + sendPositionToWatchers(m_service->lastPosition()); + m_oneShots.clear(); if (!hasListeners()) diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h index ae24bdd..44a7fe0 100644 --- a/WebCore/page/Geolocation.h +++ b/WebCore/page/Geolocation.h @@ -99,6 +99,7 @@ private: void startTimersForWatchers(); void startTimers(); + void makeSuccessCallbacks(); void handleError(PositionError*); void requestPermission(); |