OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ScreenOrientation_h |
| 6 #define ScreenOrientation_h |
| 7 |
| 8 #include "core/dom/ActiveDOMObject.h" |
| 9 #include "core/events/EventTarget.h" |
| 10 #include "core/frame/DOMWindowProperty.h" |
| 11 #include "core/page/PageLifecycleObserver.h" |
| 12 #include "platform/Supplementable.h" |
| 13 #include "platform/Timer.h" |
| 14 #include "wtf/Vector.h" |
| 15 #include "wtf/text/AtomicString.h" |
| 16 #include "wtf/text/WTFString.h" |
| 17 |
| 18 namespace WebCore { |
| 19 |
| 20 class Frame; |
| 21 class Page; |
| 22 class Screen; |
| 23 |
| 24 enum ScreenOrientationValue { |
| 25 OrientationInvalid = 0, |
| 26 OrientationPortraitPrimary = 1, |
| 27 OrientationLandscapePrimary = 1 << 1, |
| 28 OrientationPortraitSecondary = 1 << 2, |
| 29 OrientationLandscapeSecondary = 1 << 3, |
| 30 OrientationPortrait = OrientationPortraitPrimary | OrientationPortraitSecond
ary, |
| 31 OrientationLandscape = OrientationLandscapePrimary | OrientationLandscapeSec
ondary, |
| 32 OrientationAny = OrientationPortrait | OrientationLandscape |
| 33 }; |
| 34 typedef unsigned char ScreenOrientationValues; |
| 35 |
| 36 class ScreenOrientation FINAL : public Supplement<Screen>, public DOMWindowPrope
rty, public PageLifecycleObserver, public ActiveDOMObject { |
| 37 public: |
| 38 static ScreenOrientation* from(Screen*); |
| 39 virtual ~ScreenOrientation(); |
| 40 |
| 41 DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(orientationchange); |
| 42 |
| 43 static const AtomicString& orientation(Screen*); |
| 44 static bool lockOrientation(Screen*, const Vector<String>& orientations); |
| 45 static bool lockOrientation(Screen*, const AtomicString& orientation); |
| 46 static void unlockOrientation(Screen*); |
| 47 |
| 48 void orientationChanged(); |
| 49 |
| 50 private: |
| 51 explicit ScreenOrientation(Screen*); |
| 52 static const char* supplementName(); |
| 53 |
| 54 // PageLifecycleObserver API. |
| 55 virtual void didCommitLoad(Frame*) OVERRIDE; |
| 56 |
| 57 // DOMWindowProperty API |
| 58 virtual void willDestroyGlobalObjectInFrame() OVERRIDE; |
| 59 virtual void willDetachGlobalObjectFromFrame() OVERRIDE; |
| 60 |
| 61 // ActiveDOMObject. |
| 62 virtual void stop() OVERRIDE; |
| 63 |
| 64 Page* page() const; |
| 65 |
| 66 static const AtomicString& orientationToString(ScreenOrientationValue); |
| 67 static ScreenOrientationValues stringToOrientationValues(const AtomicString&
); |
| 68 |
| 69 void orientationLockTimerFired(Timer<ScreenOrientation>*); |
| 70 void lockOrientationAsync(ScreenOrientationValues orientations); |
| 71 void unlockOrientation(); |
| 72 |
| 73 Screen* m_screen; |
| 74 Timer<ScreenOrientation> m_orientationLockTimer; |
| 75 ScreenOrientationValues m_lockedOrientations; |
| 76 |
| 77 friend class InternalsScreenOrientation; |
| 78 }; |
| 79 |
| 80 } // namespace WebCore |
| 81 |
| 82 #endif // ScreenOrientation_h |
OLD | NEW |