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

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

Issue 2539763004: Don't dispatch vrdisplayactivate event if the page that listens for it is invisible (Closed)
Patch Set: nit Created 4 years 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 #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/DOMWindowProperty.h" 9 #include "core/frame/DOMWindowProperty.h"
10 #include "core/frame/LocalDOMWindow.h" 10 #include "core/frame/LocalDOMWindow.h"
11 #include "core/page/PageVisibilityObserver.h"
11 #include "modules/ModulesExport.h" 12 #include "modules/ModulesExport.h"
12 #include "modules/vr/VRDisplay.h" 13 #include "modules/vr/VRDisplay.h"
13 #include "modules/vr/VRDisplayEvent.h" 14 #include "modules/vr/VRDisplayEvent.h"
14 #include "platform/Supplementable.h" 15 #include "platform/Supplementable.h"
15 #include "platform/heap/Handle.h" 16 #include "platform/heap/Handle.h"
16 #include "public/platform/WebVector.h" 17 #include "public/platform/WebVector.h"
17 #include "wtf/Noncopyable.h" 18 #include "wtf/Noncopyable.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 class Document; 22 class Document;
22 class Navigator; 23 class Navigator;
23 class VRController; 24 class VRController;
24 25
25 class MODULES_EXPORT NavigatorVR final 26 class MODULES_EXPORT NavigatorVR final
26 : public GarbageCollectedFinalized<NavigatorVR>, 27 : public GarbageCollectedFinalized<NavigatorVR>,
27 public Supplement<Navigator>, 28 public Supplement<Navigator>,
28 public DOMWindowProperty, 29 public DOMWindowProperty,
30 public PageVisibilityObserver,
29 public LocalDOMWindow::EventListenerObserver { 31 public LocalDOMWindow::EventListenerObserver {
30 USING_GARBAGE_COLLECTED_MIXIN(NavigatorVR); 32 USING_GARBAGE_COLLECTED_MIXIN(NavigatorVR);
31 WTF_MAKE_NONCOPYABLE(NavigatorVR); 33 WTF_MAKE_NONCOPYABLE(NavigatorVR);
32 34
33 public: 35 public:
34 static NavigatorVR* from(Document&); 36 static NavigatorVR* from(Document&);
35 static NavigatorVR& from(Navigator&); 37 static NavigatorVR& from(Navigator&);
36 virtual ~NavigatorVR(); 38 virtual ~NavigatorVR();
37 39
38 static ScriptPromise getVRDisplays(ScriptState*, Navigator&); 40 static ScriptPromise getVRDisplays(ScriptState*, Navigator&);
39 ScriptPromise getVRDisplays(ScriptState*); 41 ScriptPromise getVRDisplays(ScriptState*);
40 42
41 VRController* controller(); 43 VRController* controller();
42 Document* document(); 44 Document* document();
43 45
44 // Queues up event to be fired soon. 46 // Queues up event to be fired soon.
45 void enqueueVREvent(VRDisplayEvent*); 47 void enqueueVREvent(VRDisplayEvent*);
46 48
47 // Dispatches a user gesture event immediately. 49 // Dispatches a user gesture event immediately.
48 void dispatchVRGestureEvent(VRDisplayEvent*); 50 void dispatchVRGestureEvent(VRDisplayEvent*);
49 51
52 // Inherited from PageVisibilityObserver.
53 void pageVisibilityChanged() override;
54
50 // Inherited from LocalDOMWindow::EventListenerObserver. 55 // Inherited from LocalDOMWindow::EventListenerObserver.
51 void didAddEventListener(LocalDOMWindow*, const AtomicString&) override; 56 void didAddEventListener(LocalDOMWindow*, const AtomicString&) override;
52 void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) override; 57 void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) override;
53 void didRemoveAllEventListeners(LocalDOMWindow*) override; 58 void didRemoveAllEventListeners(LocalDOMWindow*) override;
54 59
55 DECLARE_VIRTUAL_TRACE(); 60 DECLARE_VIRTUAL_TRACE();
56 61
57 private: 62 private:
58 friend class VRDisplay; 63 friend class VRDisplay;
59 friend class VRGetDevicesCallback; 64 friend class VRGetDevicesCallback;
60 65
61 explicit NavigatorVR(LocalFrame*); 66 explicit NavigatorVR(LocalFrame*);
62 67
63 static const char* supplementName(); 68 static const char* supplementName();
64 69
65 void fireVRDisplayPresentChange(VRDisplay*); 70 void fireVRDisplayPresentChange(VRDisplay*);
66 71
67 Member<VRController> m_controller; 72 Member<VRController> m_controller;
73
74 // Whether this page is listening for vrdisplayactivate event.
75 bool m_listeningForActivate = false;
68 }; 76 };
69 77
70 } // namespace blink 78 } // namespace blink
71 79
72 #endif // NavigatorVR_h 80 #endif // NavigatorVR_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698