| 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/NavigatorVRDevice.h" | 5 #include "modules/vr/NavigatorVRDevice.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| 11 #include "core/frame/LocalDOMWindow.h" | 11 #include "core/frame/LocalDOMWindow.h" |
| 12 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
| 13 #include "core/frame/Navigator.h" | 13 #include "core/frame/Navigator.h" |
| 14 #include "core/page/Page.h" | 14 #include "core/page/Page.h" |
| 15 #include "modules/vr/HMDVRDevice.h" | 15 #include "modules/vr/HMDVRDevice.h" |
| 16 #include "modules/vr/PositionSensorVRDevice.h" | 16 #include "modules/vr/PositionSensorVRDevice.h" |
| 17 #include "modules/vr/VRController.h" | 17 #include "modules/vr/VRController.h" |
| 18 #include "modules/vr/VRGetDevicesCallback.h" | 18 #include "modules/vr/VRGetDevicesCallback.h" |
| 19 #include "modules/vr/VRHardwareUnit.h" | 19 #include "modules/vr/VRHardwareUnit.h" |
| 20 #include "modules/vr/VRHardwareUnitCollection.h" | 20 #include "modules/vr/VRHardwareUnitCollection.h" |
| 21 #include "modules/vr/VRPositionState.h" | 21 #include "modules/vr/VRPositionState.h" |
| 22 #include "wtf/PtrUtil.h" |
| 22 | 23 |
| 23 namespace blink { | 24 namespace blink { |
| 24 | 25 |
| 25 NavigatorVRDevice* NavigatorVRDevice::from(Document& document) | 26 NavigatorVRDevice* NavigatorVRDevice::from(Document& document) |
| 26 { | 27 { |
| 27 if (!document.frame() || !document.frame()->domWindow()) | 28 if (!document.frame() || !document.frame()->domWindow()) |
| 28 return 0; | 29 return 0; |
| 29 Navigator& navigator = *document.frame()->domWindow()->navigator(); | 30 Navigator& navigator = *document.frame()->domWindow()->navigator(); |
| 30 return &from(navigator); | 31 return &from(navigator); |
| 31 } | 32 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 51 ScriptPromise promise = resolver->promise(); | 52 ScriptPromise promise = resolver->promise(); |
| 52 | 53 |
| 53 Document* document = m_frame ? m_frame->document() : 0; | 54 Document* document = m_frame ? m_frame->document() : 0; |
| 54 | 55 |
| 55 if (!document || !controller()) { | 56 if (!document || !controller()) { |
| 56 DOMException* exception = DOMException::create(InvalidStateError, "The o
bject is no longer associated to a document."); | 57 DOMException* exception = DOMException::create(InvalidStateError, "The o
bject is no longer associated to a document."); |
| 57 resolver->reject(exception); | 58 resolver->reject(exception); |
| 58 return promise; | 59 return promise; |
| 59 } | 60 } |
| 60 | 61 |
| 61 controller()->getDevices(new VRGetDevicesCallback(resolver, m_hardwareUnits.
get())); | 62 controller()->getDevices(WTF::wrapUnique(new VRGetDevicesCallback(resolver,
m_hardwareUnits.get()))); |
| 62 | 63 |
| 63 return promise; | 64 return promise; |
| 64 } | 65 } |
| 65 | 66 |
| 66 VRController* NavigatorVRDevice::controller() | 67 VRController* NavigatorVRDevice::controller() |
| 67 { | 68 { |
| 68 if (!frame()) | 69 if (!frame()) |
| 69 return 0; | 70 return 0; |
| 70 | 71 |
| 71 return VRController::from(*frame()); | 72 return VRController::from(*frame()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 { | 85 { |
| 85 m_hardwareUnits = new VRHardwareUnitCollection(this); | 86 m_hardwareUnits = new VRHardwareUnitCollection(this); |
| 86 } | 87 } |
| 87 | 88 |
| 88 const char* NavigatorVRDevice::supplementName() | 89 const char* NavigatorVRDevice::supplementName() |
| 89 { | 90 { |
| 90 return "NavigatorVRDevice"; | 91 return "NavigatorVRDevice"; |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace blink | 94 } // namespace blink |
| OLD | NEW |