Vibration.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C) 2012 Samsung Electronics
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public License
  15. * along with this library; see the file COPYING.LIB. If not, write to
  16. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef Vibration_h
  20. #define Vibration_h
  21. #if ENABLE(VIBRATION)
  22. #include "Page.h"
  23. #include "Timer.h"
  24. #include <wtf/PassOwnPtr.h>
  25. namespace WebCore {
  26. class VibrationClient;
  27. class Vibration : public Supplement<Page> {
  28. public:
  29. typedef Vector<unsigned> VibrationPattern;
  30. explicit Vibration(VibrationClient*);
  31. ~Vibration();
  32. static PassOwnPtr<Vibration> create(VibrationClient*);
  33. void vibrate(const unsigned& time);
  34. void vibrate(const VibrationPattern&);
  35. void cancelVibration();
  36. // FIXME : Add suspendVibration() and resumeVibration() to the page visibility feature, when the document.hidden attribute is changed.
  37. void suspendVibration();
  38. void resumeVibration();
  39. void timerStartFired(Timer<Vibration>*);
  40. void timerStopFired(Timer<Vibration>*);
  41. static const char* supplementName();
  42. static Vibration* from(Page* page) { return static_cast<Vibration*>(Supplement<Page>::from(page, supplementName())); }
  43. static bool isActive(Page*);
  44. private:
  45. VibrationClient* m_vibrationClient;
  46. Timer<Vibration> m_timerStart;
  47. Timer<Vibration> m_timerStop;
  48. bool m_isVibrating;
  49. VibrationPattern m_pattern;
  50. };
  51. } // namespace WebCore
  52. #endif // ENABLE(VIBRATION)
  53. #endif // Vibration_h