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