Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(960)

Unified Diff: third_party/WebKit/Source/modules/vr/NavigatorVR.cpp

Issue 2510993002: Notify VRDeviceProviders when there are pages listening for vrdisplayactivate (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
diff --git a/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp b/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
index a157e2c3d1b13e5066d01f441854b29eacde782c..de32e5af44b98de1a8a58c3e5f703478dd00bb36 100644
--- a/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
+++ b/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
@@ -94,7 +94,9 @@ DEFINE_TRACE(NavigatorVR) {
DOMWindowProperty::trace(visitor);
}
-NavigatorVR::NavigatorVR(LocalFrame* frame) : DOMWindowProperty(frame) {}
+NavigatorVR::NavigatorVR(LocalFrame* frame) : DOMWindowProperty(frame) {
+ frame->localDOMWindow()->registerEventListenerObserver(this);
+}
NavigatorVR::~NavigatorVR() {}
@@ -117,4 +119,29 @@ void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) {
}
}
+void NavigatorVR::didAddEventListener(LocalDOMWindow* window,
+ const AtomicString& eventType) {
+ if (eventType == EventTypeNames::vrdisplayactivate) {
+ controller()->setListeningForActivate(true);
+ } else if (eventType == EventTypeNames::vrdisplayconnect) {
+ // If the page is listening for connection events make sure we've created a
+ // controller so that we'll be notified of new devices.
+ controller();
+ }
+}
+
+void NavigatorVR::didRemoveEventListener(LocalDOMWindow* window,
+ const AtomicString& eventType) {
+ if (eventType == EventTypeNames::vrdisplayactivate &&
+ !window->hasEventListeners(EventTypeNames::vrdisplayactivate)) {
+ controller()->setListeningForActivate(false);
+ }
+}
+
+void NavigatorVR::didRemoveAllEventListeners(LocalDOMWindow* window) {
+ if (m_controller) {
+ m_controller->setListeningForActivate(false);
+ }
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.h ('k') | third_party/WebKit/Source/modules/vr/VRController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698