#ifndef GeolocationController_h
#define GeolocationController_h
#include "core/page/Page.h"
#include "core/page/PageLifecycleObserver.h"
#include "heap/Handle.h"
#include "modules/geolocation/Geolocation.h"
#include "wtf/HashSet.h"
#include "wtf/Noncopyable.h"
#include "wtf/RefPtr.h"
namespace WebCore {
class GeolocationInspectorAgent;
class GeolocationClient;
class GeolocationError;
class GeolocationPosition;
class Page;
class GeolocationController FINAL : public Supplement<Page>, public PageLifecycleObserver {
WTF_MAKE_NONCOPYABLE(GeolocationController);
public:
virtual ~GeolocationController();
static PassOwnPtr<GeolocationController> create(Page&, GeolocationClient*);
void addObserver(Geolocation*, bool enableHighAccuracy);
void removeObserver(Geolocation*);
void requestPermission(Geolocation*);
void cancelPermissionRequest(Geolocation*);
void positionChanged(GeolocationPosition*);
void errorOccurred(GeolocationError*);
GeolocationPosition* lastPosition();
void setClientForTest(GeolocationClient*);
bool hasClientForTest() { return m_hasClientForTest; }
GeolocationClient* client() { return m_client; }
virtual void pageVisibilityChanged() OVERRIDE;
static const char* supplementName();
static GeolocationController* from(Page* page) { return static_cast<GeolocationController*>(Supplement<Page>::from(page, supplementName())); }
private:
GeolocationController(Page&, GeolocationClient*);
void startUpdatingIfNeeded();
void stopUpdatingIfNeeded();
GeolocationClient* m_client;
bool m_hasClientForTest;
RefPtr<GeolocationPosition> m_lastPosition;
typedef WillBePersistentHeapHashSet<RefPtrWillBeMember<Geolocation> > ObserversSet;
ObserversSet m_observers;
ObserversSet m_highAccuracyObservers;
bool m_isClientUpdating;
GeolocationInspectorAgent* m_inspectorAgent;
};
}
#endif