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

Unified Diff: content/browser/media/media_web_contents_observer.h

Issue 2399023002: Make MediaSession available on Desktop (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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media/media_web_contents_observer.h
diff --git a/content/browser/media/media_web_contents_observer.h b/content/browser/media/media_web_contents_observer.h
index 5d6d8d2f5ff92d2f54f53bafcd1e03aa7642cab7..e1aa80c66c192d9161f09db345763faa2cc13353 100644
--- a/content/browser/media/media_web_contents_observer.h
+++ b/content/browser/media/media_web_contents_observer.h
@@ -11,6 +11,7 @@
#include <memory>
#include <set>
+#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h"
#include "content/browser/media/session/media_session_controllers_manager.h"
#include "content/common/content_export.h"
@@ -30,6 +31,8 @@ enum class MediaContentType;
namespace content {
+class BrowserMediaSessionManager;
+
// This class manages all RenderFrame based media related managers at the
// browser side. It receives IPC messages from media RenderFrameObservers and
// forwards them to the corresponding managers. The managers are responsible
@@ -39,6 +42,18 @@ class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver {
explicit MediaWebContentsObserver(WebContents* web_contents);
~MediaWebContentsObserver() override;
+ // Gets the BrowserMediaSessionManager associated with the given
+ // |render_frame_host|. Creates a new one if it doesn't exist. The caller
+ // doesn't own the returned pointer.
+ BrowserMediaSessionManager* GetMediaSessionManager(
+ RenderFrameHost* render_frame_host);
+
+ // Sets or overrides the BrowserMediaSessionManager for the given
+ // |render_frame_host|.
+ void SetMediaSessionManagerForTest(
+ RenderFrameHost* render_frame_host,
+ std::unique_ptr<BrowserMediaSessionManager> manager);
+
// Called by WebContentsImpl when the audible state may have changed.
void MaybeUpdateAudibleState();
@@ -109,6 +124,12 @@ class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver {
MediaSessionControllersManager session_controllers_manager_;
+ // Map from RenderFrameHost* to BrowserMediaSessionManager.
+ using MediaSessionManagerMap =
+ base::ScopedPtrHashMap<RenderFrameHost*,
+ std::unique_ptr<BrowserMediaSessionManager>>;
+ MediaSessionManagerMap media_session_managers_;
+
DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver);
};

Powered by Google App Engine
This is Rietveld 408576698