Fixes WebKit bug 26993.
Makes sure that if the Geolocation permissions request to the chrome is
implemented synchronously, watches are called back only once.
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 @@
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 @@
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 @@
void startTimersForWatchers();
void startTimers();
+ void makeSuccessCallbacks();
void handleError(PositionError*);
void requestPermission();