GeolocationService.h [plain text]
#ifndef GeolocationService_h
#define GeolocationService_h
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.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 {
WTF_MAKE_NONCOPYABLE(GeolocationService);
public:
static PassOwnPtr<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();
typedef PassOwnPtr<GeolocationService> (FactoryFunction)(GeolocationServiceClient*);
static void setCustomMockFactory(FactoryFunction);
protected:
GeolocationService(GeolocationServiceClient*);
GeolocationServiceClient* geolocationServiceClient() const { return m_geolocationServiceClient; }
private:
GeolocationServiceClient* m_geolocationServiceClient;
static FactoryFunction* s_factoryFunction;
static FactoryFunction* s_mockFactoryFunction;
};
}
#endif // GeolocationService_h