GeolocationController.h [plain text]
#pragma once
#if ENABLE(GEOLOCATION)
#include "ActivityStateChangeObserver.h"
#include "Geolocation.h"
#include "Page.h"
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class GeolocationClient;
class GeolocationError;
class GeolocationPosition;
class GeolocationController : public Supplement<Page>, private ActivityStateChangeObserver {
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(GeolocationController);
public:
GeolocationController(Page&, GeolocationClient&);
~GeolocationController();
void addObserver(Geolocation&, bool enableHighAccuracy);
void removeObserver(Geolocation&);
void requestPermission(Geolocation&);
void cancelPermissionRequest(Geolocation&);
WEBCORE_EXPORT void positionChanged(const Optional<GeolocationPosition>&);
WEBCORE_EXPORT void errorOccurred(GeolocationError&);
Optional<GeolocationPosition> lastPosition();
GeolocationClient& client() { return m_client; }
WEBCORE_EXPORT static const char* supplementName();
static GeolocationController* from(Page* page) { return static_cast<GeolocationController*>(Supplement<Page>::from(page, supplementName())); }
private:
Page& m_page;
GeolocationClient& m_client;
void activityStateDidChange(OptionSet<ActivityState::Flag> oldActivityState, OptionSet<ActivityState::Flag> newActivityState) override;
Optional<GeolocationPosition> m_lastPosition;
typedef HashSet<Ref<Geolocation>> ObserversSet;
ObserversSet m_observers;
ObserversSet m_highAccuracyObservers;
HashSet<Ref<Geolocation>> m_pendingPermissionRequest;
};
}
#endif // ENABLE(GEOLOCATION)