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 #include "config.h" | 20 #include "config.h" |
21 #include "modules/vibration/NavigatorVibration.h" | 21 #include "modules/vibration/NavigatorVibration.h" |
22 | 22 |
23 #if ENABLE(VIBRATION) | |
24 | |
25 #include "core/dom/ExceptionCode.h" | 23 #include "core/dom/ExceptionCode.h" |
26 #include "core/page/Frame.h" | 24 #include "core/page/Frame.h" |
27 #include "core/page/Navigator.h" | 25 #include "core/page/Navigator.h" |
28 #include "core/page/Page.h" | 26 #include "core/page/Page.h" |
29 #include "modules/vibration/Vibration.h" | 27 #include "modules/vibration/Vibration.h" |
30 #include "wtf/Uint32Array.h" | 28 #include "wtf/Uint32Array.h" |
31 | 29 |
32 namespace WebCore { | 30 namespace WebCore { |
33 | 31 |
34 NavigatorVibration::NavigatorVibration() | 32 NavigatorVibration::NavigatorVibration() |
35 { | 33 { |
36 } | 34 } |
37 | 35 |
38 NavigatorVibration::~NavigatorVibration() | 36 NavigatorVibration::~NavigatorVibration() |
39 { | 37 { |
40 } | 38 } |
41 | 39 |
42 void NavigatorVibration::vibrate(Navigator* navigator, unsigned time, ExceptionC ode& ec) | 40 void NavigatorVibration::vibrate(Navigator* navigator, unsigned time, ExceptionC ode& ec) |
43 { | 41 { |
44 if (!navigator->frame()->page()) | 42 if (!navigator->frame()->page()) |
45 return; | 43 return; |
46 | 44 |
47 if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidd en) | 45 if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidd en) |
48 return; | 46 return; |
49 | 47 |
50 if (!Vibration::isActive(navigator->frame()->page())) { | 48 if (!Vibration::isActive(navigator->frame()->page())) |
51 ec = NOT_SUPPORTED_ERR; | 49 provideVibrationTo(navigator->frame()->page()); |
Peter Beverloo
2013/06/11 10:19:10
navigator->frame()->page() is used five times in t
Michael van Ouwerkerk
2013/06/11 13:26:51
Done.
| |
52 return; | |
53 } | |
54 | 50 |
55 Vibration::from(navigator->frame()->page())->vibrate(time); | 51 Vibration::from(navigator->frame()->page())->vibrate(time); |
56 } | 52 } |
57 | 53 |
58 void NavigatorVibration::vibrate(Navigator* navigator, const VibrationPattern& p attern, ExceptionCode& ec) | 54 void NavigatorVibration::vibrate(Navigator* navigator, const VibrationPattern& p attern, ExceptionCode& ec) |
59 { | 55 { |
60 if (!navigator->frame()->page()) | 56 if (!navigator->frame()->page()) |
61 return; | 57 return; |
62 | 58 |
63 if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidd en) | 59 if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidd en) |
64 return; | 60 return; |
65 | 61 |
66 if (!Vibration::isActive(navigator->frame()->page())) { | 62 if (!Vibration::isActive(navigator->frame()->page())) |
67 ec = NOT_SUPPORTED_ERR; | 63 provideVibrationTo(navigator->frame()->page()); |
Peter Beverloo
2013/06/11 10:19:10
dito
Michael van Ouwerkerk
2013/06/11 13:26:51
Done.
| |
68 return; | |
69 } | |
70 | 64 |
71 Vibration::from(navigator->frame()->page())->vibrate(pattern); | 65 Vibration::from(navigator->frame()->page())->vibrate(pattern); |
72 } | 66 } |
73 | 67 |
74 } // namespace WebCore | 68 } // namespace WebCore |
75 | |
76 #endif // ENABLE(VIBRATION) | |
77 | |
OLD | NEW |