| 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 "core/dom/ActiveDOMObject.h" | 8 #include "core/dom/ActiveDOMObject.h" |
| 9 #include "core/events/EventTarget.h" | 9 #include "core/events/EventTarget.h" |
| 10 #include "core/page/PageLifecycleObserver.h" | 10 #include "core/page/PageLifecycleObserver.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // Expose whether there is a presentation display available for |url|. The | 21 // Expose whether there is a presentation display available for |url|. The |
| 22 // object will be initialized with a default value passed via ::take() and will | 22 // object will be initialized with a default value passed via ::take() and will |
| 23 // then subscribe to receive callbacks if the status for |url| were to | 23 // then subscribe to receive callbacks if the status for |url| were to |
| 24 // change. The object will only listen to changes when required. | 24 // change. The object will only listen to changes when required. |
| 25 class MODULES_EXPORT PresentationAvailability final | 25 class MODULES_EXPORT PresentationAvailability final |
| 26 : public RefCountedGarbageCollectedEventTargetWithInlineData<PresentationAva
ilability> | 26 : public RefCountedGarbageCollectedEventTargetWithInlineData<PresentationAva
ilability> |
| 27 , public ActiveDOMObject | 27 , public ActiveDOMObject |
| 28 , public PageLifecycleObserver | 28 , public PageLifecycleObserver |
| 29 , public WebPresentationAvailabilityObserver { | 29 , public WebPresentationAvailabilityObserver { |
| 30 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PresentationAvailability); | 30 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PresentationAvailability); |
| 31 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability); | 31 USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability); |
| 32 DEFINE_WRAPPERTYPEINFO(); | 32 DEFINE_WRAPPERTYPEINFO(); |
| 33 public: | 33 public: |
| 34 static PresentationAvailability* take(ScriptPromiseResolver*, const KURL&, b
ool); | 34 static PresentationAvailability* take(ScriptPromiseResolver*, const KURL&, b
ool); |
| 35 ~PresentationAvailability() override; | 35 ~PresentationAvailability() override; |
| 36 | 36 |
| 37 // EventTarget implementation. | 37 // EventTarget implementation. |
| 38 const AtomicString& interfaceName() const override; | 38 const AtomicString& interfaceName() const override; |
| 39 ExecutionContext* executionContext() const override; | 39 ExecutionContext* executionContext() const override; |
| 40 | 40 |
| 41 // WebPresentationAvailabilityObserver implementation. | 41 // WebPresentationAvailabilityObserver implementation. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 void pageVisibilityChanged() override; | 52 void pageVisibilityChanged() override; |
| 53 | 53 |
| 54 bool value() const; | 54 bool value() const; |
| 55 | 55 |
| 56 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); | 56 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| 57 | 57 |
| 58 DECLARE_VIRTUAL_TRACE(); | 58 DECLARE_VIRTUAL_TRACE(); |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 // EventTarget implementation. | 61 // EventTarget implementation. |
| 62 bool addEventListenerInternal(const AtomicString& eventType, PassRefPtrWillB
eRawPtr<EventListener>, const EventListenerOptions&) override; | 62 bool addEventListenerInternal(const AtomicString& eventType, RawPtr<EventLis
tener>, const EventListenerOptions&) override; |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 // Current state of the ActiveDOMObject. It is Active when created. It | 65 // Current state of the ActiveDOMObject. It is Active when created. It |
| 66 // becomes Suspended when suspend() is called and moves back to Active if | 66 // becomes Suspended when suspend() is called and moves back to Active if |
| 67 // resume() is called. It becomes Inactive when stop() is called or at | 67 // resume() is called. It becomes Inactive when stop() is called or at |
| 68 // destruction time. | 68 // destruction time. |
| 69 enum class State : char { | 69 enum class State : char { |
| 70 Active, | 70 Active, |
| 71 Suspended, | 71 Suspended, |
| 72 Inactive, | 72 Inactive, |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 PresentationAvailability(ExecutionContext*, const KURL&, bool); | 75 PresentationAvailability(ExecutionContext*, const KURL&, bool); |
| 76 | 76 |
| 77 void setState(State); | 77 void setState(State); |
| 78 void updateListening(); | 78 void updateListening(); |
| 79 | 79 |
| 80 const KURL m_url; | 80 const KURL m_url; |
| 81 bool m_value; | 81 bool m_value; |
| 82 State m_state; | 82 State m_state; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace blink | 85 } // namespace blink |
| 86 | 86 |
| 87 #endif // PresentationAvailability_h | 87 #endif // PresentationAvailability_h |
| OLD | NEW |