Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / screen_orientation / ScreenOrientationController.h
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 ScreenOrientationController_h
6 #define ScreenOrientationController_h
7
8 #include "core/frame/PlatformEventController.h"
9 #include "platform/Supplementable.h"
10 #include "platform/Timer.h"
11 #include "public/platform/WebLockOrientationCallback.h"
12 #include "public/platform/WebScreenOrientationLockType.h"
13 #include "public/platform/WebScreenOrientationType.h"
14
15 namespace blink {
16
17 class FrameView;
18 class ScreenOrientation;
19 class WebScreenOrientationClient;
20
21 class ScreenOrientationController FINAL
22     : public NoBaseWillBeGarbageCollectedFinalized<ScreenOrientationController>
23     , public WillBeHeapSupplement<LocalFrame>
24     , public PlatformEventController {
25     WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScreenOrientationController);
26     WTF_MAKE_NONCOPYABLE(ScreenOrientationController);
27 public:
28     virtual ~ScreenOrientationController();
29
30     virtual void persistentHostHasBeenDestroyed() OVERRIDE;
31
32     void setOrientation(ScreenOrientation*);
33     void notifyOrientationChanged();
34
35     void lock(WebScreenOrientationLockType, WebLockOrientationCallback*);
36     void unlock();
37
38     const LocalFrame& frame() const;
39
40     static void provideTo(LocalFrame&, WebScreenOrientationClient*);
41     static ScreenOrientationController* from(LocalFrame&);
42     static const char* supplementName();
43
44     virtual void trace(Visitor*);
45
46 private:
47     explicit ScreenOrientationController(LocalFrame&, WebScreenOrientationClient*);
48     static WebScreenOrientationType computeOrientation(FrameView*);
49
50     // Inherited from PlatformEventController.
51     virtual void didUpdateData() OVERRIDE;
52     virtual void registerWithDispatcher() OVERRIDE;
53     virtual void unregisterWithDispatcher() OVERRIDE;
54     virtual bool hasLastData() OVERRIDE;
55     virtual void pageVisibilityChanged() OVERRIDE;
56
57     void notifyDispatcher();
58
59     void updateOrientation();
60
61     void dispatchEventTimerFired(Timer<ScreenOrientationController>*);
62
63     PersistentWillBeMember<ScreenOrientation> m_orientation;
64     WebScreenOrientationClient* m_client;
65     LocalFrame& m_frame;
66     Timer<ScreenOrientationController> m_dispatchEventTimer;
67 };
68
69 } // namespace blink
70
71 #endif // ScreenOrientationController_h