Index: Source/modules/presentation/Presentation.h |
diff --git a/Source/modules/presentation/Presentation.h b/Source/modules/presentation/Presentation.h |
index f075f735defa029934d85005b0dfbde8dcd4e0ec..b061d3b33cbaded3a69028a1511fec64d17dd683 100644 |
--- a/Source/modules/presentation/Presentation.h |
+++ b/Source/modules/presentation/Presentation.h |
@@ -6,22 +6,31 @@ |
#define Presentation_h |
#include "bindings/core/v8/ScriptPromise.h" |
-#include "core/dom/ContextLifecycleObserver.h" |
#include "core/events/EventTarget.h" |
+#include "core/frame/DOMWindowProperty.h" |
#include "modules/presentation/PresentationSession.h" |
+#include "platform/heap/Handle.h" |
+ |
+namespace WTF { |
+class String; |
+} // namespace WTF |
namespace blink { |
+class LocalFrame; |
+class PresentationController; |
class ScriptState; |
+// Implements the main entry point of the Presentation API corresponding to the Presentation.idl |
+// See https://w3c.github.io/presentation-api/#navigatorpresentation for details. |
class Presentation final |
: public RefCountedGarbageCollectedEventTargetWithInlineData<Presentation> |
- , public ContextLifecycleObserver { |
+ , public DOMWindowProperty { |
DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<Presentation>); |
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Presentation); |
DEFINE_WRAPPERTYPEINFO(); |
public: |
- static Presentation* create(ExecutionContext*); |
+ static Presentation* create(LocalFrame*); |
virtual ~Presentation(); |
// EventTarget implementation. |
@@ -32,13 +41,27 @@ public: |
PresentationSession* session() const; |
- ScriptPromise startSession(ScriptState*, const String& senderId, const String& presentationId); |
- ScriptPromise joinSession(ScriptState*, const String& senderId, const String& presentationId); |
+ ScriptPromise startSession(ScriptState*, const String& presentationUrl, const String& presentationId); |
+ ScriptPromise joinSession(ScriptState*, const String& presentationUrl, const String& presentationId); |
DEFINE_ATTRIBUTE_EVENT_LISTENER(availablechange); |
+ // The embedder needs to keep track if anything is listening to the event so it could stop the |
+ // might be expensive screen discovery process. |
+ virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture) override; |
+ virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture) override; |
+ virtual void removeAllEventListeners() override; |
+ |
+ // Called when the |availablechange| event needs to be fired. |
+ void didChangeAvailability(bool available); |
+ // Queried by the controller if |availablechange| event has any listeners. |
+ bool isAvailableChangeWatched() const; |
private: |
- explicit Presentation(ExecutionContext*); |
+ explicit Presentation(LocalFrame*); |
+ |
+ // Returns the |PresentationController| object associated with the frame |Presentation| corresponds to. |
+ // Can return |nullptr| if the frame is detached from the document. |
+ PresentationController* presentationController(); |
Member<PresentationSession> m_session; |
}; |