OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PresentationAvailability_h |
| 6 #define PresentationAvailability_h |
| 7 |
| 8 #include "core/dom/ActiveDOMObject.h" |
| 9 #include "core/events/EventTarget.h" |
| 10 #include "public/platform/modules/presentation/WebPresentationAvailabilityObserv
er.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class ExecutionContext; |
| 15 class ScriptPromiseResolver; |
| 16 |
| 17 // Expose whether there is a presentation display available. The object will be |
| 18 // initialized with a default value passed via ::take() and will then subscribe |
| 19 // to receive callbacks if the status were to change. The object will only |
| 20 // listen to changes when required. |
| 21 class PresentationAvailability final |
| 22 : public RefCountedGarbageCollectedEventTargetWithInlineData<PresentationAva
ilability> |
| 23 , public ActiveDOMObject |
| 24 , public WebPresentationAvailabilityObserver { |
| 25 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PresentationAvailability); |
| 26 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability); |
| 27 DEFINE_WRAPPERTYPEINFO(); |
| 28 public: |
| 29 static PresentationAvailability* take(ScriptPromiseResolver*, bool); |
| 30 |
| 31 static PresentationAvailability* create(ExecutionContext*, bool); |
| 32 ~PresentationAvailability() override; |
| 33 |
| 34 // EventTarget implementation. |
| 35 const AtomicString& interfaceName() const override; |
| 36 ExecutionContext* executionContext() const override; |
| 37 |
| 38 // WebPresentationAvailabilityObserver implementation. |
| 39 void availabilityChanged(bool) override; |
| 40 |
| 41 // ActiveDOMObject implementation. |
| 42 bool hasPendingActivity() const override; |
| 43 void suspend() override; |
| 44 void resume() override; |
| 45 void stop() override; |
| 46 |
| 47 bool value() const; |
| 48 |
| 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| 50 |
| 51 DECLARE_VIRTUAL_TRACE(); |
| 52 |
| 53 private: |
| 54 PresentationAvailability(ExecutionContext*, bool); |
| 55 |
| 56 void startListening(); |
| 57 void stopListening(); |
| 58 |
| 59 bool m_value; |
| 60 bool m_listening; |
| 61 }; |
| 62 |
| 63 } // namespace blink |
| 64 |
| 65 #endif // PresentationAvailability_h |
OLD | NEW |