OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/vr/VRController.h" | 5 #include "modules/vr/VRController.h" |
6 | 6 |
7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "modules/vr/NavigatorVR.h" | 10 #include "modules/vr/NavigatorVR.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 void VRController::OnDisplayChanged(device::blink::VRDisplayPtr display) | 109 void VRController::OnDisplayChanged(device::blink::VRDisplayPtr display) |
110 { | 110 { |
111 VRDisplay* vrDisplay = getDisplayForIndex(display->index); | 111 VRDisplay* vrDisplay = getDisplayForIndex(display->index); |
112 if (!vrDisplay) | 112 if (!vrDisplay) |
113 return; | 113 return; |
114 | 114 |
115 vrDisplay->update(display); | 115 vrDisplay->update(display); |
116 } | 116 } |
117 | 117 |
| 118 void VRController::OnDisplayConnected(device::blink::VRDisplayPtr display) |
| 119 { |
| 120 VRDisplay* vrDisplay = createOrUpdateDisplay(display); |
| 121 if (!vrDisplay) |
| 122 return; |
| 123 |
| 124 m_navigatorVR->fireVREvent(VRDisplayEvent::create( |
| 125 EventTypeNames::vrdisplayconnect, true, false, vrDisplay, "connect")); |
| 126 } |
| 127 |
| 128 void VRController::OnDisplayDisconnected(unsigned index) |
| 129 { |
| 130 VRDisplay* vrDisplay = getDisplayForIndex(index); |
| 131 if (!vrDisplay) |
| 132 return; |
| 133 |
| 134 vrDisplay->disconnected(); |
| 135 |
| 136 m_navigatorVR->fireVREvent(VRDisplayEvent::create( |
| 137 EventTypeNames::vrdisplaydisconnect, true, false, vrDisplay, "disconnect
")); |
| 138 } |
| 139 |
118 void VRController::contextDestroyed() | 140 void VRController::contextDestroyed() |
119 { | 141 { |
120 // If the document context was destroyed, shut down the client connection | 142 // If the document context was destroyed, shut down the client connection |
121 // and never call the mojo service again. | 143 // and never call the mojo service again. |
122 m_binding.Close(); | 144 m_binding.Close(); |
123 m_service.reset(); | 145 m_service.reset(); |
124 | 146 |
125 // The context is not automatically cleared, so do it manually. | 147 // The context is not automatically cleared, so do it manually. |
126 ContextLifecycleObserver::clearContext(); | 148 ContextLifecycleObserver::clearContext(); |
127 } | 149 } |
128 | 150 |
129 DEFINE_TRACE(VRController) | 151 DEFINE_TRACE(VRController) |
130 { | 152 { |
131 visitor->trace(m_navigatorVR); | 153 visitor->trace(m_navigatorVR); |
132 visitor->trace(m_displays); | 154 visitor->trace(m_displays); |
133 | 155 |
134 ContextLifecycleObserver::trace(visitor); | 156 ContextLifecycleObserver::trace(visitor); |
135 } | 157 } |
136 | 158 |
137 } // namespace blink | 159 } // namespace blink |
OLD | NEW |