Chromium Code Reviews| 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 #include "MediaControlsOrientationLockDelegate.h" | 5 #include "MediaControlsOrientationLockDelegate.h" |
| 6 | 6 |
| 7 #include "core/events/Event.h" | 7 #include "core/events/Event.h" |
| 8 #include "core/frame/ScreenOrientationController.h" | 8 #include "core/frame/ScreenOrientationController.h" |
| 9 #include "core/html/HTMLVideoElement.h" | 9 #include "core/html/HTMLVideoElement.h" |
| 10 #include "core/page/ChromeClient.h" | 10 #include "core/page/ChromeClient.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 videoElement().addEventListener(EventTypeNames::webkitfullscreenchange, this, | 68 videoElement().addEventListener(EventTypeNames::webkitfullscreenchange, this, |
| 69 true); | 69 true); |
| 70 videoElement().addEventListener(EventTypeNames::loadedmetadata, this, true); | 70 videoElement().addEventListener(EventTypeNames::loadedmetadata, this, true); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool MediaControlsOrientationLockDelegate::operator==( | 73 bool MediaControlsOrientationLockDelegate::operator==( |
| 74 const EventListener& other) const { | 74 const EventListener& other) const { |
| 75 return this == &other; | 75 return this == &other; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void MediaControlsOrientationLockDelegate::detach() { | |
| 79 document().removeEventListener(EventTypeNames::fullscreenchange, this, true); | |
|
Zhiqiang Zhang (Slow)
2017/03/01 16:22:36
Should we also remove the listeners from the video
mlamouri (slow - plz ping)
2017/03/01 20:22:33
Good point :) Though, the approach the first itera
| |
| 80 } | |
| 81 | |
| 78 void MediaControlsOrientationLockDelegate::maybeLockOrientation() { | 82 void MediaControlsOrientationLockDelegate::maybeLockOrientation() { |
| 79 DCHECK(m_state != State::MaybeLockedFullscreen); | 83 DCHECK(m_state != State::MaybeLockedFullscreen); |
| 80 | 84 |
| 81 if (videoElement().getReadyState() == HTMLMediaElement::kHaveNothing) { | 85 if (videoElement().getReadyState() == HTMLMediaElement::kHaveNothing) { |
| 82 recordMetadataAvailability(MetadataAvailabilityMetrics::Missing); | 86 recordMetadataAvailability(MetadataAvailabilityMetrics::Missing); |
| 83 m_state = State::PendingMetadata; | 87 m_state = State::PendingMetadata; |
| 84 return; | 88 return; |
| 85 } | 89 } |
| 86 | 90 |
| 87 if (m_state == State::PendingMetadata) | 91 if (m_state == State::PendingMetadata) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 NOTREACHED(); | 196 NOTREACHED(); |
| 193 return WebScreenOrientationLockLandscape; | 197 return WebScreenOrientationLockLandscape; |
| 194 } | 198 } |
| 195 | 199 |
| 196 DEFINE_TRACE(MediaControlsOrientationLockDelegate) { | 200 DEFINE_TRACE(MediaControlsOrientationLockDelegate) { |
| 197 EventListener::trace(visitor); | 201 EventListener::trace(visitor); |
| 198 visitor->trace(m_videoElement); | 202 visitor->trace(m_videoElement); |
| 199 } | 203 } |
| 200 | 204 |
| 201 } // namespace blink | 205 } // namespace blink |
| OLD | NEW |