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 "config.h" | 5 #include "config.h" |
6 #include "modules/vr/NavigatorVRDevice.h" | 6 #include "modules/vr/NavigatorVRDevice.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
11 #include "core/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
12 #include "core/frame/LocalDOMWindow.h" | 12 #include "core/frame/LocalDOMWindow.h" |
13 #include "core/frame/LocalFrame.h" | 13 #include "core/frame/LocalFrame.h" |
14 #include "core/frame/Navigator.h" | 14 #include "core/frame/Navigator.h" |
15 #include "core/page/Page.h" | 15 #include "core/page/Page.h" |
16 #include "modules/vr/HMDVRDevice.h" | 16 #include "modules/vr/HMDVRDevice.h" |
17 #include "modules/vr/PositionSensorVRDevice.h" | 17 #include "modules/vr/PositionSensorVRDevice.h" |
18 #include "modules/vr/VRController.h" | 18 #include "modules/vr/VRController.h" |
19 #include "modules/vr/VRGetDevicesCallback.h" | 19 #include "modules/vr/VRGetDevicesCallback.h" |
20 #include "modules/vr/VRHardwareUnit.h" | 20 #include "modules/vr/VRHardwareUnit.h" |
21 #include "modules/vr/VRHardwareUnitCollection.h" | 21 #include "modules/vr/VRHardwareUnitCollection.h" |
22 #include "modules/vr/VRPositionState.h" | 22 #include "modules/vr/VRPositionState.h" |
23 | 23 |
24 namespace blink { | 24 namespace blink { |
25 | 25 |
26 NavigatorVRDevice* NavigatorVRDevice::from(Document& document) | 26 NavigatorVRDevice* NavigatorVRDevice::from(Document& document) |
27 { | 27 { |
28 if (!document.frame() || !document.frame()->domWindow()) | 28 if (!document.frame() || !document.frame()->domWindow()) |
29 return 0; | 29 return nullptr; |
30 Navigator& navigator = *document.frame()->domWindow()->navigator(); | 30 Navigator* navigator = document.frame()->domWindow()->navigator(); |
31 return &from(navigator); | 31 if (!navigator) |
| 32 return nullptr; |
| 33 return &from(*navigator); |
32 } | 34 } |
33 | 35 |
34 NavigatorVRDevice& NavigatorVRDevice::from(Navigator& navigator) | 36 NavigatorVRDevice& NavigatorVRDevice::from(Navigator& navigator) |
35 { | 37 { |
36 NavigatorVRDevice* supplement = static_cast<NavigatorVRDevice*>(HeapSuppleme
nt<Navigator>::from(navigator, supplementName())); | 38 NavigatorVRDevice* supplement = static_cast<NavigatorVRDevice*>(HeapSuppleme
nt<Navigator>::from(navigator, supplementName())); |
37 if (!supplement) { | 39 if (!supplement) { |
38 supplement = new NavigatorVRDevice(navigator.frame()); | 40 supplement = new NavigatorVRDevice(navigator.frame()); |
39 provideTo(navigator, supplementName(), supplement); | 41 provideTo(navigator, supplementName(), supplement); |
40 } | 42 } |
41 return *supplement; | 43 return *supplement; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 NavigatorVRDevice::~NavigatorVRDevice() | 91 NavigatorVRDevice::~NavigatorVRDevice() |
90 { | 92 { |
91 } | 93 } |
92 | 94 |
93 const char* NavigatorVRDevice::supplementName() | 95 const char* NavigatorVRDevice::supplementName() |
94 { | 96 { |
95 return "NavigatorVRDevice"; | 97 return "NavigatorVRDevice"; |
96 } | 98 } |
97 | 99 |
98 } // namespace blink | 100 } // namespace blink |
OLD | NEW |