| 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 MediaControlsOrientationLockDelegate_h | 5 #ifndef MediaControlsOrientationLockDelegate_h |
| 6 #define MediaControlsOrientationLockDelegate_h | 6 #define MediaControlsOrientationLockDelegate_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | |
| 9 #include "core/events/EventListener.h" | 8 #include "core/events/EventListener.h" |
| 9 #include "modules/ModulesExport.h" |
| 10 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp
e.h" | 10 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp
e.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class Document; | 14 class Document; |
| 15 class HTMLVideoElement; | 15 class HTMLVideoElement; |
| 16 | 16 |
| 17 // MediaControlsOrientationLockDelegate is implementing the orientation lock | 17 // MediaControlsOrientationLockDelegate is implementing the orientation lock |
| 18 // feature when a <video> is fullscreen. It is meant to be created by | 18 // feature when a <video> is fullscreen. It is meant to be created by |
| 19 // `MediaControls` when the feature applies. Once created, it will use events to | 19 // `MediaControls` when the feature applies. Once created, it will use events to |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 // The possible state transitions are: | 31 // The possible state transitions are: |
| 32 // - PendingFullscreen => PendingMetadata: on fullscreenchange event (entering | 32 // - PendingFullscreen => PendingMetadata: on fullscreenchange event (entering |
| 33 // fullscreen) when metadata are not available; | 33 // fullscreen) when metadata are not available; |
| 34 // - PendingFullscreen => MaybeLockedFullscreen: on fullscreenchange event | 34 // - PendingFullscreen => MaybeLockedFullscreen: on fullscreenchange event |
| 35 // (entering fullscreen) when metadata are available; | 35 // (entering fullscreen) when metadata are available; |
| 36 // - PendingMetadata => MaybeLockedFullscreen: on loadedmetadata; | 36 // - PendingMetadata => MaybeLockedFullscreen: on loadedmetadata; |
| 37 // - PendingMetadata => PendingFullscreen: on fullscreenchange event (leaving | 37 // - PendingMetadata => PendingFullscreen: on fullscreenchange event (leaving |
| 38 // fullscreen); | 38 // fullscreen); |
| 39 // - MaybeLockedFullscreen => PendingFullscreen: on fullscreenchange event | 39 // - MaybeLockedFullscreen => PendingFullscreen: on fullscreenchange event |
| 40 // (leaving fullscreen). | 40 // (leaving fullscreen). |
| 41 class CORE_EXPORT MediaControlsOrientationLockDelegate final | 41 class MediaControlsOrientationLockDelegate final : public EventListener { |
| 42 : public EventListener { | |
| 43 public: | 42 public: |
| 44 explicit MediaControlsOrientationLockDelegate(HTMLVideoElement&); | 43 explicit MediaControlsOrientationLockDelegate(HTMLVideoElement&); |
| 45 | 44 |
| 46 // Called by MediaControls when the HTMLMediaElement is added to a document | 45 // Called by MediaControls when the HTMLMediaElement is added to a document |
| 47 // document. All event listeners should be added. | 46 // document. All event listeners should be added. |
| 48 void attach(); | 47 void attach(); |
| 49 | 48 |
| 50 // Called by MediaControls when the HTMLMediaElement is no longer in the | 49 // Called by MediaControls when the HTMLMediaElement is no longer in the |
| 51 // document. All event listeners should be removed in order to prepare the | 50 // document. All event listeners should be removed in order to prepare the |
| 52 // object to be garbage collected. | 51 // object to be garbage collected. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 // EventListener implementation. | 68 // EventListener implementation. |
| 70 void handleEvent(ExecutionContext*, Event*) override; | 69 void handleEvent(ExecutionContext*, Event*) override; |
| 71 | 70 |
| 72 HTMLVideoElement& videoElement() const; | 71 HTMLVideoElement& videoElement() const; |
| 73 Document& document() const; | 72 Document& document() const; |
| 74 | 73 |
| 75 // Returns the orientation in which the video should be locked based on its | 74 // Returns the orientation in which the video should be locked based on its |
| 76 // size. | 75 // size. |
| 77 WebScreenOrientationLockType computeOrientationLock() const; | 76 MODULES_EXPORT WebScreenOrientationLockType computeOrientationLock() const; |
| 78 | 77 |
| 79 // Locks the screen orientation if the video has metadata information | 78 // Locks the screen orientation if the video has metadata information |
| 80 // available. Delays locking orientation until metadata are available | 79 // available. Delays locking orientation until metadata are available |
| 81 // otherwise. | 80 // otherwise. |
| 82 void maybeLockOrientation(); | 81 void maybeLockOrientation(); |
| 83 | 82 |
| 84 // Unlocks the screen orientation if the screen orientation was previously | 83 // Unlocks the screen orientation if the screen orientation was previously |
| 85 // locked. | 84 // locked. |
| 86 void maybeUnlockOrientation(); | 85 void maybeUnlockOrientation(); |
| 87 | 86 |
| 88 // Current state of the object. See comment at the top of the file for a | 87 // Current state of the object. See comment at the top of the file for a |
| 89 // detailed description. | 88 // detailed description. |
| 90 State m_state = State::PendingFullscreen; | 89 State m_state = State::PendingFullscreen; |
| 91 | 90 |
| 92 // Whether the controls should unlock the screen orientation when possible. | 91 // Whether the controls should unlock the screen orientation when possible. |
| 93 // In other words, whether the orientation was locked. | 92 // In other words, whether the orientation was locked. |
| 94 bool m_shouldUnlockOrientation = false; | 93 bool m_shouldUnlockOrientation = false; |
| 95 | 94 |
| 96 // `m_videoElement` owns MediaControls that owns |this|. | 95 // `m_videoElement` owns MediaControls that owns |this|. |
| 97 Member<HTMLVideoElement> m_videoElement; | 96 Member<HTMLVideoElement> m_videoElement; |
| 98 }; | 97 }; |
| 99 | 98 |
| 100 } // namespace blink | 99 } // namespace blink |
| 101 | 100 |
| 102 #endif // MediaControlsOrientationLockDelegate_h | 101 #endif // MediaControlsOrientationLockDelegate_h |
| OLD | NEW |