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

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: with flag Created 4 years, 10 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.cc
diff --git a/content/browser/media/media_web_contents_observer.cc b/content/browser/media/media_web_contents_observer.cc
index 1123974df7b63597f042420cbbd1bdb681a89175..558cc64cd61a8959a6aa591f5a5b44b30b81ed18 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_.Clear(render_frame_host);
DaleCurtis 2016/02/17 20:16:54 We are now mixing a pattern of a delegate, 2 manag
mlamouri (slow - plz ping) 2016/02/23 20:27:55 The delegate is really because of platform dependa
}
void MediaWebContentsObserver::MaybeUpdateAudibleState() {
@@ -87,13 +89,27 @@ void MediaWebContentsObserver::WasHidden() {
video_power_save_blocker_.reset();
}
+#if defined(OS_ANDROID)
+bool MediaWebContentsObserver::RequestPlay(
+ RenderFrameHost* render_frame_host,
+ int delegate_id,
+ bool has_audio,
+ bool is_remote,
+ base::TimeDelta duration) {
+ // |has_video| forced to true since the value doesn't matter at present.
DaleCurtis 2016/02/17 20:16:54 This no longer does quite the right thing, we don'
mlamouri (slow - plz ping) 2016/02/23 20:27:55 This is actually neatly solved with the MediaSessi
+ OnMediaPlaying(render_frame_host, delegate_id, true, has_audio, is_remote,
+ duration);
+ return media_session_map_.find(MediaPlayerId(
DaleCurtis 2016/02/17 20:16:54 No media_session_map_ anymore.
mlamouri (slow - plz ping) 2016/02/23 20:27:55 Done.
+ render_frame_host, delegate_id)) != media_session_map_.end();
+}
+#endif // OS_ANDROID
+
void MediaWebContentsObserver::OnMediaDestroyed(
RenderFrameHost* render_frame_host,
int delegate_id) {
OnMediaPaused(render_frame_host, delegate_id, true);
}
-
void MediaWebContentsObserver::OnMediaPaused(RenderFrameHost* render_frame_host,
int delegate_id,
bool reached_end_of_stream) {
@@ -106,6 +122,11 @@ void MediaWebContentsObserver::OnMediaPaused(RenderFrameHost* render_frame_host,
// Notify observers the player has been "paused".
static_cast<WebContentsImpl*>(web_contents())->MediaStoppedPlaying(id);
}
+
+ if (reached_end_of_stream)
+ session_controllers_manager_.OnEnd(id);
+ else
+ session_controllers_manager_.OnPause(id);
}
void MediaWebContentsObserver::OnMediaPlaying(
@@ -143,6 +164,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);

Powered by Google App Engine
This is Rietveld 408576698