| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 RefCountedGarbageCollectedEventTargetWithInlineData<PresentationAva
ilability> | 27 : public RefCountedGarbageCollectedEventTargetWithInlineData<PresentationAva
ilability> |
| 28 , public ActiveScriptWrappable | 28 , public ActiveScriptWrappable |
| 29 , public ActiveDOMObject | 29 , public ActiveDOMObject |
| 30 , public PageLifecycleObserver | 30 , public PageLifecycleObserver |
| 31 , public WebPresentationAvailabilityObserver { | 31 , public WebPresentationAvailabilityObserver { |
| 32 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PresentationAvailability); | 32 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PresentationAvailability); |
| 33 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability); | 33 USING_GARBAGE_COLLECTED_MIXIN(PresentationAvailability); |
| 34 DEFINE_WRAPPERTYPEINFO(); | 34 DEFINE_WRAPPERTYPEINFO(); |
| 35 public: | 35 public: |
| 36 static PresentationAvailability* take(ScriptPromiseResolver*, const KURL&, b
ool); | 36 static PresentationAvailability* take(ScriptPromiseResolver*, const KURL&, b
ool); |
| 37 ~PresentationAvailability() override; | 37 ~PresentationAvailability() override; |
| 38 | 38 |
| 39 // EventTarget implementation. | 39 // EventTarget implementation. |
| 40 const AtomicString& interfaceName() const override; | 40 const AtomicString& interfaceName() const override; |
| 41 ExecutionContext* getExecutionContext() const override; | 41 ExecutionContext* getExecutionContext() const override; |
| 42 | 42 |
| 43 // WebPresentationAvailabilityObserver implementation. | 43 // WebPresentationAvailabilityObserver implementation. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 56 void pageVisibilityChanged() override; | 56 void pageVisibilityChanged() override; |
| 57 | 57 |
| 58 bool value() const; | 58 bool value() const; |
| 59 | 59 |
| 60 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); | 60 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| 61 | 61 |
| 62 DECLARE_VIRTUAL_TRACE(); | 62 DECLARE_VIRTUAL_TRACE(); |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 // EventTarget implementation. | 65 // EventTarget implementation. |
| 66 bool addEventListenerInternal(const AtomicString& eventType, PassRefPtrWillB
eRawPtr<EventListener>, const EventListenerOptions&) override; | 66 bool addEventListenerInternal(const AtomicString& eventType, RawPtr<EventLis
tener>, const EventListenerOptions&) override; |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 // Current state of the ActiveDOMObject. It is Active when created. It | 69 // Current state of the ActiveDOMObject. It is Active when created. It |
| 70 // becomes Suspended when suspend() is called and moves back to Active if | 70 // becomes Suspended when suspend() is called and moves back to Active if |
| 71 // resume() is called. It becomes Inactive when stop() is called or at | 71 // resume() is called. It becomes Inactive when stop() is called or at |
| 72 // destruction time. | 72 // destruction time. |
| 73 enum class State : char { | 73 enum class State : char { |
| 74 Active, | 74 Active, |
| 75 Suspended, | 75 Suspended, |
| 76 Inactive, | 76 Inactive, |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 PresentationAvailability(ExecutionContext*, const KURL&, bool); | 79 PresentationAvailability(ExecutionContext*, const KURL&, bool); |
| 80 | 80 |
| 81 void setState(State); | 81 void setState(State); |
| 82 void updateListening(); | 82 void updateListening(); |
| 83 | 83 |
| 84 const KURL m_url; | 84 const KURL m_url; |
| 85 bool m_value; | 85 bool m_value; |
| 86 State m_state; | 86 State m_state; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace blink | 89 } // namespace blink |
| 90 | 90 |
| 91 #endif // PresentationAvailability_h | 91 #endif // PresentationAvailability_h |
| OLD | NEW |