| 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/events/EventListener.h" | 8 #include "core/events/EventListener.h" |
| 9 #include "modules/ModulesExport.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 // `MediaControlsImpl` when the feature applies. Once created, it will use |
| 20 // change state. | 20 // events to change state. |
| 21 // | 21 // |
| 22 // The different states of the class are: | 22 // The different states of the class are: |
| 23 // - PendingFullscreen: the object is created and is waiting for the associated | 23 // - PendingFullscreen: the object is created and is waiting for the associated |
| 24 // <video> to go fullscreen in order to apply an orientation lock; | 24 // <video> to go fullscreen in order to apply an orientation lock; |
| 25 // - PendingMetadata: the <video> is fullscreen but the metadata have not been | 25 // - PendingMetadata: the <video> is fullscreen but the metadata have not been |
| 26 // downloaded yet. It can happen because of network latency or because the | 26 // downloaded yet. It can happen because of network latency or because the |
| 27 // <video> went fullscreen before playback and download started; | 27 // <video> went fullscreen before playback and download started; |
| 28 // - MaybeLockedFullscreen: the <video> is fullscreen and a screen orientation | 28 // - MaybeLockedFullscreen: the <video> is fullscreen and a screen orientation |
| 29 // lock was applied. | 29 // lock was applied. |
| 30 // | 30 // |
| 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 MediaControlsOrientationLockDelegate final : public EventListener { | 41 class MediaControlsOrientationLockDelegate final : public EventListener { |
| 42 public: | 42 public: |
| 43 explicit MediaControlsOrientationLockDelegate(HTMLVideoElement&); | 43 explicit MediaControlsOrientationLockDelegate(HTMLVideoElement&); |
| 44 | 44 |
| 45 // Called by MediaControls when the HTMLMediaElement is added to a document | 45 // Called by MediaControlsImpl when the HTMLMediaElement is added to a |
| 46 // document. All event listeners should be added. | 46 // document. All event listeners should be added. |
| 47 void Attach(); | 47 void Attach(); |
| 48 | 48 |
| 49 // Called by MediaControls when the HTMLMediaElement is no longer in the | 49 // Called by MediaControlsImpl when the HTMLMediaElement is no longer in the |
| 50 // 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 |
| 51 // object to be garbage collected. | 51 // object to be garbage collected. |
| 52 void Detach(); | 52 void Detach(); |
| 53 | 53 |
| 54 // EventListener implementation. | 54 // EventListener implementation. |
| 55 bool operator==(const EventListener&) const override; | 55 bool operator==(const EventListener&) const override; |
| 56 | 56 |
| 57 DECLARE_VIRTUAL_TRACE(); | 57 DECLARE_VIRTUAL_TRACE(); |
| 58 | 58 |
| 59 private: | 59 private: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 85 void MaybeUnlockOrientation(); | 85 void MaybeUnlockOrientation(); |
| 86 | 86 |
| 87 // 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 |
| 88 // detailed description. | 88 // detailed description. |
| 89 State state_ = State::kPendingFullscreen; | 89 State state_ = State::kPendingFullscreen; |
| 90 | 90 |
| 91 // Whether the controls should unlock the screen orientation when possible. | 91 // Whether the controls should unlock the screen orientation when possible. |
| 92 // In other words, whether the orientation was locked. | 92 // In other words, whether the orientation was locked. |
| 93 bool should_unlock_orientation_ = false; | 93 bool should_unlock_orientation_ = false; |
| 94 | 94 |
| 95 // `m_videoElement` owns MediaControls that owns |this|. | 95 // `video_element_` owns MediaControlsImpl that owns |this|. |
| 96 Member<HTMLVideoElement> video_element_; | 96 Member<HTMLVideoElement> video_element_; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 } // namespace blink | 99 } // namespace blink |
| 100 | 100 |
| 101 #endif // MediaControlsOrientationLockDelegate_h | 101 #endif // MediaControlsOrientationLockDelegate_h |
| OLD | NEW |