From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/Modules/geolocation/Geolocation.h | 93 ++++++++---------------- 1 file changed, 31 insertions(+), 62 deletions(-) (limited to 'Source/WebCore/Modules/geolocation/Geolocation.h') diff --git a/Source/WebCore/Modules/geolocation/Geolocation.h b/Source/WebCore/Modules/geolocation/Geolocation.h index ab486443e..3396cdc85 100644 --- a/Source/WebCore/Modules/geolocation/Geolocation.h +++ b/Source/WebCore/Modules/geolocation/Geolocation.h @@ -24,12 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef Geolocation_h -#define Geolocation_h +#pragma once #if ENABLE(GEOLOCATION) #include "ActiveDOMObject.h" +#include "Document.h" #include "Geoposition.h" #include "PositionCallback.h" #include "PositionError.h" @@ -37,41 +37,40 @@ #include "PositionOptions.h" #include "ScriptWrappable.h" #include "Timer.h" +#include +#include namespace WebCore { -class Document; class Frame; -class GeolocationController; +class GeoNotifier; class GeolocationError; -class GeolocationPosition; class Page; class ScriptExecutionContext; +class SecurityOrigin; +struct PositionOptions; -class Geolocation : public ScriptWrappable, public RefCounted, public ActiveDOMObject -{ +class Geolocation : public ScriptWrappable, public RefCounted, public ActiveDOMObject { + friend class GeoNotifier; public: - static PassRefPtr create(ScriptExecutionContext*); - ~Geolocation(); - -#if PLATFORM(IOS) - virtual bool canSuspend() const override; - virtual void suspend(ReasonForSuspension) override; - virtual void resume() override; - void resetAllGeolocationPermission(); -#endif // PLATFORM(IOS) - Document* document() const; - Frame* frame() const; - - void getCurrentPosition(PassRefPtr, PassRefPtr, PassRefPtr); - int watchPosition(PassRefPtr, PassRefPtr, PassRefPtr); + static Ref create(ScriptExecutionContext*); + WEBCORE_EXPORT ~Geolocation(); + + WEBCORE_EXPORT void resetAllGeolocationPermission(); + Document* document() const { return downcast(scriptExecutionContext()); } + Frame* frame() const { return document() ? document()->frame() : nullptr; } + + void getCurrentPosition(Ref&&, RefPtr&&, PositionOptions&&); + int watchPosition(Ref&&, RefPtr&&, PositionOptions&&); void clearWatch(int watchID); - void setIsAllowed(bool); + WEBCORE_EXPORT void setIsAllowed(bool); + void resetIsAllowed() { m_allowGeolocation = Unknown; } bool isAllowed() const { return m_allowGeolocation == Yes; } void positionChanged(); void setError(GeolocationError*); + bool shouldBlockGeolocationRequests(); private: explicit Geolocation(ScriptExecutionContext*); @@ -79,48 +78,23 @@ private: Geoposition* lastPosition(); // ActiveDOMObject - virtual void stop() override; + void stop() override; + bool canSuspendForDocumentSuspension() const override; + void suspend(ReasonForSuspension) override; + void resume() override; + const char* activeDOMObjectName() const override; bool isDenied() const { return m_allowGeolocation == No; } Page* page() const; - - class GeoNotifier : public RefCounted { - public: - static PassRefPtr create(Geolocation* geolocation, PassRefPtr positionCallback, PassRefPtr positionErrorCallback, PassRefPtr options) { return adoptRef(new GeoNotifier(geolocation, positionCallback, positionErrorCallback, options)); } - - PositionOptions* options() const { return m_options.get(); }; - void setFatalError(PassRefPtr); - - bool useCachedPosition() const { return m_useCachedPosition; } - void setUseCachedPosition(); - - void runSuccessCallback(Geoposition*); - void runErrorCallback(PositionError*); - - void startTimerIfNeeded(); - void stopTimer(); - void timerFired(Timer&); - bool hasZeroTimeout() const; - - private: - GeoNotifier(Geolocation*, PassRefPtr, PassRefPtr, PassRefPtr); - - RefPtr m_geolocation; - RefPtr m_successCallback; - RefPtr m_errorCallback; - RefPtr m_options; - Timer m_timer; - RefPtr m_fatalError; - bool m_useCachedPosition; - }; + SecurityOrigin* securityOrigin() const; typedef Vector> GeoNotifierVector; typedef HashSet> GeoNotifierSet; class Watchers { public: - bool add(int id, PassRefPtr); + bool add(int id, RefPtr&&); GeoNotifier* find(int id); void remove(int id); void remove(GeoNotifier*); @@ -166,7 +140,7 @@ private: void fatalErrorOccurred(GeoNotifier*); void requestTimedOut(GeoNotifier*); void requestUsesCachedPosition(GeoNotifier*); - bool haveSuitableCachedPosition(PositionOptions*); + bool haveSuitableCachedPosition(const PositionOptions&); void makeCachedPositionCallbacks(); GeoNotifierSet m_oneShots; @@ -180,15 +154,13 @@ private: Yes, No } m_allowGeolocation; -#if PLATFORM(IOS) bool m_isSuspended; bool m_resetOnResume; bool m_hasChangedPosition; RefPtr m_errorWaitingForResume; - void resumeTimerFired(Timer&); - Timer m_resumeTimer; -#endif // PLATFORM(IOS) + void resumeTimerFired(); + Timer m_resumeTimer; GeoNotifierSet m_requestsAwaitingCachedPosition; }; @@ -196,6 +168,3 @@ private: } // namespace WebCore #endif // ENABLE(GEOLOCATION) - -#endif // Geolocation_h - -- cgit v1.2.1