| 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 NavigatorVibration_h | 20 #ifndef NavigatorVibration_h |
| 21 #define NavigatorVibration_h | 21 #define NavigatorVibration_h |
| 22 | 22 |
| 23 #include "core/frame/DOMWindowProperty.h" | 23 #include "core/dom/ContextLifecycleObserver.h" |
| 24 #include "modules/ModulesExport.h" | 24 #include "modules/ModulesExport.h" |
| 25 #include "platform/Supplementable.h" | 25 #include "platform/Supplementable.h" |
| 26 #include "platform/heap/GarbageCollected.h" | 26 #include "platform/heap/GarbageCollected.h" |
| 27 #include "platform/heap/Handle.h" | 27 #include "platform/heap/Handle.h" |
| 28 #include "wtf/Noncopyable.h" | 28 #include "wtf/Noncopyable.h" |
| 29 #include "wtf/Vector.h" | 29 #include "wtf/Vector.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 class LocalFrame; |
| 33 class Navigator; | 34 class Navigator; |
| 34 class VibrationController; | 35 class VibrationController; |
| 35 | 36 |
| 36 enum NavigatorVibrationType { | 37 enum NavigatorVibrationType { |
| 37 MainFrameNoUserGesture = 0, | 38 MainFrameNoUserGesture = 0, |
| 38 MainFrameWithUserGesture = 1, | 39 MainFrameWithUserGesture = 1, |
| 39 SameOriginSubFrameNoUserGesture = 2, | 40 SameOriginSubFrameNoUserGesture = 2, |
| 40 SameOriginSubFrameWithUserGesture = 3, | 41 SameOriginSubFrameWithUserGesture = 3, |
| 41 CrossOriginSubFrameNoUserGesture = 4, | 42 CrossOriginSubFrameNoUserGesture = 4, |
| 42 CrossOriginSubFrameWithUserGesture = 5, | 43 CrossOriginSubFrameWithUserGesture = 5, |
| 43 EnumMax = 6 | 44 EnumMax = 6 |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 class MODULES_EXPORT NavigatorVibration final | 47 class MODULES_EXPORT NavigatorVibration final |
| 47 : public GarbageCollectedFinalized<NavigatorVibration> | 48 : public GarbageCollectedFinalized<NavigatorVibration> |
| 48 , public Supplement<Navigator> | 49 , public Supplement<Navigator> |
| 49 , public DOMWindowProperty { | 50 , public ContextLifecycleObserver { |
| 50 USING_GARBAGE_COLLECTED_MIXIN(NavigatorVibration); | 51 USING_GARBAGE_COLLECTED_MIXIN(NavigatorVibration); |
| 51 WTF_MAKE_NONCOPYABLE(NavigatorVibration); | 52 WTF_MAKE_NONCOPYABLE(NavigatorVibration); |
| 52 public: | 53 public: |
| 53 using VibrationPattern = Vector<unsigned>; | 54 using VibrationPattern = Vector<unsigned>; |
| 54 | 55 |
| 55 virtual ~NavigatorVibration(); | 56 virtual ~NavigatorVibration(); |
| 56 | 57 |
| 57 static NavigatorVibration& from(Navigator&); | 58 static NavigatorVibration& from(Navigator&); |
| 58 | 59 |
| 59 static bool vibrate(Navigator&, unsigned time); | 60 static bool vibrate(Navigator&, unsigned time); |
| 60 static bool vibrate(Navigator&, const VibrationPattern&); | 61 static bool vibrate(Navigator&, const VibrationPattern&); |
| 61 | 62 |
| 62 VibrationController* controller(); | 63 VibrationController* controller(const LocalFrame&); |
| 63 | 64 |
| 64 DECLARE_VIRTUAL_TRACE(); | 65 DECLARE_VIRTUAL_TRACE(); |
| 65 | 66 |
| 66 private: | 67 private: |
| 67 static const char* supplementName(); | 68 static const char* supplementName(); |
| 68 | 69 |
| 69 explicit NavigatorVibration(Navigator&); | 70 explicit NavigatorVibration(Navigator&); |
| 70 | 71 |
| 71 // Inherited from DOMWindowProperty. | 72 // Inherited from ContextLifecycleObserver. |
| 72 void willDetachGlobalObjectFromFrame() override; | 73 void contextDestroyed() override; |
| 73 | 74 |
| 74 static void collectHistogramMetrics(const LocalFrame&); | 75 static void collectHistogramMetrics(const LocalFrame&); |
| 75 | 76 |
| 76 Member<VibrationController> m_controller; | 77 Member<VibrationController> m_controller; |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 } // namespace blink | 80 } // namespace blink |
| 80 | 81 |
| 81 #endif // NavigatorVibration_h | 82 #endif // NavigatorVibration_h |
| OLD | NEW |