Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(765)

Side by Side Diff: Source/modules/screen_orientation/ScreenOrientation.h

Issue 132113006: Add initial Blink-side support for the Screen Orientation API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add Kenneth as OWNER Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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);
kenneth.r.christiansen 2014/02/12 13:42:37 I wonder if you some way need to know which orient
Inactive 2014/02/12 16:03:11 This would mean having lockOrientation() request C
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698