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/FrameDestructionObserver.h"
9 #include "core/frame/PlatformEventController.h"
10 #include "platform/Supplementable.h"
11 #include "platform/Timer.h"
12 #include "public/platform/WebLockOrientationCallback.h"
13 #include "public/platform/WebScreenOrientationLockType.h"
14 #include "public/platform/WebScreenOrientationType.h"
19 class ScreenOrientation;
20 class WebScreenOrientationClient;
22 class ScreenOrientationController FINAL
23 : public NoBaseWillBeGarbageCollectedFinalized<ScreenOrientationController>
24 , public WillBeHeapSupplement<LocalFrame>
25 , public FrameDestructionObserver
26 , public PlatformEventController {
27 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ScreenOrientationController);
28 WTF_MAKE_NONCOPYABLE(ScreenOrientationController);
30 virtual ~ScreenOrientationController();
32 void setOrientation(ScreenOrientation*);
33 void notifyOrientationChanged();
35 void lock(WebScreenOrientationLockType, WebLockOrientationCallback*);
38 static void provideTo(LocalFrame&, WebScreenOrientationClient*);
39 static ScreenOrientationController* from(LocalFrame&);
40 static const char* supplementName();
42 virtual void trace(Visitor*) OVERRIDE;
45 explicit ScreenOrientationController(LocalFrame&, WebScreenOrientationClient*);
46 static WebScreenOrientationType computeOrientation(FrameView*);
48 // Inherited from PlatformEventController.
49 virtual void didUpdateData() OVERRIDE;
50 virtual void registerWithDispatcher() OVERRIDE;
51 virtual void unregisterWithDispatcher() OVERRIDE;
52 virtual bool hasLastData() OVERRIDE;
53 virtual void pageVisibilityChanged() OVERRIDE;
55 // Inherited from FrameDestructionObserver.
56 virtual void willDetachFrameHost() override;
58 void notifyDispatcher();
60 void updateOrientation();
62 void dispatchEventTimerFired(Timer<ScreenOrientationController>*);
64 bool isActiveAndVisible() const;
66 PersistentWillBeMember<ScreenOrientation> m_orientation;
67 WebScreenOrientationClient* m_client;
68 Timer<ScreenOrientationController> m_dispatchEventTimer;
73 #endif // ScreenOrientationController_h