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

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

Issue 2428523002: Add media controls to MediaSession in Blink (Closed)
Patch Set: 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 // Event getters and setters. Not using DEFINE_ATTRIBUTE_EVENT_LISTENER macro
whywhat 2016/10/17 15:32:35 I thought the common way to do it was to override
whywhat 2016/10/17 15:41:46 s/attachEventListener/addEventListener
Zhiqiang Zhang (Slow) 2016/10/17 17:19:08 Thanks. Done. Though there might be a drawback whe
whywhat 2016/10/17 17:32:06 That's already the case with add/removeEventListen
34 // since there are additional actions in setters.
35 EventListener* onplay();
36 EventListener* onpause();
37 EventListener* onplaypause();
38 EventListener* onprevioustrack();
39 EventListener* onnexttrack();
40 EventListener* onseekforward();
41 EventListener* onseekbackward();
42
43 void setOnplay(EventListener*);
44 void setOnpause(EventListener*);
45 void setOnplaypause(EventListener*);
46 void setOnprevioustrack(EventListener*);
47 void setOnnexttrack(EventListener*);
48 void setOnseekforward(EventListener*);
49 void setOnseekbackward(EventListener*);
29 50
30 DECLARE_VIRTUAL_TRACE(); 51 DECLARE_VIRTUAL_TRACE();
31 52
32 private: 53 private:
33 friend class MediaSessionTest; 54 friend class MediaSessionTest;
34 55
35 MediaSession(); 56 MediaSession(ScriptState*);
36 57
37 // Returns null when the ExecutionContext is not document. 58 // Returns null when the ExecutionContext is not document.
38 mojom::blink::MediaSessionService* getService(ScriptState*); 59 mojom::blink::MediaSessionService* getService(ScriptState*);
39 60
61 RefPtr<ScriptState> m_scriptState;
40 Member<MediaMetadata> m_metadata; 62 Member<MediaMetadata> m_metadata;
41 mojom::blink::MediaSessionServicePtr m_service; 63 mojom::blink::MediaSessionServicePtr m_service;
42 }; 64 };
43 65
44 } // namespace blink 66 } // namespace blink
45 67
46 #endif // MediaSession_h 68 #endif // MediaSession_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698