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(GeolocationPosition*);
WEBCORE_EXPORT void errorOccurred(GeolocationError*);
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(ActivityState::Flags oldActivityState, ActivityState::Flags newActivityState) override;
RefPtr<GeolocationPosition> m_lastPosition;
typedef HashSet<RefPtr<Geolocation>> ObserversSet;
ObserversSet m_observers;
ObserversSet m_highAccuracyObservers;
HashSet<RefPtr<Geolocation>> m_pendedPermissionRequest;
};
}
#endif // ENABLE(GEOLOCATION)