| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/screen_orientation/ScreenOrientationController.h" | 6 #include "modules/screen_orientation/ScreenOrientationController.h" |
| 7 | 7 |
| 8 #include "core/events/Event.h" | 8 #include "core/events/Event.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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void ScreenOrientationController::setOrientation(ScreenOrientation* orientation) | 148 void ScreenOrientationController::setOrientation(ScreenOrientation* orientation) |
| 149 { | 149 { |
| 150 m_orientation = orientation; | 150 m_orientation = orientation; |
| 151 if (m_orientation) | 151 if (m_orientation) |
| 152 updateOrientation(); | 152 updateOrientation(); |
| 153 notifyDispatcher(); | 153 notifyDispatcher(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void ScreenOrientationController::lock(WebScreenOrientationLockType orientation,
WebLockOrientationCallback* callback) | 156 void ScreenOrientationController::lock(WebScreenOrientationLockType orientation,
WebLockOrientationCallback* callback) |
| 157 { | 157 { |
| 158 ASSERT(m_client); | 158 // When detached, the client is no longer valid. |
| 159 if (!m_client) |
| 160 return; |
| 159 m_client->lockOrientation(orientation, callback); | 161 m_client->lockOrientation(orientation, callback); |
| 160 } | 162 } |
| 161 | 163 |
| 162 void ScreenOrientationController::unlock() | 164 void ScreenOrientationController::unlock() |
| 163 { | 165 { |
| 164 ASSERT(m_client); | 166 // When detached, the client is no longer valid. |
| 167 if (!m_client) |
| 168 return; |
| 165 m_client->unlockOrientation(); | 169 m_client->unlockOrientation(); |
| 166 } | 170 } |
| 167 | 171 |
| 168 void ScreenOrientationController::dispatchEventTimerFired(Timer<ScreenOrientatio
nController>*) | 172 void ScreenOrientationController::dispatchEventTimerFired(Timer<ScreenOrientatio
nController>*) |
| 169 { | 173 { |
| 170 if (!m_orientation) | 174 if (!m_orientation) |
| 171 return; | 175 return; |
| 172 m_orientation->dispatchEvent(Event::create(EventTypeNames::change)); | 176 m_orientation->dispatchEvent(Event::create(EventTypeNames::change)); |
| 173 } | 177 } |
| 174 | 178 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 185 void ScreenOrientationController::unregisterWithDispatcher() | 189 void ScreenOrientationController::unregisterWithDispatcher() |
| 186 { | 190 { |
| 187 ScreenOrientationDispatcher::instance().removeController(this); | 191 ScreenOrientationDispatcher::instance().removeController(this); |
| 188 } | 192 } |
| 189 | 193 |
| 190 bool ScreenOrientationController::hasLastData() | 194 bool ScreenOrientationController::hasLastData() |
| 191 { | 195 { |
| 192 return true; | 196 return true; |
| 193 } | 197 } |
| 194 | 198 |
| 199 void ScreenOrientationController::willDetachFrameHost() |
| 200 { |
| 201 m_client = nullptr; |
| 202 } |
| 203 |
| 195 void ScreenOrientationController::notifyDispatcher() | 204 void ScreenOrientationController::notifyDispatcher() |
| 196 { | 205 { |
| 197 if (m_orientation && page()->visibilityState() == PageVisibilityStateVisible
) | 206 if (m_orientation && page()->visibilityState() == PageVisibilityStateVisible
) |
| 198 startUpdating(); | 207 startUpdating(); |
| 199 else | 208 else |
| 200 stopUpdating(); | 209 stopUpdating(); |
| 201 } | 210 } |
| 202 | 211 |
| 203 void ScreenOrientationController::trace(Visitor* visitor) | 212 void ScreenOrientationController::trace(Visitor* visitor) |
| 204 { | 213 { |
| 205 visitor->trace(m_orientation); | 214 visitor->trace(m_orientation); |
| 206 FrameDestructionObserver::trace(visitor); | 215 FrameDestructionObserver::trace(visitor); |
| 207 WillBeHeapSupplement<LocalFrame>::trace(visitor); | 216 WillBeHeapSupplement<LocalFrame>::trace(visitor); |
| 208 PlatformEventController::trace(visitor); | 217 PlatformEventController::trace(visitor); |
| 209 } | 218 } |
| 210 | 219 |
| 211 } // namespace blink | 220 } // namespace blink |
| OLD | NEW |