Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: third_party/WebKit/Source/modules/mediasession/MediaSession.h

Issue 2428523002: Add media controls to MediaSession in Blink (Closed)
Patch Set: rebased Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "modules/ModulesExport.h" 10 #include "modules/ModulesExport.h"
10 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
11 #include "public/platform/modules/mediasession/media_session.mojom-blink.h" 12 #include "public/platform/modules/mediasession/media_session.mojom-blink.h"
12 #include <memory> 13 #include <memory>
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class MediaMetadata; 17 class MediaMetadata;
17 class ScriptState; 18 class ScriptState;
18 19
19 class MODULES_EXPORT MediaSession final 20 class MODULES_EXPORT MediaSession final : public EventTargetWithInlineData {
20 : public GarbageCollectedFinalized<MediaSession>,
21 public ScriptWrappable {
22 DEFINE_WRAPPERTYPEINFO(); 21 DEFINE_WRAPPERTYPEINFO();
23 22
24 public: 23 public:
25 static MediaSession* create(); 24 static MediaSession* create(ScriptState*);
26 25
27 void setMetadata(ScriptState*, MediaMetadata*); 26 void setMetadata(MediaMetadata*);
28 MediaMetadata* metadata(ScriptState*) const; 27 MediaMetadata* metadata() const;
28
29 // EventTarget implementation.
30 const WTF::AtomicString& interfaceName() const override;
31 ExecutionContext* getExecutionContext() const override;
32
33 DEFINE_ATTRIBUTE_EVENT_LISTENER(play);
34 DEFINE_ATTRIBUTE_EVENT_LISTENER(pause);
35 DEFINE_ATTRIBUTE_EVENT_LISTENER(playpause);
36 DEFINE_ATTRIBUTE_EVENT_LISTENER(previoustrack);
37 DEFINE_ATTRIBUTE_EVENT_LISTENER(nexttrack);
38 DEFINE_ATTRIBUTE_EVENT_LISTENER(seekforward);
39 DEFINE_ATTRIBUTE_EVENT_LISTENER(seekbackward);
29 40
30 DECLARE_VIRTUAL_TRACE(); 41 DECLARE_VIRTUAL_TRACE();
31 42
32 private: 43 private:
33 friend class MediaSessionTest; 44 friend class MediaSessionTest;
34 45
35 MediaSession(); 46 MediaSession(ScriptState*);
47
48 // EventTarget overrides
49 bool addEventListenerInternal(
50 const AtomicString& eventType,
51 EventListener*,
52 const AddEventListenerOptionsResolved&) override;
53 bool removeEventListenerInternal(const AtomicString& eventType,
54 const EventListener*,
55 const EventListenerOptions&) override;
36 56
37 // Returns null when the ExecutionContext is not document. 57 // Returns null when the ExecutionContext is not document.
38 mojom::blink::MediaSessionService* getService(ScriptState*); 58 mojom::blink::MediaSessionService* getService(ScriptState*);
39 59
60 RefPtr<ScriptState> m_scriptState;
40 Member<MediaMetadata> m_metadata; 61 Member<MediaMetadata> m_metadata;
41 mojom::blink::MediaSessionServicePtr m_service; 62 mojom::blink::MediaSessionServicePtr m_service;
42 }; 63 };
43 64
44 } // namespace blink 65 } // namespace blink
45 66
46 #endif // MediaSession_h 67 #endif // MediaSession_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/mediasession/DEPS ('k') | third_party/WebKit/Source/modules/mediasession/MediaSession.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698