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

Unified Diff: content/browser/media/android/browser_media_session_manager.cc

Issue 1308983005: NOT FOR LANDING Implement WebMediaSession (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add forward declaration Created 4 years, 11 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/android/browser_media_session_manager.cc
diff --git a/content/browser/media/android/browser_media_session_manager.cc b/content/browser/media/android/browser_media_session_manager.cc
index 146a60fe970ae9da7f0fe9a4b56f044ecdfeec77..10d3a56f56e36b2fb3a4d29676c3bb6713a79088 100644
--- a/content/browser/media/android/browser_media_session_manager.cc
+++ b/content/browser/media/android/browser_media_session_manager.cc
@@ -13,13 +13,32 @@ BrowserMediaSessionManager::BrowserMediaSessionManager(
RenderFrameHost* render_frame_host)
: render_frame_host_(render_frame_host) {}
+MediaSession* BrowserMediaSessionManager::GetSession(int session_id) {
+ WebContents* web_contents =
+ WebContents::FromRenderFrameHost(render_frame_host_);
+
+ if (session_id == 0)
+ return MediaSession::Get(web_contents);
+
+ for (ScopedVector<MediaSession>::iterator it = sessions_.begin();
+ it != sessions_.end(); ++it) {
+ if ((*it)->session_id() == session_id)
+ return *it;
+ }
+
+ MediaSession* session = MediaSession::Create(web_contents, session_id);
+ sessions_.push_back(session);
+ return session;
+}
+
void BrowserMediaSessionManager::OnActivate(int session_id, int request_id) {
- NOTIMPLEMENTED();
- Send(new MediaSessionMsg_DidActivate(GetRoutingID(), request_id, false));
+ bool success = GetSession(session_id)->Activate();
+ Send(new MediaSessionMsg_DidActivate(GetRoutingID(), request_id, success));
}
void BrowserMediaSessionManager::OnDeactivate(int session_id, int request_id) {
- NOTIMPLEMENTED();
+ if (MediaSession* media_session = GetSession(session_id))
+ media_session->Deactivate();
Send(new MediaSessionMsg_DidDeactivate(GetRoutingID(), request_id));
}
@@ -27,6 +46,40 @@ int BrowserMediaSessionManager::GetRoutingID() const {
return render_frame_host_->GetRoutingID();
}
+void BrowserMediaSessionManager::RemovePlayers(MediaSessionObserver* observer) {
+ // Remove observer from default session and user created sessions.
+
+ WebContents* web_contents =
+ WebContents::FromRenderFrameHost(render_frame_host_);
+ MediaSession::Get(web_contents)->RemovePlayers(observer);
+
+ for (ScopedVector<MediaSession>::iterator it = sessions_.begin();
+ it != sessions_.end(); ++it)
+ (*it)->RemovePlayers(observer);
+}
+
+void BrowserMediaSessionManager::RemovePlayer(MediaSessionObserver* observer,
+ int player_id) {
+ WebContents* web_contents =
+ WebContents::FromRenderFrameHost(render_frame_host_);
+ MediaSession::Get(web_contents)->RemovePlayer(observer, player_id);
+
+ for (ScopedVector<MediaSession>::iterator it = sessions_.begin();
+ it != sessions_.end(); ++it)
+ (*it)->RemovePlayer(observer, player_id);
+}
+
+void BrowserMediaSessionManager::OnPlayerPaused(MediaSessionObserver* observer,
+ int player_id) {
+ WebContents* web_contents =
+ WebContents::FromRenderFrameHost(render_frame_host_);
+ MediaSession::Get(web_contents)->OnPlayerPaused(observer, player_id);
+
+ for (ScopedVector<MediaSession>::iterator it = sessions_.begin();
+ it != sessions_.end(); ++it)
+ (*it)->OnPlayerPaused(observer, player_id);
+}
+
bool BrowserMediaSessionManager::Send(IPC::Message* msg) {
return render_frame_host_->Send(msg);
}
« no previous file with comments | « content/browser/media/android/browser_media_session_manager.h ('k') | content/browser/media/android/media_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698