#ifndef GeolocationClientMock_h
#define GeolocationClientMock_h
#include "heap/Handle.h"
#include "modules/geolocation/GeolocationClient.h"
#include "platform/Timer.h"
#include "wtf/HashSet.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class GeolocationController;
class GeolocationPosition;
class GeolocationClientMock : public GeolocationClient {
public:
GeolocationClientMock();
virtual ~GeolocationClientMock();
void setController(GeolocationController*);
void setPosition(PassRefPtr<GeolocationPosition>);
void setPositionUnavailableError(const String& errorMessage);
void setPermission(bool allowed);
int numberOfPendingPermissionRequests() const;
virtual void geolocationDestroyed() OVERRIDE;
virtual void startUpdating() OVERRIDE;
virtual void stopUpdating() OVERRIDE;
virtual void setEnableHighAccuracy(bool) OVERRIDE;
virtual GeolocationPosition* lastPosition() OVERRIDE;
virtual void requestPermission(Geolocation*) OVERRIDE;
virtual void cancelPermissionRequest(Geolocation*) OVERRIDE;
private:
void asyncUpdateController();
void controllerTimerFired(Timer<GeolocationClientMock>*);
void asyncUpdatePermission();
void permissionTimerFired(Timer<GeolocationClientMock>*);
void clearError();
GeolocationController* m_controller;
RefPtr<GeolocationPosition> m_lastPosition;
bool m_hasError;
String m_errorMessage;
Timer<GeolocationClientMock> m_controllerTimer;
Timer<GeolocationClientMock> m_permissionTimer;
bool m_isActive;
enum PermissionState {
PermissionStateUnset,
PermissionStateAllowed,
PermissionStateDenied
};
PermissionState m_permissionState;
typedef WillBePersistentHeapHashSet<RefPtrWillBeMember<Geolocation> > GeolocationSet;
GeolocationSet m_pendingPermissions;
};
}
#endif