#ifndef UserGestureIndicator_h
#define UserGestureIndicator_h
#include "platform/PlatformExport.h"
#include "wtf/Noncopyable.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
namespace WebCore {
class UserGestureIndicator;
enum ProcessingUserGestureState {
DefinitelyProcessingNewUserGesture,
DefinitelyProcessingUserGesture,
PossiblyProcessingUserGesture,
DefinitelyNotProcessingUserGesture
};
class PLATFORM_EXPORT UserGestureToken : public RefCounted<UserGestureToken> {
public:
virtual ~UserGestureToken() { }
virtual bool hasGestures() const = 0;
virtual void setOutOfProcess() = 0;
virtual void setJavascriptPrompt() = 0;
};
class PLATFORM_EXPORT UserGestureIndicatorDisabler {
WTF_MAKE_NONCOPYABLE(UserGestureIndicatorDisabler);
public:
UserGestureIndicatorDisabler();
~UserGestureIndicatorDisabler();
private:
ProcessingUserGestureState m_savedState;
UserGestureIndicator* m_savedIndicator;
};
class PLATFORM_EXPORT UserGestureIndicator {
WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
friend class UserGestureIndicatorDisabler;
public:
static bool processingUserGesture();
static bool consumeUserGesture();
static UserGestureToken* currentToken();
explicit UserGestureIndicator(ProcessingUserGestureState);
explicit UserGestureIndicator(PassRefPtr<UserGestureToken>);
~UserGestureIndicator();
private:
static ProcessingUserGestureState s_state;
static UserGestureIndicator* s_topmostIndicator;
ProcessingUserGestureState m_previousState;
RefPtr<UserGestureToken> m_token;
};
}
#endif