Index: content/browser/media/session/media_session.h |
diff --git a/content/browser/media/session/media_session.h b/content/browser/media/session/media_session.h |
index 9239c7854a18b18326e2c2983451e49490922982..5641f0708be67c7164faf68e1dc89b5cbdde953d 100644 |
--- a/content/browser/media/session/media_session.h |
+++ b/content/browser/media/session/media_session.h |
@@ -7,9 +7,11 @@ |
#include <stddef.h> |
+#include "base/android/scoped_java_ref.h" |
#include "base/callback_list.h" |
#include "base/id_map.h" |
#include "base/macros.h" |
+#include "base/observer_list.h" |
#include "base/optional.h" |
#include "content/browser/media/session/audio_focus_manager.h" |
#include "content/browser/media/session/media_session_uma_helper.h" |
@@ -29,9 +31,14 @@ namespace content { |
class AudioFocusDelegate; |
class AudioFocusManagerTest; |
class MediaSessionPlayerObserver; |
+class MediaSessionObserver; |
class MediaSessionStateObserver; |
class MediaSessionVisibilityBrowserTest; |
+#if defined(OS_ANDROID) |
+class MediaSessionAndroid; |
+#endif // defined(OS_ANDROID) |
+ |
// MediaSession manages the media session and audio focus for a given |
// WebContents. It is requesting the audio focus, pausing when requested by the |
// system and dropping it on demand. |
@@ -71,6 +78,22 @@ class MediaSession : public WebContentsObserver, |
~MediaSession() override; |
+#if defined(OS_ANDROID) |
+ static MediaSession* FromJavaMediaSession( |
+ const base::android::JavaRef<jobject>& j_media_session); |
+ MediaSessionAndroid* session_android() const { |
+ return session_android_.get(); |
+ } |
+#endif // defined(OS_ANDROID) |
+ |
+ // Add and remove an observer for MediaSession messages. Clients must remove |
+ // the observer before they go away, or pass the observer ownership to |
+ // MediaSession via PassObserverOwnership (then the observer will go away when |
+ // the session is destroyed. AddObserver() can only be called in |
+ // MediaSessionObserver constructor, and cannot be called explicitly. |
+ void AddObserver(MediaSessionObserver* observer); |
+ void RemoveObserver(MediaSessionObserver* observer); |
+ |
void SetMetadata(const base::Optional<MediaMetadata>& metadata); |
const base::Optional<MediaMetadata>& metadata() const { return metadata_; } |
@@ -237,6 +260,13 @@ class MediaSession : public WebContentsObserver, |
base::Optional<MediaMetadata> metadata_; |
base::CallbackList<void(State)> media_session_state_listeners_; |
+ // The list of observers notified when the MediaSession changes. |
+ base::ObserverList<MediaSessionObserver> observers_; |
+ |
+#if defined(OS_ANDROID) |
+ std::unique_ptr<MediaSessionAndroid> session_android_; |
+#endif // defined(OS_ANDROID) |
+ |
DISALLOW_COPY_AND_ASSIGN(MediaSession); |
}; |