OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Samsung Electronics | 2 * Copyright (C) 2012 Samsung Electronics |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #ifndef Vibration_h | 20 #ifndef Vibration_h |
21 #define Vibration_h | 21 #define Vibration_h |
22 | 22 |
23 #if ENABLE(VIBRATION) | |
24 | |
25 #include "core/page/Page.h" | 23 #include "core/page/Page.h" |
26 #include "core/platform/Timer.h" | 24 #include "core/platform/Timer.h" |
27 #include "wtf/PassOwnPtr.h" | 25 #include "wtf/PassOwnPtr.h" |
28 | 26 |
29 namespace WebCore { | 27 namespace WebCore { |
30 | 28 |
31 class VibrationClient; | |
32 | |
33 class Vibration : public Supplement<Page> { | 29 class Vibration : public Supplement<Page> { |
34 public: | 30 public: |
35 typedef Vector<unsigned> VibrationPattern; | 31 typedef Vector<unsigned> VibrationPattern; |
36 | 32 |
37 explicit Vibration(VibrationClient*); | |
38 ~Vibration(); | 33 ~Vibration(); |
39 | 34 |
40 static PassOwnPtr<Vibration> create(VibrationClient*); | 35 static PassOwnPtr<Vibration> create(); |
41 | 36 |
42 void vibrate(const unsigned& time); | 37 void vibrate(const unsigned& time); |
43 void vibrate(const VibrationPattern&); | 38 void vibrate(const VibrationPattern&); |
44 void cancelVibration(); | 39 void cancelVibration(); |
45 | 40 |
46 // FIXME : Add suspendVibration() and resumeVibration() to the page visibili ty feature, when the document.hidden attribute is changed. | 41 // FIXME : Add suspendVibration() and resumeVibration() to the page visibili ty feature, when the document.hidden attribute is changed. |
47 void suspendVibration(); | 42 void suspendVibration(); |
48 void resumeVibration(); | 43 void resumeVibration(); |
49 void timerStartFired(Timer<Vibration>*); | 44 void timerStartFired(Timer<Vibration>*); |
50 void timerStopFired(Timer<Vibration>*); | 45 void timerStopFired(Timer<Vibration>*); |
51 | 46 |
52 static const char* supplementName(); | 47 static const char* supplementName(); |
53 static Vibration* from(Page* page) { return static_cast<Vibration*>(Suppleme nt<Page>::from(page, supplementName())); } | 48 static Vibration* from(Page* page) { return static_cast<Vibration*>(Suppleme nt<Page>::from(page, supplementName())); } |
54 static bool isActive(Page*); | 49 static bool isActive(Page*); |
55 | 50 |
56 private: | 51 private: |
57 VibrationClient* m_vibrationClient; | 52 Vibration(); |
58 Timer<Vibration> m_timerStart; | 53 Timer<Vibration> m_timerStart; |
59 Timer<Vibration> m_timerStop; | 54 Timer<Vibration> m_timerStop; |
60 bool m_isVibrating; | 55 bool m_isVibrating; |
61 VibrationPattern m_pattern; | 56 VibrationPattern m_pattern; |
62 }; | 57 }; |
63 | 58 |
59 void provideVibrationTo(Page*); | |
Peter Beverloo
2013/06/11 10:19:10
Since we already have three methods related to sup
Michael van Ouwerkerk
2013/06/11 13:26:51
Much nicer. Done.
| |
60 | |
64 } // namespace WebCore | 61 } // namespace WebCore |
65 | 62 |
66 #endif // ENABLE(VIBRATION) | |
67 | |
68 #endif // Vibration_h | 63 #endif // Vibration_h |
69 | |
OLD | NEW |