OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ScreenOrientationController_h | 5 #ifndef ScreenOrientationController_h |
6 #define ScreenOrientationController_h | 6 #define ScreenOrientationController_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "platform/Supplementable.h" | 10 #include "platform/Supplementable.h" |
11 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp
e.h" | 11 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp
e.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class WebLockOrientationCallback; | 15 class WebLockOrientationCallback; |
16 | 16 |
17 // ScreenOrientationController allows to manipulate screen orientation in Blink | 17 // ScreenOrientationController allows to manipulate screen orientation in Blink |
18 // outside of the screen_orientation/ modules. It is an interface that the | 18 // outside of the screen_orientation/ modules. It is an interface that the |
19 // module will implement and add a provider for. | 19 // module will implement and add a provider for. |
20 // Callers of ScreenOrientationController::from() should always assume the | 20 // Callers of ScreenOrientationController::from() should always assume the |
21 // returned pointer can be nullptr. | 21 // returned pointer can be nullptr. |
22 class CORE_EXPORT ScreenOrientationController : public Supplement<LocalFrame> { | 22 class CORE_EXPORT ScreenOrientationController |
| 23 : public GarbageCollectedFinalized<ScreenOrientationController>, |
| 24 public Supplement<LocalFrame> { |
| 25 USING_GARBAGE_COLLECTED_MIXIN(ScreenOrientationController); |
| 26 |
23 public: | 27 public: |
24 virtual ~ScreenOrientationController() = default; | 28 virtual ~ScreenOrientationController() = default; |
25 | 29 |
26 static ScreenOrientationController* from(LocalFrame&); | 30 static ScreenOrientationController* from(LocalFrame&); |
27 | 31 |
28 virtual void lock(WebScreenOrientationLockType, | 32 virtual void lock(WebScreenOrientationLockType, |
29 std::unique_ptr<WebLockOrientationCallback>) = 0; | 33 std::unique_ptr<WebLockOrientationCallback>) = 0; |
30 virtual void unlock() = 0; | 34 virtual void unlock() = 0; |
31 | 35 |
32 // Returns whether a lock() call was made without an unlock() call. Others | 36 // Returns whether a lock() call was made without an unlock() call. Others |
33 // frames might have changed the lock state so this should only be used to | 37 // frames might have changed the lock state so this should only be used to |
34 // know whether the current frame made an attempt to lock without explicitly | 38 // know whether the current frame made an attempt to lock without explicitly |
35 // unlocking. | 39 // unlocking. |
36 virtual bool maybeHasActiveLock() const = 0; | 40 virtual bool maybeHasActiveLock() const = 0; |
37 | 41 |
38 DECLARE_VIRTUAL_TRACE(); | 42 DECLARE_VIRTUAL_TRACE(); |
39 | 43 |
40 protected: | 44 protected: |
| 45 explicit ScreenOrientationController(LocalFrame&); |
41 // To be called by an ScreenOrientationController to register its | 46 // To be called by an ScreenOrientationController to register its |
42 // implementation. | 47 // implementation. |
43 static void provideTo(LocalFrame&, ScreenOrientationController*); | 48 static void provideTo(LocalFrame&, ScreenOrientationController*); |
44 | 49 |
45 private: | 50 private: |
46 static const char* supplementName(); | 51 static const char* supplementName(); |
47 }; | 52 }; |
48 | 53 |
49 } // namespace blink | 54 } // namespace blink |
50 | 55 |
51 #endif // ScreenOrientationController_h | 56 #endif // ScreenOrientationController_h |
OLD | NEW |