Commit 86c1e31c authored by eric@webkit.org's avatar eric@webkit.org

2009-08-12 Steve Block <steveblock@google.com>

        Reviewed by Eric Seidel.

        Bug 26993 : Geolocation::requestPermission()
        https://bugs.webkit.org/show_bug.cgi?id=26993

        Second patch to allow the Geolocation permission request to chrome to be asynchronous
        or synchronous. Fixes a bug where callbacks were called twice when permissions
        are granted synchronously.

        No new tests required.

        * page/Geolocation.cpp:
        (WebCore::Geolocation::setIsAllowed): Modified. Calls makeSuccessCallbacks() rather than geolocationServicePositionChanged().
        (WebCore::Geolocation::geolocationServicePositionChanged): Modified. Updated logic to avoid repeated callbacks when permissions are granted synchronously.
        (WebCore::Geolocation::makeSuccessCallbacks): Added. Calls success callbacks.
        * page/Geolocation.h: Modified. Adds makeSuccessCallbacks().

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47152 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6c6fb4b5
2009-08-12 Steve Block <steveblock@google.com>
Reviewed by Eric Seidel.
Bug 26993 : Geolocation::requestPermission()
https://bugs.webkit.org/show_bug.cgi?id=26993
Second patch to allow the Geolocation permission request to chrome to be asynchronous
or synchronous. Fixes a bug where callbacks were called twice when permissions
are granted synchronously.
No new tests required.
* page/Geolocation.cpp:
(WebCore::Geolocation::setIsAllowed): Modified. Calls makeSuccessCallbacks() rather than geolocationServicePositionChanged().
(WebCore::Geolocation::geolocationServicePositionChanged): Modified. Updated logic to avoid repeated callbacks when permissions are granted synchronously.
(WebCore::Geolocation::makeSuccessCallbacks): Added. Calls success callbacks.
* page/Geolocation.h: Modified. Adds makeSuccessCallbacks().
2009-08-12 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
......@@ -139,7 +139,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());
......@@ -270,14 +270,28 @@ void Geolocation::requestPermission()
void Geolocation::geolocationServicePositionChanged(GeolocationService* service)
{
ASSERT(service->lastPosition());
ASSERT_UNUSED(service, service == m_service);
ASSERT(m_service->lastPosition());
requestPermission();
if (!isAllowed())
if (!isAllowed()) {
// requestPermission() will ask the chrome for permission. This may be
// implemented synchronously or asynchronously. In both cases,
// makeSuccessCallbacks() will be called if permission is granted, so
// there's nothing more to do here.
requestPermission();
return;
}
makeSuccessCallbacks();
}
void Geolocation::makeSuccessCallbacks()
{
ASSERT(m_service->lastPosition());
ASSERT(isAllowed());
sendPositionToOneShots(service->lastPosition());
sendPositionToWatchers(service->lastPosition());
sendPositionToOneShots(m_service->lastPosition());
sendPositionToWatchers(m_service->lastPosition());
m_oneShots.clear();
......
......@@ -102,6 +102,7 @@ private:
void startTimersForWatchers();
void startTimers();
void makeSuccessCallbacks();
void handleError(PositionError*);
void requestPermission();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment