| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } // anonymous namespace | 62 } // anonymous namespace |
| 63 | 63 |
| 64 MediaControlsOrientationLockDelegate::MediaControlsOrientationLockDelegate( | 64 MediaControlsOrientationLockDelegate::MediaControlsOrientationLockDelegate( |
| 65 HTMLVideoElement& video) | 65 HTMLVideoElement& video) |
| 66 : EventListener(CPPEventListenerType), m_videoElement(video) { | 66 : EventListener(CPPEventListenerType), m_videoElement(video) { |
| 67 if (videoElement().isConnected()) | 67 if (videoElement().isConnected()) |
| 68 attach(); | 68 attach(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void MediaControlsOrientationLockDelegate::attach() { | 71 void MediaControlsOrientationLockDelegate::attach() { |
| 72 DCHECK(videoElement().isConnected()); |
| 73 |
| 72 document().addEventListener(EventTypeNames::fullscreenchange, this, true); | 74 document().addEventListener(EventTypeNames::fullscreenchange, this, true); |
| 73 videoElement().addEventListener(EventTypeNames::webkitfullscreenchange, this, | 75 videoElement().addEventListener(EventTypeNames::webkitfullscreenchange, this, |
| 74 true); | 76 true); |
| 75 videoElement().addEventListener(EventTypeNames::loadedmetadata, this, true); | 77 videoElement().addEventListener(EventTypeNames::loadedmetadata, this, true); |
| 76 } | 78 } |
| 77 | 79 |
| 78 void MediaControlsOrientationLockDelegate::detach() { | 80 void MediaControlsOrientationLockDelegate::detach() { |
| 81 DCHECK(!videoElement().isConnected()); |
| 82 |
| 79 document().removeEventListener(EventTypeNames::fullscreenchange, this, true); | 83 document().removeEventListener(EventTypeNames::fullscreenchange, this, true); |
| 80 videoElement().removeEventListener(EventTypeNames::webkitfullscreenchange, | 84 videoElement().removeEventListener(EventTypeNames::webkitfullscreenchange, |
| 81 this, true); | 85 this, true); |
| 82 videoElement().removeEventListener(EventTypeNames::loadedmetadata, this, | 86 videoElement().removeEventListener(EventTypeNames::loadedmetadata, this, |
| 83 true); | 87 true); |
| 84 } | 88 } |
| 85 | 89 |
| 86 bool MediaControlsOrientationLockDelegate::operator==( | 90 bool MediaControlsOrientationLockDelegate::operator==( |
| 87 const EventListener& other) const { | 91 const EventListener& other) const { |
| 88 return this == &other; | 92 return this == &other; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 NOTREACHED(); | 209 NOTREACHED(); |
| 206 return WebScreenOrientationLockLandscape; | 210 return WebScreenOrientationLockLandscape; |
| 207 } | 211 } |
| 208 | 212 |
| 209 DEFINE_TRACE(MediaControlsOrientationLockDelegate) { | 213 DEFINE_TRACE(MediaControlsOrientationLockDelegate) { |
| 210 EventListener::trace(visitor); | 214 EventListener::trace(visitor); |
| 211 visitor->trace(m_videoElement); | 215 visitor->trace(m_videoElement); |
| 212 } | 216 } |
| 213 | 217 |
| 214 } // namespace blink | 218 } // namespace blink |
| OLD | NEW |