| 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/NavigatorVR.h" | 5 #include "modules/vr/NavigatorVR.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/frame/UseCounter.h" |
| 14 #include "core/page/Page.h" | 15 #include "core/page/Page.h" |
| 15 #include "modules/vr/VRController.h" | 16 #include "modules/vr/VRController.h" |
| 16 #include "modules/vr/VRDisplay.h" | 17 #include "modules/vr/VRDisplay.h" |
| 17 #include "modules/vr/VRGetDevicesCallback.h" | 18 #include "modules/vr/VRGetDevicesCallback.h" |
| 18 #include "modules/vr/VRPose.h" | 19 #include "modules/vr/VRPose.h" |
| 19 #include "wtf/PtrUtil.h" | 20 #include "wtf/PtrUtil.h" |
| 20 | 21 |
| 21 namespace blink { | 22 namespace blink { |
| 22 | 23 |
| 23 NavigatorVR* NavigatorVR::from(Document& document) | 24 NavigatorVR* NavigatorVR::from(Document& document) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 ScriptPromise promise = resolver->promise(); | 50 ScriptPromise promise = resolver->promise(); |
| 50 | 51 |
| 51 Document* document = m_frame ? m_frame->document() : 0; | 52 Document* document = m_frame ? m_frame->document() : 0; |
| 52 | 53 |
| 53 if (!document || !controller()) { | 54 if (!document || !controller()) { |
| 54 DOMException* exception = DOMException::create(InvalidStateError, "The o
bject is no longer associated to a document."); | 55 DOMException* exception = DOMException::create(InvalidStateError, "The o
bject is no longer associated to a document."); |
| 55 resolver->reject(exception); | 56 resolver->reject(exception); |
| 56 return promise; | 57 return promise; |
| 57 } | 58 } |
| 58 | 59 |
| 60 UseCounter::count(*document, UseCounter::VRGetDisplays); |
| 61 |
| 59 controller()->getDisplays(resolver); | 62 controller()->getDisplays(resolver); |
| 60 | 63 |
| 61 return promise; | 64 return promise; |
| 62 } | 65 } |
| 63 | 66 |
| 64 VRController* NavigatorVR::controller() | 67 VRController* NavigatorVR::controller() |
| 65 { | 68 { |
| 66 if (!frame()) | 69 if (!frame()) |
| 67 return 0; | 70 return 0; |
| 68 | 71 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 105 |
| 103 void NavigatorVR::fireVRDisplayPresentChange(VRDisplay* display) | 106 void NavigatorVR::fireVRDisplayPresentChange(VRDisplay* display) |
| 104 { | 107 { |
| 105 if (m_frame && m_frame->localDOMWindow()) { | 108 if (m_frame && m_frame->localDOMWindow()) { |
| 106 m_frame->localDOMWindow()->enqueueWindowEvent( | 109 m_frame->localDOMWindow()->enqueueWindowEvent( |
| 107 VRDisplayEvent::create(EventTypeNames::vrdisplaypresentchange, true,
false, display, "")); | 110 VRDisplayEvent::create(EventTypeNames::vrdisplaypresentchange, true,
false, display, "")); |
| 108 } | 111 } |
| 109 } | 112 } |
| 110 | 113 |
| 111 } // namespace blink | 114 } // namespace blink |
| OLD | NEW |