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

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

Issue 1698933004: Make MediaSession a runtime-enabled feature on Desktop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
« no previous file with comments | « content/browser/media/media_web_contents_observer.h ('k') | content/browser/media/session/OWNERS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/media_web_contents_observer.cc
diff --git a/content/browser/media/media_web_contents_observer.cc b/content/browser/media/media_web_contents_observer.cc
index 1123974df7b63597f042420cbbd1bdb681a89175..654f99cfa4e69dfd1daef72143e5f2ca048d3d97 100644
--- a/content/browser/media/media_web_contents_observer.cc
+++ b/content/browser/media/media_web_contents_observer.cc
@@ -26,7 +26,8 @@ static base::LazyInstance<AudibleMetrics>::Leaky g_audible_metrics =
} // anonymous namespace
MediaWebContentsObserver::MediaWebContentsObserver(WebContents* web_contents)
- : WebContentsObserver(web_contents) {}
+ : WebContentsObserver(web_contents),
+ session_controllers_manager_(this) {}
MediaWebContentsObserver::~MediaWebContentsObserver() {}
@@ -37,6 +38,7 @@ void MediaWebContentsObserver::WebContentsDestroyed() {
void MediaWebContentsObserver::RenderFrameDeleted(
RenderFrameHost* render_frame_host) {
ClearPowerSaveBlockers(render_frame_host);
+ session_controllers_manager_.RenderFrameDeleted(render_frame_host);
}
void MediaWebContentsObserver::MaybeUpdateAudibleState() {
@@ -93,19 +95,26 @@ void MediaWebContentsObserver::OnMediaDestroyed(
OnMediaPaused(render_frame_host, delegate_id, true);
}
-
void MediaWebContentsObserver::OnMediaPaused(RenderFrameHost* render_frame_host,
int delegate_id,
bool reached_end_of_stream) {
- const MediaPlayerId id(render_frame_host, delegate_id);
- const bool removed_audio = RemoveMediaPlayerEntry(id, &active_audio_players_);
- const bool removed_video = RemoveMediaPlayerEntry(id, &active_video_players_);
+ const MediaPlayerId player_id(render_frame_host, delegate_id);
+ const bool removed_audio =
+ RemoveMediaPlayerEntry(player_id, &active_audio_players_);
+ const bool removed_video =
+ RemoveMediaPlayerEntry(player_id, &active_video_players_);
MaybeReleasePowerSaveBlockers();
if (removed_audio || removed_video) {
// Notify observers the player has been "paused".
- static_cast<WebContentsImpl*>(web_contents())->MediaStoppedPlaying(id);
+ static_cast<WebContentsImpl*>(web_contents())
+ ->MediaStoppedPlaying(player_id);
}
+
+ if (reached_end_of_stream)
+ session_controllers_manager_.OnEnd(player_id);
+ else
+ session_controllers_manager_.OnPause(player_id);
}
void MediaWebContentsObserver::OnMediaPlaying(
@@ -143,6 +152,11 @@ void MediaWebContentsObserver::OnMediaPlaying(
}
}
+ if (!session_controllers_manager_.RequestPlay(
+ id, has_audio, is_remote, duration)) {
+ return;
+ }
+
// Notify observers of the new player.
DCHECK(has_audio || has_video);
static_cast<WebContentsImpl*>(web_contents())->MediaStartedPlaying(id);
« no previous file with comments | « content/browser/media/media_web_contents_observer.h ('k') | content/browser/media/session/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698