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

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

Issue 2904263002: [Media Controls] Tests for rotate-to-fullscreen meets orientation lock (Closed)
Patch Set: Address Tim's nits Created 3 years, 6 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 "device/screen_orientation/public/interfaces/screen_orientation.mojom-b link.h"
10 #include "modules/ModulesExport.h" 10 #include "modules/ModulesExport.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 DeviceOrientationData;
15 class DeviceOrientationEvent; 16 class DeviceOrientationEvent;
16 class Document; 17 class Document;
17 class HTMLVideoElement; 18 class HTMLVideoElement;
18 19
19 // MediaControlsOrientationLockDelegate is implementing the orientation lock 20 // MediaControlsOrientationLockDelegate is implementing the orientation lock
20 // feature when a <video> is fullscreen. It is meant to be created by 21 // feature when a <video> is fullscreen. It is meant to be created by
21 // `MediaControlsImpl` when the feature applies. Once created, it will use 22 // `MediaControlsImpl` when the feature applies. Once created, it will use
22 // events to change state. 23 // events to change state.
23 // 24 //
24 // The behavior depends on whether MediaControlsRotateToFullscreenDelegate is 25 // The behavior depends on whether MediaControlsRotateToFullscreenDelegate is
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // object to be garbage collected. 63 // object to be garbage collected.
63 void Detach(); 64 void Detach();
64 65
65 // EventListener implementation. 66 // EventListener implementation.
66 bool operator==(const EventListener&) const override; 67 bool operator==(const EventListener&) const override;
67 68
68 DECLARE_VIRTUAL_TRACE(); 69 DECLARE_VIRTUAL_TRACE();
69 70
70 private: 71 private:
71 friend class MediaControlsOrientationLockDelegateTest; 72 friend class MediaControlsOrientationLockDelegateTest;
73 friend class MediaControlsOrientationLockAndRotateToFullscreenDelegateTest;
72 74
73 enum class State { 75 enum class State {
74 kPendingFullscreen, 76 kPendingFullscreen,
75 kPendingMetadata, 77 kPendingMetadata,
76 kMaybeLockedFullscreen, 78 kMaybeLockedFullscreen,
77 }; 79 };
78 80
81 enum class DeviceOrientationType {
82 kUnknown,
83 kFlat,
84 kDiagonal,
85 kPortrait,
86 kLandscape
87 };
88
79 // EventListener implementation. 89 // EventListener implementation.
80 void handleEvent(ExecutionContext*, Event*) override; 90 void handleEvent(ExecutionContext*, Event*) override;
81 91
82 HTMLVideoElement& VideoElement() const; 92 HTMLVideoElement& VideoElement() const;
83 Document& GetDocument() const; 93 Document& GetDocument() const;
84 94
85 // Returns the orientation in which the video should be locked based on its 95 // Returns the orientation in which the video should be locked based on its
86 // size. 96 // size.
87 MODULES_EXPORT WebScreenOrientationLockType ComputeOrientationLock() const; 97 MODULES_EXPORT WebScreenOrientationLockType ComputeOrientationLock() const;
88 98
89 // Locks the screen orientation if the video has metadata information 99 // Locks the screen orientation if the video has metadata information
90 // available. Delays locking orientation until metadata are available 100 // available. Delays locking orientation until metadata are available
91 // otherwise. 101 // otherwise.
92 void MaybeLockOrientation(); 102 void MaybeLockOrientation();
93 103
94 // Unlocks the screen orientation if the screen orientation was previously 104 // Unlocks the screen orientation if the screen orientation was previously
95 // locked. 105 // locked.
96 void MaybeUnlockOrientation(); 106 void MaybeUnlockOrientation();
97 107
98 void MaybeListenToDeviceOrientation(); 108 void MaybeListenToDeviceOrientation();
99 void GotIsAutoRotateEnabledByUser(bool enabled); 109 void GotIsAutoRotateEnabledByUser(bool enabled);
100 110
111 MODULES_EXPORT DeviceOrientationType
112 ComputeDeviceOrientation(DeviceOrientationData*) const;
113
101 void MaybeUnlockIfDeviceOrientationMatchesVideo(DeviceOrientationEvent*); 114 void MaybeUnlockIfDeviceOrientationMatchesVideo(DeviceOrientationEvent*);
102 115
103 // Current state of the object. See comment at the top of the file for a 116 // Current state of the object. See comment at the top of the file for a
104 // detailed description. 117 // detailed description.
105 State state_ = State::kPendingFullscreen; 118 State state_ = State::kPendingFullscreen;
106 119
107 // Which lock is currently applied by this delegate. 120 // Which lock is currently applied by this delegate.
108 WebScreenOrientationLockType locked_orientation_ = 121 WebScreenOrientationLockType locked_orientation_ =
109 kWebScreenOrientationLockDefault /* unlocked */; 122 kWebScreenOrientationLockDefault /* unlocked */;
110 123
111 device::mojom::blink::ScreenOrientationListenerPtr monitor_; 124 device::mojom::blink::ScreenOrientationListenerPtr monitor_;
112 125
126 int is_auto_rotate_enabled_by_user_for_testing_ = -1;
mlamouri (slow - plz ping) 2017/06/05 13:26:42 Can you make this `base::Optional<bool>`?
johnme 2017/06/14 17:46:42 Done.
127
113 // `video_element_` owns MediaControlsImpl that owns |this|. 128 // `video_element_` owns MediaControlsImpl that owns |this|.
114 Member<HTMLVideoElement> video_element_; 129 Member<HTMLVideoElement> video_element_;
115 }; 130 };
116 131
117 } // namespace blink 132 } // namespace blink
118 133
119 #endif // MediaControlsOrientationLockDelegate_h 134 #endif // MediaControlsOrientationLockDelegate_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698