| 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 MediaSession_h | 5 #ifndef MediaSession_h |
| 6 #define MediaSession_h | 6 #define MediaSession_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "core/events/EventTarget.h" | 9 #include "core/events/EventTarget.h" |
| 10 #include "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" |
| 11 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 12 #include "public/platform/modules/mediasession/media_session.mojom-blink.h" | 13 #include "public/platform/modules/mediasession/media_session.mojom-blink.h" |
| 13 #include <memory> | 14 #include <memory> |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 class MediaMetadata; | 18 class MediaMetadata; |
| 18 class ScriptState; | 19 class ScriptState; |
| 19 | 20 |
| 20 class MODULES_EXPORT MediaSession final : public EventTargetWithInlineData { | 21 class MODULES_EXPORT MediaSession final |
| 22 : public EventTargetWithInlineData, |
| 23 blink::mojom::blink::MediaSessionClient { |
| 21 DEFINE_WRAPPERTYPEINFO(); | 24 DEFINE_WRAPPERTYPEINFO(); |
| 25 USING_PRE_FINALIZER(MediaSession, dispose); |
| 22 | 26 |
| 23 public: | 27 public: |
| 24 static MediaSession* create(ScriptState*); | 28 static MediaSession* create(ScriptState*); |
| 25 | 29 |
| 30 void dispose(); |
| 31 |
| 26 void setMetadata(MediaMetadata*); | 32 void setMetadata(MediaMetadata*); |
| 27 MediaMetadata* metadata() const; | 33 MediaMetadata* metadata() const; |
| 28 | 34 |
| 29 // EventTarget implementation. | 35 // EventTarget implementation. |
| 30 const WTF::AtomicString& interfaceName() const override; | 36 const WTF::AtomicString& interfaceName() const override; |
| 31 ExecutionContext* getExecutionContext() const override; | 37 ExecutionContext* getExecutionContext() const override; |
| 32 | 38 |
| 33 DEFINE_ATTRIBUTE_EVENT_LISTENER(play); | 39 DEFINE_ATTRIBUTE_EVENT_LISTENER(play); |
| 34 DEFINE_ATTRIBUTE_EVENT_LISTENER(pause); | 40 DEFINE_ATTRIBUTE_EVENT_LISTENER(pause); |
| 35 DEFINE_ATTRIBUTE_EVENT_LISTENER(playpause); | 41 DEFINE_ATTRIBUTE_EVENT_LISTENER(playpause); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 | 53 |
| 48 // EventTarget overrides | 54 // EventTarget overrides |
| 49 bool addEventListenerInternal( | 55 bool addEventListenerInternal( |
| 50 const AtomicString& eventType, | 56 const AtomicString& eventType, |
| 51 EventListener*, | 57 EventListener*, |
| 52 const AddEventListenerOptionsResolved&) override; | 58 const AddEventListenerOptionsResolved&) override; |
| 53 bool removeEventListenerInternal(const AtomicString& eventType, | 59 bool removeEventListenerInternal(const AtomicString& eventType, |
| 54 const EventListener*, | 60 const EventListener*, |
| 55 const EventListenerOptions&) override; | 61 const EventListenerOptions&) override; |
| 56 | 62 |
| 63 // blink::mojom::blink::MediaSessionClient implementation. |
| 64 void DidReceiveAction(blink::mojom::blink::MediaSessionAction) override; |
| 65 |
| 57 // Returns null when the ExecutionContext is not document. | 66 // Returns null when the ExecutionContext is not document. |
| 58 mojom::blink::MediaSessionService* getService(ScriptState*); | 67 mojom::blink::MediaSessionService* getService(ScriptState*); |
| 59 | 68 |
| 60 RefPtr<ScriptState> m_scriptState; | 69 RefPtr<ScriptState> m_scriptState; |
| 61 Member<MediaMetadata> m_metadata; | 70 Member<MediaMetadata> m_metadata; |
| 62 mojom::blink::MediaSessionServicePtr m_service; | 71 mojom::blink::MediaSessionServicePtr m_service; |
| 72 mojo::Binding<blink::mojom::blink::MediaSessionClient> m_clientBinding; |
| 63 }; | 73 }; |
| 64 | 74 |
| 65 } // namespace blink | 75 } // namespace blink |
| 66 | 76 |
| 67 #endif // MediaSession_h | 77 #endif // MediaSession_h |
| OLD | NEW |