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

Side by Side Diff: third_party/WebKit/Source/modules/vr/NavigatorVR.cpp

Issue 2505493004: Wired up vrdisplayactivate/deactivate (Closed)
Patch Set: Again with the upstream issues 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 unified diff | Download patch
OLDNEW
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/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
11 #include "core/frame/LocalDOMWindow.h" 12 #include "core/frame/LocalDOMWindow.h"
12 #include "core/frame/LocalFrame.h" 13 #include "core/frame/LocalFrame.h"
13 #include "core/frame/Navigator.h" 14 #include "core/frame/Navigator.h"
14 #include "core/frame/UseCounter.h" 15 #include "core/frame/UseCounter.h"
15 #include "core/page/Page.h" 16 #include "core/page/Page.h"
16 #include "modules/vr/VRController.h" 17 #include "modules/vr/VRController.h"
17 #include "modules/vr/VRDisplay.h" 18 #include "modules/vr/VRDisplay.h"
18 #include "modules/vr/VRGetDevicesCallback.h" 19 #include "modules/vr/VRGetDevicesCallback.h"
19 #include "modules/vr/VRPose.h" 20 #include "modules/vr/VRPose.h"
21 #include "platform/UserGestureIndicator.h"
20 #include "public/platform/Platform.h" 22 #include "public/platform/Platform.h"
21 #include "wtf/PtrUtil.h" 23 #include "wtf/PtrUtil.h"
22 24
23 namespace blink { 25 namespace blink {
24 26
25 NavigatorVR* NavigatorVR::from(Document& document) { 27 NavigatorVR* NavigatorVR::from(Document& document) {
26 if (!document.frame() || !document.frame()->domWindow()) 28 if (!document.frame() || !document.frame()->domWindow())
27 return 0; 29 return 0;
28 Navigator& navigator = *document.frame()->domWindow()->navigator(); 30 Navigator& navigator = *document.frame()->domWindow()->navigator();
29 return &from(navigator); 31 return &from(navigator);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 95 }
94 96
95 NavigatorVR::NavigatorVR(LocalFrame* frame) : DOMWindowProperty(frame) {} 97 NavigatorVR::NavigatorVR(LocalFrame* frame) : DOMWindowProperty(frame) {}
96 98
97 NavigatorVR::~NavigatorVR() {} 99 NavigatorVR::~NavigatorVR() {}
98 100
99 const char* NavigatorVR::supplementName() { 101 const char* NavigatorVR::supplementName() {
100 return "NavigatorVR"; 102 return "NavigatorVR";
101 } 103 }
102 104
103 void NavigatorVR::fireVRDisplayPresentChange(VRDisplay* display) { 105 void NavigatorVR::enqueueVREvent(VRDisplayEvent* event) {
104 if (frame() && frame()->localDOMWindow()) {
105 frame()->localDOMWindow()->enqueueWindowEvent(VRDisplayEvent::create(
106 EventTypeNames::vrdisplaypresentchange, true, false, display, ""));
107 }
108 }
109
110 void NavigatorVR::fireVrDisplayOnBlur(VRDisplay* display) {
111 fireVREvent(VRDisplayEvent::create(EventTypeNames::vrdisplayblur, true, false,
112 display, ""));
113 }
114
115 void NavigatorVR::fireVrDisplayOnFocus(VRDisplay* display) {
116 fireVREvent(VRDisplayEvent::create(EventTypeNames::vrdisplayfocus, true,
117 false, display, ""));
118 }
119
120 void NavigatorVR::fireVREvent(VRDisplayEvent* event) {
121 if (frame() && frame()->localDOMWindow()) { 106 if (frame() && frame()->localDOMWindow()) {
122 frame()->localDOMWindow()->enqueueWindowEvent(event); 107 frame()->localDOMWindow()->enqueueWindowEvent(event);
123 } 108 }
124 } 109 }
125 110
111 void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) {
112 if (frame() && frame()->localDOMWindow()) {
113 UserGestureIndicator gestureIndicator(
114 DocumentUserGestureToken::create(frame()->document()));
115 event->setTarget(frame()->localDOMWindow());
116 frame()->localDOMWindow()->dispatchEvent(event);
117 }
118 }
119
126 } // namespace blink 120 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.h ('k') | third_party/WebKit/Source/modules/vr/VRController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698