Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsOrientationLockDelegate.h

Issue 2890423003: [Media controls] Integrate rotate-to-fullscreen with orientation lock (Closed)
Patch Set: Fix existing tests Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "device/screen_orientation/public/interfaces/screen_orientation.mojom-b link.h"
9 #include "modules/ModulesExport.h" 10 #include "modules/ModulesExport.h"
10 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp e.h" 11 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp e.h"
11 12
12 namespace blink { 13 namespace blink {
13 14
15 class DeviceOrientationEvent;
14 class Document; 16 class Document;
15 class HTMLVideoElement; 17 class HTMLVideoElement;
16 18
17 // MediaControlsOrientationLockDelegate is implementing the orientation lock 19 // MediaControlsOrientationLockDelegate is implementing the orientation lock
18 // feature when a <video> is fullscreen. It is meant to be created by 20 // feature when a <video> is fullscreen. It is meant to be created by
19 // `MediaControlsImpl` when the feature applies. Once created, it will use 21 // `MediaControlsImpl` when the feature applies. Once created, it will use
20 // events to change state. 22 // events to change state.
21 // 23 //
24 // The behavior depends on whether MediaControlsRotateToFullscreenDelegate is
25 // enabled. If it is enabled and the user has not locked the screen orientation
26 // at the OS level, then the orientation lock is only held until the user
27 // rotates their device to match the orientation of the video; otherwise it is
28 // held until fullscreen is exited.
29 //
22 // The different states of the class are: 30 // The different states of the class are:
23 // - PendingFullscreen: the object is created and is waiting for the associated 31 // - PendingFullscreen: the object is created and it is either waiting for the
24 // <video> to go fullscreen in order to apply an orientation lock; 32 // associated <video> to go fullscreen in order to apply an orientation lock,
33 // or it already went fullscreen then the lock was unlocked since the user
34 // rotated their device, and now it is waiting until fullscreen is re-entered;
25 // - PendingMetadata: the <video> is fullscreen but the metadata have not been 35 // - PendingMetadata: the <video> is fullscreen but the metadata have not been
26 // downloaded yet. It can happen because of network latency or because the 36 // downloaded yet. It can happen because of network latency or because the
27 // <video> went fullscreen before playback and download started; 37 // <video> went fullscreen before playback and download started;
28 // - MaybeLockedFullscreen: the <video> is fullscreen and a screen orientation 38 // - MaybeLockedFullscreen: the <video> is fullscreen and a screen orientation
29 // lock was applied. 39 // lock is applied.
30 // 40 //
31 // The possible state transitions are: 41 // The possible state transitions are:
32 // - PendingFullscreen => PendingMetadata: on fullscreenchange event (entering 42 // - PendingFullscreen => PendingMetadata: on fullscreenchange event (entering
33 // fullscreen) when metadata are not available; 43 // fullscreen) when metadata are not available;
34 // - PendingFullscreen => MaybeLockedFullscreen: on fullscreenchange event 44 // - PendingFullscreen => MaybeLockedFullscreen: on fullscreenchange event
35 // (entering fullscreen) when metadata are available; 45 // (entering fullscreen) when metadata are available;
36 // - PendingMetadata => MaybeLockedFullscreen: on loadedmetadata; 46 // - PendingMetadata => MaybeLockedFullscreen: on loadedmetadata;
37 // - PendingMetadata => PendingFullscreen: on fullscreenchange event (leaving 47 // - PendingMetadata => PendingFullscreen: on fullscreenchange event (exiting
38 // fullscreen); 48 // fullscreen);
39 // - MaybeLockedFullscreen => PendingFullscreen: on fullscreenchange event 49 // - MaybeLockedFullscreen => PendingFullscreen: on fullscreenchange event
40 // (leaving fullscreen). 50 // (exiting fullscreen) or on deviceorientation event (rotated to match the
51 // orientation of the video).
41 class MediaControlsOrientationLockDelegate final : public EventListener { 52 class MediaControlsOrientationLockDelegate final : public EventListener {
42 public: 53 public:
43 explicit MediaControlsOrientationLockDelegate(HTMLVideoElement&); 54 explicit MediaControlsOrientationLockDelegate(HTMLVideoElement&);
44 55
45 // Called by MediaControlsImpl when the HTMLMediaElement is added to a 56 // Called by MediaControlsImpl when the HTMLMediaElement is added to a
46 // document. All event listeners should be added. 57 // document. All event listeners should be added.
47 void Attach(); 58 void Attach();
48 59
49 // Called by MediaControlsImpl when the HTMLMediaElement is no longer in the 60 // Called by MediaControlsImpl when the HTMLMediaElement is no longer in the
50 // document. All event listeners should be removed in order to prepare the 61 // document. All event listeners should be removed in order to prepare the
(...skipping 26 matching lines...) Expand all
77 88
78 // Locks the screen orientation if the video has metadata information 89 // Locks the screen orientation if the video has metadata information
79 // available. Delays locking orientation until metadata are available 90 // available. Delays locking orientation until metadata are available
80 // otherwise. 91 // otherwise.
81 void MaybeLockOrientation(); 92 void MaybeLockOrientation();
82 93
83 // Unlocks the screen orientation if the screen orientation was previously 94 // Unlocks the screen orientation if the screen orientation was previously
84 // locked. 95 // locked.
85 void MaybeUnlockOrientation(); 96 void MaybeUnlockOrientation();
86 97
98 void MaybeListenToDeviceOrientation();
99 void GotIsAutoRotateEnabledByUser(bool enabled);
100
101 void MaybeUnlockIfDeviceOrientationMatchesVideo(DeviceOrientationEvent*);
102
87 // Current state of the object. See comment at the top of the file for a 103 // Current state of the object. See comment at the top of the file for a
88 // detailed description. 104 // detailed description.
89 State state_ = State::kPendingFullscreen; 105 State state_ = State::kPendingFullscreen;
90 106
91 // Whether the controls should unlock the screen orientation when possible. 107 // Which lock is currently applied by this delegate.
92 // In other words, whether the orientation was locked. 108 WebScreenOrientationLockType locked_orientation_ =
93 bool should_unlock_orientation_ = false; 109 kWebScreenOrientationLockDefault /* unlocked */;
110
111 device::mojom::blink::ScreenOrientationListenerPtr monitor_;
94 112
95 // `video_element_` owns MediaControlsImpl that owns |this|. 113 // `video_element_` owns MediaControlsImpl that owns |this|.
96 Member<HTMLVideoElement> video_element_; 114 Member<HTMLVideoElement> video_element_;
97 }; 115 };
98 116
99 } // namespace blink 117 } // namespace blink
100 118
101 #endif // MediaControlsOrientationLockDelegate_h 119 #endif // MediaControlsOrientationLockDelegate_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698