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 PresentationSession_h | 5 #ifndef PresentationSession_h |
6 #define PresentationSession_h | 6 #define PresentationSession_h |
7 | 7 |
8 #include "core/events/EventTarget.h" | 8 #include "core/events/EventTarget.h" |
9 #include "core/frame/DOMWindowProperty.h" | 9 #include "core/frame/DOMWindowProperty.h" |
10 #include "wtf/text/AtomicString.h" | 10 #include "public/platform/modules/presentation/WebPresentationSessionClient.h" |
11 #include "wtf/text/WTFString.h" | 11 #include "wtf/text/WTFString.h" |
12 | 12 |
| 13 namespace WTF { |
| 14 class AtomicString; |
| 15 } // namespace WTF |
| 16 |
13 namespace blink { | 17 namespace blink { |
14 | 18 |
15 class Presentation; | 19 class Presentation; |
16 class PresentationController; | 20 class PresentationController; |
17 class WebPresentationSessionClient; | |
18 class WebString; | |
19 | 21 |
20 class PresentationSession final | 22 class PresentationSession final |
21 : public RefCountedGarbageCollectedEventTargetWithInlineData<PresentationSes
sion> | 23 : public RefCountedGarbageCollectedEventTargetWithInlineData<PresentationSes
sion> |
22 , public DOMWindowProperty { | 24 , public DOMWindowProperty { |
23 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<P
resentationSession>); | 25 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<P
resentationSession>); |
24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PresentationSession); | 26 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PresentationSession); |
25 DEFINE_WRAPPERTYPEINFO(); | 27 DEFINE_WRAPPERTYPEINFO(); |
26 public: | 28 public: |
27 static PresentationSession* take(WebPresentationSessionClient*, Presentation
*); | 29 static PresentationSession* take(WebPresentationSessionClient*, Presentation
*); |
28 static void dispose(WebPresentationSessionClient*); | 30 static void dispose(WebPresentationSessionClient*); |
29 virtual ~PresentationSession(); | 31 virtual ~PresentationSession(); |
30 | 32 |
31 // EventTarget implementation. | 33 // EventTarget implementation. |
32 virtual const AtomicString& interfaceName() const override; | 34 virtual const AtomicString& interfaceName() const override; |
33 virtual ExecutionContext* executionContext() const override; | 35 virtual ExecutionContext* executionContext() const override; |
34 | 36 |
35 DECLARE_VIRTUAL_TRACE(); | 37 DECLARE_VIRTUAL_TRACE(); |
36 | 38 |
37 const String& id() const { return m_id; } | 39 const String id() const { return m_id; } |
38 const AtomicString& state() const { return m_state; } | 40 const WTF::AtomicString& state() const; |
39 | 41 |
40 void postMessage(const String& message); | 42 void postMessage(const String& message); |
41 void close(); | 43 void close(); |
42 | 44 |
43 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 45 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
44 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 46 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
45 | 47 |
| 48 // Returns true if and only if the WebPresentationSessionClient represents t
his session. |
| 49 bool matches(WebPresentationSessionClient*) const; |
| 50 |
| 51 // Notifies the session about its state change. |
| 52 void didChangeState(WebPresentationSessionState); |
| 53 |
46 private: | 54 private: |
47 PresentationSession(LocalFrame*, const WebString& id, const WebString& url); | 55 PresentationSession(LocalFrame*, const String& id, const String& url); |
48 | 56 |
49 // Returns the |PresentationController| object associated with the frame | 57 // Returns the |PresentationController| object associated with the frame |
50 // |Presentation| corresponds to. Can return |nullptr| if the frame is | 58 // |Presentation| corresponds to. Can return |nullptr| if the frame is |
51 // detached from the document. | 59 // detached from the document. |
52 PresentationController* presentationController(); | 60 PresentationController* presentationController(); |
53 | 61 |
54 String m_id; | 62 String m_id; |
55 String m_url; | 63 String m_url; |
56 AtomicString m_state; | 64 WebPresentationSessionState m_state; |
57 }; | 65 }; |
58 | 66 |
59 } // namespace blink | 67 } // namespace blink |
60 | 68 |
61 #endif // PresentationSession_h | 69 #endif // PresentationSession_h |
OLD | NEW |