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

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

Issue 2693203002: Provide a WebContents API to discover the playback of a fullscreen video. (Closed)
Patch Set: apply review comments Created 3 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 87d7670d71aa4ac5aae1a5a5e0ae738b00d66eec..7e11255ab58c84d4eaffa7542136a857ee70712b 100644
--- a/content/browser/media/media_web_contents_observer.cc
+++ b/content/browser/media/media_web_contents_observer.cc
@@ -31,7 +31,7 @@ MediaWebContentsObserver::MediaWebContentsObserver(WebContents* web_contents)
: WebContentsObserver(web_contents),
session_controllers_manager_(this) {}
-MediaWebContentsObserver::~MediaWebContentsObserver() {}
+MediaWebContentsObserver::~MediaWebContentsObserver() = default;
void MediaWebContentsObserver::WebContentsDestroyed() {
GetAudibleMetrics()->UpdateAudibleWebContentsState(web_contents(), false);
@@ -41,6 +41,9 @@ void MediaWebContentsObserver::RenderFrameDeleted(
RenderFrameHost* render_frame_host) {
ClearPowerSaveBlockers(render_frame_host);
session_controllers_manager_.RenderFrameDeleted(render_frame_host);
+
+ if (fullscreen_player_ && fullscreen_player_->first == render_frame_host)
+ fullscreen_player_.reset();
}
void MediaWebContentsObserver::MaybeUpdateAudibleState() {
@@ -58,11 +61,26 @@ void MediaWebContentsObserver::MaybeUpdateAudibleState() {
web_contents(), audio_stream_monitor->IsCurrentlyAudible());
}
+bool MediaWebContentsObserver::HasActiveEffectivelyFullscreenVideo() const {
+ DCHECK(web_contents()->IsFullscreen());
+
+ if (!fullscreen_player_)
+ return false;
+
+ // Check that the player is active.
+ const auto& players = active_video_players_.find(fullscreen_player_->first);
+ if (players == active_video_players_.end())
+ return false;
+ if (players->second.find(fullscreen_player_->second) == players->second.end())
+ return false;
+
+ return true;
+}
+
bool MediaWebContentsObserver::OnMessageReceived(
const IPC::Message& msg,
RenderFrameHost* render_frame_host) {
bool handled = true;
- // TODO(dalecurtis): These should no longer be FrameHostMsg.
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(MediaWebContentsObserver, msg,
render_frame_host)
IPC_MESSAGE_HANDLER(MediaPlayerDelegateHostMsg_OnMediaDestroyed,
@@ -70,6 +88,9 @@ bool MediaWebContentsObserver::OnMessageReceived(
IPC_MESSAGE_HANDLER(MediaPlayerDelegateHostMsg_OnMediaPaused, OnMediaPaused)
IPC_MESSAGE_HANDLER(MediaPlayerDelegateHostMsg_OnMediaPlaying,
OnMediaPlaying)
+ IPC_MESSAGE_HANDLER(
+ MediaPlayerDelegateHostMsg_OnMediaEffectivelyFullscreenChange,
+ OnMediaEffectivelyFullscreenChange)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -156,6 +177,21 @@ void MediaWebContentsObserver::OnMediaPlaying(
id);
}
+void MediaWebContentsObserver::OnMediaEffectivelyFullscreenChange(
+ RenderFrameHost* render_frame_host,
+ int delegate_id,
+ bool is_fullscreen) {
+ const MediaPlayerId id(render_frame_host, delegate_id);
+
+ if (!is_fullscreen) {
+ if (fullscreen_player_ && *fullscreen_player_ == id)
+ fullscreen_player_.reset();
+ return;
+ }
+
+ fullscreen_player_ = id;
+}
+
void MediaWebContentsObserver::ClearPowerSaveBlockers(
RenderFrameHost* render_frame_host) {
std::set<MediaPlayerId> removed_players;
« no previous file with comments | « content/browser/media/media_web_contents_observer.h ('k') | content/browser/web_contents/web_contents_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698