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.
5 #ifndef ScreenOrientationController_h
6 #define ScreenOrientationController_h
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"
18 class ScreenOrientation;
19 class WebScreenOrientationClient;
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);
28 virtual ~ScreenOrientationController();
30 virtual void persistentHostHasBeenDestroyed() OVERRIDE;
32 void setOrientation(ScreenOrientation*);
33 void notifyOrientationChanged();
35 void lock(WebScreenOrientationLockType, WebLockOrientationCallback*);
38 const LocalFrame& frame() const;
40 static void provideTo(LocalFrame&, WebScreenOrientationClient*);
41 static ScreenOrientationController* from(LocalFrame&);
42 static const char* supplementName();
44 virtual void trace(Visitor*);
47 explicit ScreenOrientationController(LocalFrame&, WebScreenOrientationClient*);
48 static WebScreenOrientationType computeOrientation(FrameView*);
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;
57 void notifyDispatcher();
59 void updateOrientation();
61 void dispatchEventTimerFired(Timer<ScreenOrientationController>*);
63 PersistentWillBeMember<ScreenOrientation> m_orientation;
64 WebScreenOrientationClient* m_client;
66 Timer<ScreenOrientationController> m_dispatchEventTimer;
71 #endif // ScreenOrientationController_h