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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 NavigatorVRDevice* NavigatorVRDevice::from(Document& document) | 25 NavigatorVRDevice* NavigatorVRDevice::from(Document& document) |
26 { | 26 { |
27 if (!document.frame() || !document.frame()->domWindow()) | 27 if (!document.frame() || !document.frame()->domWindow()) |
28 return 0; | 28 return 0; |
29 Navigator& navigator = *document.frame()->domWindow()->navigator(); | 29 Navigator& navigator = *document.frame()->domWindow()->navigator(); |
30 return &from(navigator); | 30 return &from(navigator); |
31 } | 31 } |
32 | 32 |
33 NavigatorVRDevice& NavigatorVRDevice::from(Navigator& navigator) | 33 NavigatorVRDevice& NavigatorVRDevice::from(Navigator& navigator) |
34 { | 34 { |
35 NavigatorVRDevice* supplement = static_cast<NavigatorVRDevice*>(HeapSuppleme
nt<Navigator>::from(navigator, supplementName())); | 35 NavigatorVRDevice* supplement = static_cast<NavigatorVRDevice*>(Supplement<N
avigator>::from(navigator, supplementName())); |
36 if (!supplement) { | 36 if (!supplement) { |
37 supplement = new NavigatorVRDevice(navigator.frame()); | 37 supplement = new NavigatorVRDevice(navigator.frame()); |
38 provideTo(navigator, supplementName(), supplement); | 38 provideTo(navigator, supplementName(), supplement); |
39 } | 39 } |
40 return *supplement; | 40 return *supplement; |
41 } | 41 } |
42 | 42 |
43 ScriptPromise NavigatorVRDevice::getVRDevices(ScriptState* scriptState, Navigato
r& navigator) | 43 ScriptPromise NavigatorVRDevice::getVRDevices(ScriptState* scriptState, Navigato
r& navigator) |
44 { | 44 { |
45 return NavigatorVRDevice::from(navigator).getVRDevices(scriptState); | 45 return NavigatorVRDevice::from(navigator).getVRDevices(scriptState); |
(...skipping 22 matching lines...) Expand all Loading... |
68 if (!frame()) | 68 if (!frame()) |
69 return 0; | 69 return 0; |
70 | 70 |
71 return VRController::from(*frame()); | 71 return VRController::from(*frame()); |
72 } | 72 } |
73 | 73 |
74 DEFINE_TRACE(NavigatorVRDevice) | 74 DEFINE_TRACE(NavigatorVRDevice) |
75 { | 75 { |
76 visitor->trace(m_hardwareUnits); | 76 visitor->trace(m_hardwareUnits); |
77 | 77 |
78 HeapSupplement<Navigator>::trace(visitor); | 78 Supplement<Navigator>::trace(visitor); |
79 DOMWindowProperty::trace(visitor); | 79 DOMWindowProperty::trace(visitor); |
80 } | 80 } |
81 | 81 |
82 NavigatorVRDevice::NavigatorVRDevice(LocalFrame* frame) | 82 NavigatorVRDevice::NavigatorVRDevice(LocalFrame* frame) |
83 : DOMWindowProperty(frame) | 83 : DOMWindowProperty(frame) |
84 { | 84 { |
85 m_hardwareUnits = new VRHardwareUnitCollection(this); | 85 m_hardwareUnits = new VRHardwareUnitCollection(this); |
86 } | 86 } |
87 | 87 |
88 NavigatorVRDevice::~NavigatorVRDevice() | 88 NavigatorVRDevice::~NavigatorVRDevice() |
89 { | 89 { |
90 } | 90 } |
91 | 91 |
92 const char* NavigatorVRDevice::supplementName() | 92 const char* NavigatorVRDevice::supplementName() |
93 { | 93 { |
94 return "NavigatorVRDevice"; | 94 return "NavigatorVRDevice"; |
95 } | 95 } |
96 | 96 |
97 } // namespace blink | 97 } // namespace blink |
OLD | NEW |