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/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" 15 16namespace blink { 17 18class FrameView; 19class ScreenOrientation; 20class WebScreenOrientationClient; 21 22class 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); 29public: 30 virtual ~ScreenOrientationController(); 31 32 void setOrientation(ScreenOrientation*); 33 void notifyOrientationChanged(); 34 35 void lock(WebScreenOrientationLockType, WebLockOrientationCallback*); 36 void unlock(); 37 38 static void provideTo(LocalFrame&, WebScreenOrientationClient*); 39 static ScreenOrientationController* from(LocalFrame&); 40 static const char* supplementName(); 41 42 virtual void trace(Visitor*) OVERRIDE; 43 44private: 45 explicit ScreenOrientationController(LocalFrame&, WebScreenOrientationClient*); 46 static WebScreenOrientationType computeOrientation(FrameView*); 47 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; 54 55 // Inherited from FrameDestructionObserver. 56 virtual void willDetachFrameHost() override; 57 58 void notifyDispatcher(); 59 60 void updateOrientation(); 61 62 void dispatchEventTimerFired(Timer<ScreenOrientationController>*); 63 64 bool isActiveAndVisible() const; 65 66 PersistentWillBeMember<ScreenOrientation> m_orientation; 67 WebScreenOrientationClient* m_client; 68 Timer<ScreenOrientationController> m_dispatchEventTimer; 69}; 70 71} // namespace blink 72 73#endif // ScreenOrientationController_h 74