Index: Source/modules/screen_orientation/ScreenOrientation.h |
diff --git a/Source/modules/screen_orientation/ScreenOrientation.h b/Source/modules/screen_orientation/ScreenOrientation.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..af9cd350550df3437990a496b6b2df9f64efd326 |
--- /dev/null |
+++ b/Source/modules/screen_orientation/ScreenOrientation.h |
@@ -0,0 +1,82 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ScreenOrientation_h |
+#define ScreenOrientation_h |
+ |
+#include "core/dom/ActiveDOMObject.h" |
+#include "core/events/EventTarget.h" |
+#include "core/frame/DOMWindowProperty.h" |
+#include "core/page/PageLifecycleObserver.h" |
+#include "platform/Supplementable.h" |
+#include "platform/Timer.h" |
+#include "wtf/Vector.h" |
+#include "wtf/text/AtomicString.h" |
+#include "wtf/text/WTFString.h" |
+ |
+namespace WebCore { |
+ |
+class Frame; |
+class Page; |
+class Screen; |
+ |
+enum ScreenOrientationValue { |
+ OrientationInvalid = 0, |
+ OrientationPortraitPrimary = 1, |
+ OrientationLandscapePrimary = 1 << 1, |
+ OrientationPortraitSecondary = 1 << 2, |
+ OrientationLandscapeSecondary = 1 << 3, |
+ OrientationPortrait = OrientationPortraitPrimary | OrientationPortraitSecondary, |
+ OrientationLandscape = OrientationLandscapePrimary | OrientationLandscapeSecondary, |
+ OrientationAny = OrientationPortrait | OrientationLandscape |
+}; |
+typedef unsigned char ScreenOrientationValues; |
+ |
+class ScreenOrientation FINAL : public Supplement<Screen>, public DOMWindowProperty, public PageLifecycleObserver, public ActiveDOMObject { |
+public: |
+ static ScreenOrientation* from(Screen*); |
+ virtual ~ScreenOrientation(); |
+ |
+ DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(orientationchange); |
+ |
+ static const AtomicString& orientation(Screen*); |
+ static bool lockOrientation(Screen*, const Vector<String>& orientations); |
+ static bool lockOrientation(Screen*, const AtomicString& orientation); |
+ static void unlockOrientation(Screen*); |
+ |
+ void orientationChanged(); |
+ |
+private: |
+ explicit ScreenOrientation(Screen*); |
+ static const char* supplementName(); |
+ |
+ // PageLifecycleObserver API. |
+ virtual void didCommitLoad(Frame*) OVERRIDE; |
+ |
+ // DOMWindowProperty API |
+ virtual void willDestroyGlobalObjectInFrame() OVERRIDE; |
+ virtual void willDetachGlobalObjectFromFrame() OVERRIDE; |
+ |
+ // ActiveDOMObject. |
+ virtual void stop() OVERRIDE; |
+ |
+ Page* page() const; |
+ |
+ static const AtomicString& orientationToString(ScreenOrientationValue); |
+ static ScreenOrientationValues stringToOrientationValues(const AtomicString&); |
+ |
+ void orientationLockTimerFired(Timer<ScreenOrientation>*); |
+ void lockOrientationAsync(ScreenOrientationValues orientations); |
+ void unlockOrientation(); |
+ |
+ Screen* m_screen; |
+ Timer<ScreenOrientation> m_orientationLockTimer; |
+ ScreenOrientationValues m_lockedOrientations; |
+ |
+ friend class InternalsScreenOrientation; |
+}; |
+ |
+} // namespace WebCore |
+ |
+#endif // ScreenOrientation_h |