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