From 23c22a60ec108914d8df8cd80023582fbedfe978 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Mon, 1 Feb 2010 12:39:36 +0000 Subject: [PATCH] Cherry-pick WebKit change 54079 for client-based Geolocation See http://trac.webkit.org/changeset/54079 This is required to bring Geolocation up-to-date with webkit.org to allow upstreaming of maximumAge code. Change-Id: I46b8f439668768fa930c610d4b10c7e45cc1ca01 --- WebCore/ChangeLog | 15 +++++++++++++++ WebCore/page/Geolocation.cpp | 35 ++++++++++++++++++++++++++++++----- WebCore/page/Geolocation.h | 4 +++- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index b9bfc2522..d2c246af1 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,18 @@ +2010-01-29 Steve Falkenburg + + Reviewed by Darin Adler. + + Client-based Geolocation starts updating before getting consent from the user + https://bugs.webkit.org/show_bug.cgi?id=34343 + + * page/Geolocation.cpp: + (WebCore::Geolocation::startRequest): Pass notifier instead of options to startUpdating. + (WebCore::Geolocation::setIsAllowed): Add the observer or notify of error for deferred startUpdating. + (WebCore::Geolocation::startUpdating): Pass notifier instead of options, since we may need to call it if we fail to get user consent. + Defer adding the observer if we don't yet have user consent, since this could kick off + server-based wifi Geolocation requests. + * page/Geolocation.h: + 2010-01-22 Steve Falkenburg Reviewed by Dan Bernstein. diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp index ef3d43c95..1ab4a8c69 100644 --- a/WebCore/page/Geolocation.cpp +++ b/WebCore/page/Geolocation.cpp @@ -283,7 +283,7 @@ PassRefPtr Geolocation::startRequest(PassRefPtrm_options.get())) notifier->setUseCachedPosition(); else { - if (notifier->hasZeroTimeout() || startUpdating(notifier->m_options.get())) + if (notifier->hasZeroTimeout() || startUpdating(notifier.get())) notifier->startTimerIfNeeded(); else notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, "Failed to start Geolocation service")); @@ -348,7 +348,7 @@ void Geolocation::makeCachedPositionCallbacks() if (m_oneShots.contains(notifier)) m_oneShots.remove(notifier); else if (m_watchers.contains(notifier)) { - if (notifier->hasZeroTimeout() || startUpdating(notifier->m_options.get())) + if (notifier->hasZeroTimeout() || startUpdating(notifier)) notifier->startTimerIfNeeded(); else notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, "Failed to start Geolocation service")); @@ -402,6 +402,26 @@ void Geolocation::setIsAllowed(bool allowed) // This may be due to either a new position from the service, or a cached // position. m_allowGeolocation = allowed ? Yes : No; + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + if (m_startRequestPermissionNotifier) { + if (isAllowed()) { + // Permission request was made during the startUpdating process + m_startRequestPermissionNotifier = 0; + if (!m_frame) + return; + Page* page = m_frame->page(); + if (!page) + return; + page->geolocationController()->addObserver(this); + } else { + m_startRequestPermissionNotifier->setFatalError(PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage)); + m_oneShots.add(m_startRequestPermissionNotifier); + m_startRequestPermissionNotifier = 0; + } + return; + } +#endif if (!isAllowed()) { RefPtr error = PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage); @@ -594,12 +614,17 @@ void Geolocation::geolocationServiceErrorOccurred(GeolocationService* service) #endif -bool Geolocation::startUpdating(PositionOptions* options) +bool Geolocation::startUpdating(GeoNotifier* notifier) { #if ENABLE(CLIENT_BASED_GEOLOCATION) // FIXME: Pass options to client. - UNUSED_PARAM(options); + if (!isAllowed()) { + m_startRequestPermissionNotifier = notifier; + requestPermission(); + return true; + } + if (!m_frame) return false; @@ -610,7 +635,7 @@ bool Geolocation::startUpdating(PositionOptions* options) page->geolocationController()->addObserver(this); return true; #else - return m_service->startUpdating(options); + return m_service->startUpdating(notifier->options); #endif } diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h index 077a69565..0db37e499 100644 --- a/WebCore/page/Geolocation.h +++ b/WebCore/page/Geolocation.h @@ -145,7 +145,7 @@ private: void requestPermission(); - bool startUpdating(PositionOptions*); + bool startUpdating(GeoNotifier*); void stopUpdating(); #if !ENABLE(CLIENT_BASED_GEOLOCATION) @@ -173,6 +173,8 @@ private: Frame* m_frame; #if !ENABLE(CLIENT_BASED_GEOLOCATION) OwnPtr m_service; +#else + RefPtr m_startRequestPermissionNotifier; #endif RefPtr m_lastPosition; RefPtr m_currentPosition; -- 2.11.0