Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 Presentation_h | 5 #ifndef Presentation_h |
| 6 #define Presentation_h | 6 #define Presentation_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "core/dom/ContextLifecycleObserver.h" | |
| 10 #include "core/events/EventTarget.h" | 9 #include "core/events/EventTarget.h" |
| 10 #include "core/frame/FrameDestructionObserver.h" | |
| 11 #include "modules/presentation/PresentationSession.h" | 11 #include "modules/presentation/PresentationSession.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class LocalFrame; | |
| 16 class PresentationController; | |
| 15 class ScriptState; | 17 class ScriptState; |
| 16 | 18 |
| 19 // Implements the main entry point of the Presentation API corresponding to the Presentation.idl | |
| 20 // See https://w3c.github.io/presentation-api/#navigatorpresentation for details . | |
| 17 class Presentation final | 21 class Presentation final |
| 18 : public RefCountedGarbageCollectedEventTargetWithInlineData<Presentation> | 22 : public RefCountedGarbageCollectedEventTargetWithInlineData<Presentation> |
| 19 , public ContextLifecycleObserver { | 23 , public FrameDestructionObserver { |
| 20 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<P resentation>); | 24 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<P resentation>); |
| 21 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Presentation); | 25 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Presentation); |
| 22 DEFINE_WRAPPERTYPEINFO(); | 26 DEFINE_WRAPPERTYPEINFO(); |
| 23 public: | 27 public: |
| 24 static Presentation* create(ExecutionContext*); | 28 static Presentation* create(LocalFrame*); |
| 25 virtual ~Presentation(); | 29 virtual ~Presentation(); |
| 26 | 30 |
| 27 // EventTarget implementation. | 31 // EventTarget implementation. |
| 28 virtual const AtomicString& interfaceName() const override; | 32 virtual const AtomicString& interfaceName() const override; |
|
mark a. foltz
2015/01/26 19:53:38
Do AtomicString, String, ExecutionContext, Visitor
whywhat
2015/01/27 13:51:24
I don't usually forward declare types required in
| |
| 29 virtual ExecutionContext* executionContext() const override; | 33 virtual ExecutionContext* executionContext() const override; |
| 30 | 34 |
| 31 virtual void trace(Visitor*) override; | 35 virtual void trace(Visitor*) override; |
| 32 | 36 |
| 33 PresentationSession* session() const; | 37 PresentationSession* session() const; |
| 34 | 38 |
| 35 ScriptPromise startSession(ScriptState*, const String& senderId, const Strin g& presentationId); | 39 ScriptPromise startSession(ScriptState*, const String& senderId, const Strin g& presentationId); |
|
mark a. foltz
2015/01/26 19:53:38
Which parameter conveys the presented URL? Should
whywhat
2015/01/27 13:51:24
Yes, a copy/paste error from some old API referenc
| |
| 36 ScriptPromise joinSession(ScriptState*, const String& senderId, const String & presentationId); | 40 ScriptPromise joinSession(ScriptState*, const String& senderId, const String & presentationId); |
|
mark a. foltz
2015/01/26 19:53:38
Ditto
whywhat
2015/01/27 13:51:24
Done.
| |
| 37 | 41 |
| 38 DEFINE_ATTRIBUTE_EVENT_LISTENER(availablechange); | 42 DEFINE_ATTRIBUTE_EVENT_LISTENER(availablechange); |
| 39 | 43 |
| 44 // The embedder needs to keep track if anything is listening to the event so it could stop the | |
| 45 // might be expensive screen discovery process. | |
| 46 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture) override; | |
| 47 virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr<E ventListener>, bool useCapture) override; | |
| 48 virtual void removeAllEventListeners() override; | |
| 49 | |
| 50 // Called when the |availablechange| event needs to be fired. | |
| 51 void didChangeAvailability(bool available); | |
| 52 // Queried by the controller if |availablechange| event has any listeners. | |
| 53 bool isAvailableChangeWatched() const; | |
| 40 private: | 54 private: |
| 41 explicit Presentation(ExecutionContext*); | 55 explicit Presentation(LocalFrame*); |
| 56 | |
| 57 // Returns the |PresentationController| object associated with the frame |Pr esentation| corresponds to. | |
| 58 // Can return |nullptr| if the frame is detached from the document. | |
| 59 PresentationController* presentationController(); | |
| 42 | 60 |
| 43 Member<PresentationSession> m_session; | 61 Member<PresentationSession> m_session; |
| 44 }; | 62 }; |
| 45 | 63 |
| 46 } // namespace blink | 64 } // namespace blink |
| 47 | 65 |
| 48 #endif // Presentation_h | 66 #endif // Presentation_h |
| OLD | NEW |