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 PresentationAvailability_h | 5 #ifndef PresentationAvailability_h |
6 #define PresentationAvailability_h | 6 #define PresentationAvailability_h |
7 | 7 |
8 #include "bindings/core/v8/ActiveScriptWrappable.h" | 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
9 #include "core/dom/ActiveDOMObject.h" | 9 #include "core/dom/ActiveDOMObject.h" |
10 #include "core/events/EventTarget.h" | 10 #include "core/events/EventTarget.h" |
11 #include "core/page/PageLifecycleObserver.h" | 11 #include "core/page/PageVisibilityObserver.h" |
12 #include "modules/ModulesExport.h" | 12 #include "modules/ModulesExport.h" |
13 #include "platform/weborigin/KURL.h" | 13 #include "platform/weborigin/KURL.h" |
14 #include "public/platform/WebURL.h" | 14 #include "public/platform/WebURL.h" |
15 #include "public/platform/modules/presentation/WebPresentationAvailabilityObserv
er.h" | 15 #include "public/platform/modules/presentation/WebPresentationAvailabilityObserv
er.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 class ExecutionContext; | 19 class ExecutionContext; |
20 class ScriptPromiseResolver; | 20 class ScriptPromiseResolver; |
21 | 21 |
22 // Expose whether there is a presentation display available for |url|. The | 22 // Expose whether there is a presentation display available for |url|. The |
23 // object will be initialized with a default value passed via ::take() and will | 23 // object will be initialized with a default value passed via ::take() and will |
24 // then subscribe to receive callbacks if the status for |url| were to | 24 // then subscribe to receive callbacks if the status for |url| were to |
25 // change. The object will only listen to changes when required. | 25 // change. The object will only listen to changes when required. |
26 class MODULES_EXPORT PresentationAvailability final | 26 class MODULES_EXPORT PresentationAvailability final |
27 : public EventTargetWithInlineData | 27 : public EventTargetWithInlineData |
28 , public ActiveScriptWrappable | 28 , public ActiveScriptWrappable |
29 , public ActiveDOMObject | 29 , public ActiveDOMObject |
30 , public PageLifecycleObserver | 30 , public PageVisibilityObserver |
31 , public WebPresentationAvailabilityObserver { | 31 , public WebPresentationAvailabilityObserver { |
32 USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability); | 32 USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability); |
33 DEFINE_WRAPPERTYPEINFO(); | 33 DEFINE_WRAPPERTYPEINFO(); |
34 public: | 34 public: |
35 static PresentationAvailability* take(ScriptPromiseResolver*, const KURL&, b
ool); | 35 static PresentationAvailability* take(ScriptPromiseResolver*, const KURL&, b
ool); |
36 ~PresentationAvailability() override; | 36 ~PresentationAvailability() override; |
37 | 37 |
38 // EventTarget implementation. | 38 // EventTarget implementation. |
39 const AtomicString& interfaceName() const override; | 39 const AtomicString& interfaceName() const override; |
40 ExecutionContext* getExecutionContext() const override; | 40 ExecutionContext* getExecutionContext() const override; |
41 | 41 |
42 // WebPresentationAvailabilityObserver implementation. | 42 // WebPresentationAvailabilityObserver implementation. |
43 void availabilityChanged(bool) override; | 43 void availabilityChanged(bool) override; |
44 const WebURL url() const override; | 44 const WebURL url() const override; |
45 | 45 |
46 // ActiveScriptWrappable implementation. | 46 // ActiveScriptWrappable implementation. |
47 bool hasPendingActivity() const final; | 47 bool hasPendingActivity() const final; |
48 | 48 |
49 // ActiveDOMObject implementation. | 49 // ActiveDOMObject implementation. |
50 void suspend() override; | 50 void suspend() override; |
51 void resume() override; | 51 void resume() override; |
52 void stop() override; | 52 void stop() override; |
53 | 53 |
54 // PageLifecycleObserver implementation. | 54 // PageVisibilityObserver implementation. |
55 void pageVisibilityChanged() override; | 55 void pageVisibilityChanged() override; |
56 | 56 |
57 bool value() const; | 57 bool value() const; |
58 | 58 |
59 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); | 59 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
60 | 60 |
61 DECLARE_VIRTUAL_TRACE(); | 61 DECLARE_VIRTUAL_TRACE(); |
62 | 62 |
63 protected: | 63 protected: |
64 // EventTarget implementation. | 64 // EventTarget implementation. |
(...skipping 16 matching lines...) Expand all Loading... |
81 void updateListening(); | 81 void updateListening(); |
82 | 82 |
83 const KURL m_url; | 83 const KURL m_url; |
84 bool m_value; | 84 bool m_value; |
85 State m_state; | 85 State m_state; |
86 }; | 86 }; |
87 | 87 |
88 } // namespace blink | 88 } // namespace blink |
89 | 89 |
90 #endif // PresentationAvailability_h | 90 #endif // PresentationAvailability_h |
OLD | NEW |