GeolocationService.h [plain text]
#ifndef GeolocationService_h
#define GeolocationService_h
#include <wtf/Noncopyable.h>
namespace WebCore {
class GeolocationService;
class Geoposition;
class PositionError;
class PositionOptions;
class GeolocationServiceClient {
public:
virtual ~GeolocationServiceClient() { }
virtual void geolocationServicePositionChanged(GeolocationService*) = 0;
virtual void geolocationServiceErrorOccurred(GeolocationService*) = 0;
#if ENABLE(GEOLOCATION_PERMISSION_CACHE)
virtual void geolocationServiceCachePolicyChanged(GeolocationService*) { }
#endif
};
class GeolocationService : public Noncopyable {
public:
static GeolocationService* create(GeolocationServiceClient*);
virtual ~GeolocationService() { }
virtual bool startUpdating(PositionOptions*) { return false; }
virtual void stopUpdating() { }
virtual void suspend() { }
virtual void resume() { }
virtual Geoposition* lastPosition() const { return 0; }
virtual PositionError* lastError() const { return 0; }
#if ENABLE(GEOLOCATION_PERMISSION_CACHE)
virtual void setShouldClearCache(bool) { }
virtual bool shouldClearCache() const { return false; }
#endif
void positionChanged();
void errorOccurred();
#if ENABLE(GEOLOCATION_PERMISSION_CACHE)
void cachePolicyChanged();
#endif
static void useMock();
protected:
GeolocationService(GeolocationServiceClient*);
GeolocationServiceClient* geolocationServiceClient() const { return m_geolocationServiceClient; }
private:
GeolocationServiceClient* m_geolocationServiceClient;
typedef GeolocationService* (FactoryFunction)(GeolocationServiceClient*);
static FactoryFunction* s_factoryFunction;
};
}
#endif // GeolocationService_h