| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "modules/screen_orientation/ScreenOrientationControllerImpl.h" | 5 #include "modules/screen_orientation/ScreenOrientationControllerImpl.h" |
| 6 | 6 |
| 7 #include "core/events/Event.h" | 7 #include "core/events/Event.h" |
| 8 #include "core/frame/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 for (size_t i = 0; i < childFrames.size(); ++i) { | 150 for (size_t i = 0; i < childFrames.size(); ++i) { |
| 151 if (ScreenOrientationControllerImpl* controller = | 151 if (ScreenOrientationControllerImpl* controller = |
| 152 ScreenOrientationControllerImpl::from(*childFrames[i])) | 152 ScreenOrientationControllerImpl::from(*childFrames[i])) |
| 153 controller->notifyOrientationChanged(); | 153 controller->notifyOrientationChanged(); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 void ScreenOrientationControllerImpl::setOrientation( | 157 void ScreenOrientationControllerImpl::setOrientation( |
| 158 ScreenOrientation* orientation) { | 158 ScreenOrientation* orientation) { |
| 159 m_orientation = orientation; | 159 m_orientation = orientation; |
| 160 if (m_orientation) | 160 if (isActiveAndVisible()) |
| 161 updateOrientation(); | 161 updateOrientation(); |
| 162 notifyDispatcher(); | 162 notifyDispatcher(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void ScreenOrientationControllerImpl::lock( | 165 void ScreenOrientationControllerImpl::lock( |
| 166 WebScreenOrientationLockType orientation, | 166 WebScreenOrientationLockType orientation, |
| 167 std::unique_ptr<WebLockOrientationCallback> callback) { | 167 std::unique_ptr<WebLockOrientationCallback> callback) { |
| 168 // When detached, the client is no longer valid. | 168 // When detached, the client is no longer valid. |
| 169 if (!m_client) | 169 if (!m_client) |
| 170 return; | 170 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 201 } | 201 } |
| 202 | 202 |
| 203 void ScreenOrientationControllerImpl::unregisterWithDispatcher() { | 203 void ScreenOrientationControllerImpl::unregisterWithDispatcher() { |
| 204 ScreenOrientationDispatcher::instance().removeController(this); | 204 ScreenOrientationDispatcher::instance().removeController(this); |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool ScreenOrientationControllerImpl::hasLastData() { | 207 bool ScreenOrientationControllerImpl::hasLastData() { |
| 208 return true; | 208 return true; |
| 209 } | 209 } |
| 210 | 210 |
| 211 void ScreenOrientationControllerImpl::frameDestroyed() { | 211 void ScreenOrientationControllerImpl::contextDestroyed() { |
| 212 m_client = nullptr; | 212 m_client = nullptr; |
| 213 DOMWindowProperty::frameDestroyed(); | 213 DOMWindowProperty::contextDestroyed(); |
| 214 m_activeLock = false; | 214 m_activeLock = false; |
| 215 } | 215 } |
| 216 | 216 |
| 217 void ScreenOrientationControllerImpl::notifyDispatcher() { | 217 void ScreenOrientationControllerImpl::notifyDispatcher() { |
| 218 if (m_orientation && page()->isPageVisible()) | 218 if (m_orientation && page()->isPageVisible()) |
| 219 startUpdating(); | 219 startUpdating(); |
| 220 else | 220 else |
| 221 stopUpdating(); | 221 stopUpdating(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 DEFINE_TRACE(ScreenOrientationControllerImpl) { | 224 DEFINE_TRACE(ScreenOrientationControllerImpl) { |
| 225 visitor->trace(m_orientation); | 225 visitor->trace(m_orientation); |
| 226 DOMWindowProperty::trace(visitor); | 226 DOMWindowProperty::trace(visitor); |
| 227 Supplement<LocalFrame>::trace(visitor); | 227 Supplement<LocalFrame>::trace(visitor); |
| 228 PlatformEventController::trace(visitor); | 228 PlatformEventController::trace(visitor); |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace blink | 231 } // namespace blink |
| OLD | NEW |