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

Side by Side Diff: content/public/browser/media_session_observer.h

Issue 2442303002: Adding new media controls to MediaNotification (Closed)
Patch Set: rebased onto MediaSession refactoring Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_
6 #define CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_ 6 #define CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/optional.h" 9 #include "base/optional.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "content/public/common/media_metadata.h" 11 #include "content/public/common/media_metadata.h"
12 12
13 namespace blink {
14 namespace mojom {
15 enum class MediaSessionAction;
16 } // namespace mojom
17 } // namespace blink
18
13 namespace content { 19 namespace content {
14 20
15 class MediaSession; 21 class MediaSession;
16 class MediaSessionImpl; 22 class MediaSessionImpl;
17 23
18 // The observer for observing MediaSession events. 24 // The observer for observing MediaSession events.
19 class CONTENT_EXPORT MediaSessionObserver { 25 class CONTENT_EXPORT MediaSessionObserver {
20 public: 26 public:
21 // Gets the observed MediaSession. 27 // Gets the observed MediaSession.
22 MediaSession* media_session() const; 28 MediaSession* media_session() const;
23 29
24 // Called when the observed MediaSession is being destroyed. Gives subclass a 30 // Called when the observed MediaSession is being destroyed. Gives subclass a
25 // chance to cleanup. After the whole loop over MediaSessionObservers has been 31 // chance to cleanup. After the whole loop over MediaSessionObservers has been
26 // finished, media_session() returns nullptr. 32 // finished, media_session() returns nullptr.
27 virtual void MediaSessionDestroyed() {} 33 virtual void MediaSessionDestroyed() {}
28 34
29 // Called when the observed MediaSession has changed its state. 35 // Called when the observed MediaSession has changed its state.
30 virtual void MediaSessionStateChanged(bool is_controllable, 36 virtual void MediaSessionStateChanged(bool is_controllable,
31 bool is_suspended) {} 37 bool is_suspended) {}
32 38
33 // Called when the observed MediaSession has changed metadata. 39 // Called when the observed MediaSession has changed metadata.
34 virtual void MediaSessionMetadataChanged( 40 virtual void MediaSessionMetadataChanged(
35 const base::Optional<MediaMetadata>& metadata) {} 41 const base::Optional<MediaMetadata>& metadata) {}
36 42
43 // Called when media session action is enabled.
44 virtual void MediaSessionEnabledAction(
45 blink::mojom::MediaSessionAction action) {}
46
47 // Called when media session action is disabled.
48 virtual void MediaSessionDisabledAction(
49 blink::mojom::MediaSessionAction action) {}
50
37 protected: 51 protected:
38 // Create a MediaSessionObserver and start observing |session|. 52 // Create a MediaSessionObserver and start observing |session|.
39 explicit MediaSessionObserver(MediaSession* session); 53 explicit MediaSessionObserver(MediaSession* session);
40 54
41 // Destructor of MediaSessionObserver. It will remove itself from |session| if 55 // Destructor of MediaSessionObserver. It will remove itself from |session| if
42 // the observer is still observing a MediaSession. 56 // the observer is still observing a MediaSession.
43 virtual ~MediaSessionObserver(); 57 virtual ~MediaSessionObserver();
44 58
45 private: 59 private:
46 friend class MediaSessionImpl; 60 friend class MediaSessionImpl;
47 61
48 void StopObserving(); 62 void StopObserving();
49 63
50 // Weak pointer to MediaSession. 64 // Weak pointer to MediaSession.
51 MediaSessionImpl* session_; 65 MediaSessionImpl* session_;
52 66
53 DISALLOW_COPY_AND_ASSIGN(MediaSessionObserver); 67 DISALLOW_COPY_AND_ASSIGN(MediaSessionObserver);
54 }; 68 };
55 69
56 } // namespace content 70 } // namespace content
57 71
58 #endif // CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_ 72 #endif // CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698