Chromium Code Reviews| 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 #ifndef NavigatorVR_h | 5 #ifndef NavigatorVR_h |
| 6 #define NavigatorVR_h | 6 #define NavigatorVR_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
| 10 #include "core/frame/Navigator.h" | 10 #include "core/frame/Navigator.h" |
| 11 #include "core/page/PageVisibilityObserver.h" | 11 #include "core/page/FocusChangedObserver.h" |
| 12 #include "modules/ModulesExport.h" | 12 #include "modules/ModulesExport.h" |
| 13 #include "modules/vr/VRDisplay.h" | 13 #include "modules/vr/VRDisplay.h" |
| 14 #include "modules/vr/VRDisplayEvent.h" | 14 #include "modules/vr/VRDisplayEvent.h" |
| 15 #include "platform/Supplementable.h" | 15 #include "platform/Supplementable.h" |
| 16 #include "platform/heap/Handle.h" | 16 #include "platform/heap/Handle.h" |
| 17 #include "public/platform/WebVector.h" | 17 #include "public/platform/WebVector.h" |
| 18 #include "wtf/Noncopyable.h" | 18 #include "wtf/Noncopyable.h" |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 class Document; | 22 class Document; |
| 23 class Navigator; | 23 class Navigator; |
| 24 class VRController; | 24 class VRController; |
| 25 | 25 |
| 26 class MODULES_EXPORT NavigatorVR final | 26 class MODULES_EXPORT NavigatorVR final |
| 27 : public GarbageCollectedFinalized<NavigatorVR>, | 27 : public GarbageCollectedFinalized<NavigatorVR>, |
| 28 public Supplement<Navigator>, | 28 public Supplement<Navigator>, |
| 29 public PageVisibilityObserver, | 29 public LocalDOMWindow::EventListenerObserver, |
| 30 public LocalDOMWindow::EventListenerObserver { | 30 public FocusChangedObserver { |
| 31 USING_GARBAGE_COLLECTED_MIXIN(NavigatorVR); | 31 USING_GARBAGE_COLLECTED_MIXIN(NavigatorVR); |
| 32 WTF_MAKE_NONCOPYABLE(NavigatorVR); | 32 WTF_MAKE_NONCOPYABLE(NavigatorVR); |
| 33 | 33 |
| 34 public: | 34 public: |
| 35 static NavigatorVR* from(Document&); | 35 static NavigatorVR* from(Document&); |
| 36 static NavigatorVR& from(Navigator&); | 36 static NavigatorVR& from(Navigator&); |
| 37 virtual ~NavigatorVR(); | 37 virtual ~NavigatorVR(); |
| 38 | 38 |
| 39 static ScriptPromise getVRDisplays(ScriptState*, Navigator&); | 39 static ScriptPromise getVRDisplays(ScriptState*, Navigator&); |
| 40 ScriptPromise getVRDisplays(ScriptState*); | 40 ScriptPromise getVRDisplays(ScriptState*); |
| 41 | 41 |
| 42 VRController* controller(); | 42 VRController* controller(); |
| 43 Document* document(); | 43 Document* document(); |
| 44 bool isFocused() { return m_focused; } | |
| 44 | 45 |
| 45 // Queues up event to be fired soon. | 46 // Queues up event to be fired soon. |
| 46 void enqueueVREvent(VRDisplayEvent*); | 47 void enqueueVREvent(VRDisplayEvent*); |
| 47 | 48 |
| 48 // Dispatches a user gesture event immediately. | 49 // Dispatches a user gesture event immediately. |
| 49 void dispatchVRGestureEvent(VRDisplayEvent*); | 50 void dispatchVRGestureEvent(VRDisplayEvent*); |
| 50 | 51 |
| 51 // Inherited from PageVisibilityObserver. | 52 // Inherited from FocusChangedObserver. |
| 52 void pageVisibilityChanged() override; | 53 void focusedFrameChanged() override; |
| 53 | 54 |
| 54 // Inherited from LocalDOMWindow::EventListenerObserver. | 55 // Inherited from LocalDOMWindow::EventListenerObserver. |
| 55 void didAddEventListener(LocalDOMWindow*, const AtomicString&) override; | 56 void didAddEventListener(LocalDOMWindow*, const AtomicString&) override; |
| 56 void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) override; | 57 void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) override; |
| 57 void didRemoveAllEventListeners(LocalDOMWindow*) override; | 58 void didRemoveAllEventListeners(LocalDOMWindow*) override; |
| 58 | 59 |
| 59 DECLARE_VIRTUAL_TRACE(); | 60 DECLARE_VIRTUAL_TRACE(); |
| 60 | 61 |
| 61 private: | 62 private: |
| 62 friend class VRDisplay; | 63 friend class VRDisplay; |
| 63 friend class VRGetDevicesCallback; | 64 friend class VRGetDevicesCallback; |
| 64 | 65 |
| 65 explicit NavigatorVR(Navigator&); | 66 explicit NavigatorVR(Navigator&); |
| 66 | 67 |
| 67 static const char* supplementName(); | 68 static const char* supplementName(); |
| 68 | 69 |
| 69 void fireVRDisplayPresentChange(VRDisplay*); | 70 void fireVRDisplayPresentChange(VRDisplay*); |
| 70 | 71 |
| 71 Member<VRController> m_controller; | 72 Member<VRController> m_controller; |
| 72 | 73 |
| 73 // Whether this page is listening for vrdisplayactivate event. | 74 // Whether this page is listening for vrdisplayactivate event. |
| 74 bool m_listeningForActivate = false; | 75 bool m_listeningForActivate = false; |
| 76 bool m_focused = false; | |
|
haraken
2017/02/03 18:46:18
Maybe would it make more sense to move this boolea
mthiesse
2017/02/03 20:47:29
That doesn't really make sense to me in the genera
| |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 } // namespace blink | 79 } // namespace blink |
| 78 | 80 |
| 79 #endif // NavigatorVR_h | 81 #endif // NavigatorVR_h |
| OLD | NEW |