summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/geolocation/Geolocation.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/Modules/geolocation/Geolocation.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/Modules/geolocation/Geolocation.h')
-rw-r--r--Source/WebCore/Modules/geolocation/Geolocation.h93
1 files changed, 31 insertions, 62 deletions
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 <wtf/HashMap.h>
+#include <wtf/HashSet.h>
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<Geolocation>, public ActiveDOMObject
-{
+class Geolocation : public ScriptWrappable, public RefCounted<Geolocation>, public ActiveDOMObject {
+ friend class GeoNotifier;
public:
- static PassRefPtr<Geolocation> 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<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>);
- int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>);
+ static Ref<Geolocation> create(ScriptExecutionContext*);
+ WEBCORE_EXPORT ~Geolocation();
+
+ WEBCORE_EXPORT void resetAllGeolocationPermission();
+ Document* document() const { return downcast<Document>(scriptExecutionContext()); }
+ Frame* frame() const { return document() ? document()->frame() : nullptr; }
+
+ void getCurrentPosition(Ref<PositionCallback>&&, RefPtr<PositionErrorCallback>&&, PositionOptions&&);
+ int watchPosition(Ref<PositionCallback>&&, RefPtr<PositionErrorCallback>&&, 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<GeoNotifier> {
- public:
- static PassRefPtr<GeoNotifier> create(Geolocation* geolocation, PassRefPtr<PositionCallback> positionCallback, PassRefPtr<PositionErrorCallback> positionErrorCallback, PassRefPtr<PositionOptions> options) { return adoptRef(new GeoNotifier(geolocation, positionCallback, positionErrorCallback, options)); }
-
- PositionOptions* options() const { return m_options.get(); };
- void setFatalError(PassRefPtr<PositionError>);
-
- bool useCachedPosition() const { return m_useCachedPosition; }
- void setUseCachedPosition();
-
- void runSuccessCallback(Geoposition*);
- void runErrorCallback(PositionError*);
-
- void startTimerIfNeeded();
- void stopTimer();
- void timerFired(Timer<GeoNotifier>&);
- bool hasZeroTimeout() const;
-
- private:
- GeoNotifier(Geolocation*, PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>);
-
- RefPtr<Geolocation> m_geolocation;
- RefPtr<PositionCallback> m_successCallback;
- RefPtr<PositionErrorCallback> m_errorCallback;
- RefPtr<PositionOptions> m_options;
- Timer<GeoNotifier> m_timer;
- RefPtr<PositionError> m_fatalError;
- bool m_useCachedPosition;
- };
+ SecurityOrigin* securityOrigin() const;
typedef Vector<RefPtr<GeoNotifier>> GeoNotifierVector;
typedef HashSet<RefPtr<GeoNotifier>> GeoNotifierSet;
class Watchers {
public:
- bool add(int id, PassRefPtr<GeoNotifier>);
+ bool add(int id, RefPtr<GeoNotifier>&&);
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<PositionError> m_errorWaitingForResume;
- void resumeTimerFired(Timer<Geolocation>&);
- Timer<Geolocation> 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
-