| 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 "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 "platform/WebTaskRunner.h" |
| 11 #include "platform/wtf/Optional.h" | 12 #include "platform/wtf/Optional.h" |
| 12 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp
e.h" | 13 #include "public/platform/modules/screen_orientation/WebScreenOrientationLockTyp
e.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 class DeviceOrientationData; | 17 class DeviceOrientationData; |
| 17 class DeviceOrientationEvent; | 18 class DeviceOrientationEvent; |
| 18 class Document; | 19 class Document; |
| 19 class HTMLVideoElement; | 20 class HTMLVideoElement; |
| 20 | 21 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void MaybeUnlockOrientation(); | 108 void MaybeUnlockOrientation(); |
| 108 | 109 |
| 109 void MaybeListenToDeviceOrientation(); | 110 void MaybeListenToDeviceOrientation(); |
| 110 void GotIsAutoRotateEnabledByUser(bool enabled); | 111 void GotIsAutoRotateEnabledByUser(bool enabled); |
| 111 | 112 |
| 112 MODULES_EXPORT DeviceOrientationType | 113 MODULES_EXPORT DeviceOrientationType |
| 113 ComputeDeviceOrientation(DeviceOrientationData*) const; | 114 ComputeDeviceOrientation(DeviceOrientationData*) const; |
| 114 | 115 |
| 115 void MaybeUnlockIfDeviceOrientationMatchesVideo(DeviceOrientationEvent*); | 116 void MaybeUnlockIfDeviceOrientationMatchesVideo(DeviceOrientationEvent*); |
| 116 | 117 |
| 118 // Delay before unlocking - see `MaybeUnlockIfDeviceOrientationMatchesVideo`. |
| 119 // Emprically, 200ms is too short, but 250ms avoids glitches. 500ms gives us |
| 120 // a 2x margin in case the device is running slow, without being noticeable. |
| 121 static constexpr int kUnlockDelayMs = 500; |
| 122 |
| 117 // Current state of the object. See comment at the top of the file for a | 123 // Current state of the object. See comment at the top of the file for a |
| 118 // detailed description. | 124 // detailed description. |
| 119 State state_ = State::kPendingFullscreen; | 125 State state_ = State::kPendingFullscreen; |
| 120 | 126 |
| 121 // Which lock is currently applied by this delegate. | 127 // Which lock is currently applied by this delegate. |
| 122 WebScreenOrientationLockType locked_orientation_ = | 128 WebScreenOrientationLockType locked_orientation_ = |
| 123 kWebScreenOrientationLockDefault /* unlocked */; | 129 kWebScreenOrientationLockDefault /* unlocked */; |
| 124 | 130 |
| 131 TaskHandle unlock_task_; |
| 132 |
| 125 device::mojom::blink::ScreenOrientationListenerPtr monitor_; | 133 device::mojom::blink::ScreenOrientationListenerPtr monitor_; |
| 126 | 134 |
| 127 WTF::Optional<bool> is_auto_rotate_enabled_by_user_override_for_testing_; | 135 WTF::Optional<bool> is_auto_rotate_enabled_by_user_override_for_testing_; |
| 128 | 136 |
| 129 // `video_element_` owns MediaControlsImpl that owns |this|. | 137 // `video_element_` owns MediaControlsImpl that owns |this|. |
| 130 Member<HTMLVideoElement> video_element_; | 138 Member<HTMLVideoElement> video_element_; |
| 131 }; | 139 }; |
| 132 | 140 |
| 133 } // namespace blink | 141 } // namespace blink |
| 134 | 142 |
| 135 #endif // MediaControlsOrientationLockDelegate_h | 143 #endif // MediaControlsOrientationLockDelegate_h |
| OLD | NEW |