| 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/DocumentUserGestureToken.h" | 10 #include "core/dom/DocumentUserGestureToken.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 Platform::current()->recordRapporURL("VR.WebVR.GetDisplays", | 65 Platform::current()->recordRapporURL("VR.WebVR.GetDisplays", |
| 66 document()->url()); | 66 document()->url()); |
| 67 | 67 |
| 68 controller()->getDisplays(resolver); | 68 controller()->getDisplays(resolver); |
| 69 | 69 |
| 70 return promise; | 70 return promise; |
| 71 } | 71 } |
| 72 | 72 |
| 73 VRController* NavigatorVR::controller() { | 73 VRController* NavigatorVR::controller() { |
| 74 if (!host()->frame()) | 74 if (!supplementable()->frame()) |
| 75 return 0; | 75 return 0; |
| 76 | 76 |
| 77 if (!m_controller) { | 77 if (!m_controller) { |
| 78 m_controller = new VRController(this); | 78 m_controller = new VRController(this); |
| 79 } | 79 } |
| 80 | 80 |
| 81 return m_controller; | 81 return m_controller; |
| 82 } | 82 } |
| 83 | 83 |
| 84 Document* NavigatorVR::document() { | 84 Document* NavigatorVR::document() { |
| 85 return host()->frame() ? host()->frame()->document() : nullptr; | 85 return supplementable()->frame() ? supplementable()->frame()->document() |
| 86 : nullptr; |
| 86 } | 87 } |
| 87 | 88 |
| 88 DEFINE_TRACE(NavigatorVR) { | 89 DEFINE_TRACE(NavigatorVR) { |
| 89 visitor->trace(m_controller); | 90 visitor->trace(m_controller); |
| 90 Supplement<Navigator>::trace(visitor); | 91 Supplement<Navigator>::trace(visitor); |
| 91 PageVisibilityObserver::trace(visitor); | 92 PageVisibilityObserver::trace(visitor); |
| 92 } | 93 } |
| 93 | 94 |
| 94 NavigatorVR::NavigatorVR(Navigator& navigator) | 95 NavigatorVR::NavigatorVR(Navigator& navigator) |
| 95 : Supplement<Navigator>(navigator), | 96 : Supplement<Navigator>(navigator), |
| 96 PageVisibilityObserver(navigator.frame()->page()) { | 97 PageVisibilityObserver(navigator.frame()->page()) { |
| 97 navigator.frame()->domWindow()->registerEventListenerObserver(this); | 98 navigator.frame()->domWindow()->registerEventListenerObserver(this); |
| 98 } | 99 } |
| 99 | 100 |
| 100 NavigatorVR::~NavigatorVR() {} | 101 NavigatorVR::~NavigatorVR() {} |
| 101 | 102 |
| 102 const char* NavigatorVR::supplementName() { | 103 const char* NavigatorVR::supplementName() { |
| 103 return "NavigatorVR"; | 104 return "NavigatorVR"; |
| 104 } | 105 } |
| 105 | 106 |
| 106 void NavigatorVR::enqueueVREvent(VRDisplayEvent* event) { | 107 void NavigatorVR::enqueueVREvent(VRDisplayEvent* event) { |
| 107 if (host()->frame()) { | 108 if (supplementable()->frame()) { |
| 108 host()->frame()->domWindow()->enqueueWindowEvent(event); | 109 supplementable()->frame()->domWindow()->enqueueWindowEvent(event); |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 | 112 |
| 112 void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) { | 113 void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) { |
| 113 if (!(host()->frame())) | 114 if (!(supplementable()->frame())) |
| 114 return; | 115 return; |
| 115 UserGestureIndicator gestureIndicator( | 116 UserGestureIndicator gestureIndicator( |
| 116 DocumentUserGestureToken::create(document())); | 117 DocumentUserGestureToken::create(document())); |
| 117 LocalDOMWindow* window = host()->frame()->domWindow(); | 118 LocalDOMWindow* window = supplementable()->frame()->domWindow(); |
| 118 DCHECK(window); | 119 DCHECK(window); |
| 119 event->setTarget(window); | 120 event->setTarget(window); |
| 120 window->dispatchEvent(event); | 121 window->dispatchEvent(event); |
| 121 } | 122 } |
| 122 | 123 |
| 123 void NavigatorVR::pageVisibilityChanged() { | 124 void NavigatorVR::pageVisibilityChanged() { |
| 124 if (!page()) | 125 if (!page()) |
| 125 return; | 126 return; |
| 126 if (m_controller) { | 127 if (m_controller) { |
| 127 m_controller->setListeningForActivate(page()->isPageVisible() && | 128 m_controller->setListeningForActivate(page()->isPageVisible() && |
| (...skipping 23 matching lines...) Expand all Loading... |
| 151 } | 152 } |
| 152 | 153 |
| 153 void NavigatorVR::didRemoveAllEventListeners(LocalDOMWindow* window) { | 154 void NavigatorVR::didRemoveAllEventListeners(LocalDOMWindow* window) { |
| 154 if (m_controller) { | 155 if (m_controller) { |
| 155 m_controller->setListeningForActivate(false); | 156 m_controller->setListeningForActivate(false); |
| 156 m_listeningForActivate = false; | 157 m_listeningForActivate = false; |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 | 160 |
| 160 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |