#ifndef NavigatorVibration_h
#define NavigatorVibration_h
#include "core/page/Page.h"
#include "core/page/PageLifecycleObserver.h"
#include "platform/Timer.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Vector.h"
namespace WebCore {
class LocalFrame;
class Navigator;
class NavigatorVibration FINAL
: public Supplement<Page>
, public PageLifecycleObserver {
public:
typedef Vector<unsigned> VibrationPattern;
virtual ~NavigatorVibration();
bool vibrate(const VibrationPattern&);
void cancelVibration();
void timerStartFired(Timer<NavigatorVibration>*);
void timerStopFired(Timer<NavigatorVibration>*);
virtual void pageVisibilityChanged() OVERRIDE;
virtual void didCommitLoad(LocalFrame*) OVERRIDE;
static bool vibrate(Navigator&, unsigned time);
static bool vibrate(Navigator&, const VibrationPattern&);
static NavigatorVibration& from(Page&);
bool isVibrating() const { return m_isVibrating; }
VibrationPattern pattern() const { return m_pattern; }
private:
explicit NavigatorVibration(Page&);
static const char* supplementName();
Timer<NavigatorVibration> m_timerStart;
Timer<NavigatorVibration> m_timerStop;
bool m_isVibrating;
VibrationPattern m_pattern;
};
}
#endif