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" | 9 #include "core/dom/ContextLifecycleObserver.h" |
10 #include "core/events/EventTarget.h" | 10 #include "core/events/EventTarget.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 PresentationController; | |
15 class ScriptState; | 16 class ScriptState; |
16 | 17 |
18 // Implements the main entry point of the Presentation API corresponding to the Presentation.idl | |
19 // See http://w3c.github.io/presentation-api/#navigatorpresentation for details. | |
17 class Presentation final | 20 class Presentation final |
18 : public RefCountedGarbageCollectedEventTargetWithInlineData<Presentation> | 21 : public RefCountedGarbageCollectedEventTargetWithInlineData<Presentation> |
19 , public ContextLifecycleObserver { | 22 , public ContextLifecycleObserver { |
20 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<P resentation>); | 23 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<P resentation>); |
21 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Presentation); | 24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Presentation); |
22 DEFINE_WRAPPERTYPEINFO(); | 25 DEFINE_WRAPPERTYPEINFO(); |
23 public: | 26 public: |
24 static Presentation* create(ExecutionContext*); | 27 static Presentation* create(ExecutionContext*); |
25 virtual ~Presentation(); | 28 virtual ~Presentation(); |
26 | 29 |
27 // EventTarget implementation. | 30 // EventTarget implementation. |
28 virtual const AtomicString& interfaceName() const override; | 31 virtual const AtomicString& interfaceName() const override; |
29 virtual ExecutionContext* executionContext() const override; | 32 virtual ExecutionContext* executionContext() const override; |
30 | 33 |
31 virtual void trace(Visitor*) override; | 34 virtual void trace(Visitor*) override; |
32 | 35 |
33 PresentationSession* session() const; | 36 PresentationSession* session() const; |
34 | 37 |
35 ScriptPromise startSession(ScriptState*, const String& senderId, const Strin g& presentationId); | 38 ScriptPromise startSession(ScriptState*, const String& senderId, const Strin g& presentationId); |
36 ScriptPromise joinSession(ScriptState*, const String& senderId, const String & presentationId); | 39 ScriptPromise joinSession(ScriptState*, const String& senderId, const String & presentationId); |
37 | 40 |
38 DEFINE_ATTRIBUTE_EVENT_LISTENER(availablechange); | 41 DEFINE_ATTRIBUTE_EVENT_LISTENER(availablechange); |
39 | 42 |
43 // The embedder needs to keep track if anything is listening to the event so it could stop the | |
44 // might be expensive screen discovery process. | |
45 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture) override; | |
46 virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr<E ventListener>, bool useCapture) override; | |
47 virtual void removeAllEventListeners() override; | |
48 | |
49 // Called when the |availablechange| event needs to be fired. | |
50 void didChangeAvailability(bool available); | |
40 private: | 51 private: |
41 explicit Presentation(ExecutionContext*); | 52 explicit Presentation(ExecutionContext*); |
42 | 53 |
54 // Returns the |PresentationController| object associated with the frame |Pr esentation| corresponds to. | |
55 // Must never return null. | |
56 PresentationController* presentationController(); | |
mlamouri (slow - plz ping)
2015/01/22 23:18:04
Are you sure that this must _never_ return nullptr
whywhat
2015/01/23 19:20:19
Done.
| |
57 | |
43 Member<PresentationSession> m_session; | 58 Member<PresentationSession> m_session; |
44 }; | 59 }; |
45 | 60 |
46 } // namespace blink | 61 } // namespace blink |
47 | 62 |
48 #endif // Presentation_h | 63 #endif // Presentation_h |
OLD | NEW |