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

Unified Diff: content/browser/media/session/media_session_service_impl.cc

Issue 2442303002: Adding new media controls to MediaNotification (Closed)
Patch Set: addressed boliu's comments 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/session/media_session_service_impl.cc
diff --git a/content/browser/media/session/media_session_service_impl.cc b/content/browser/media/session/media_session_service_impl.cc
index 3e2ab18ec4e796786141b021d99162e40422a8b7..910bcd82bccb106914463d387fcbd1260ed53308 100644
--- a/content/browser/media/session/media_session_service_impl.cc
+++ b/content/browser/media/session/media_session_service_impl.cc
@@ -14,9 +14,17 @@ namespace content {
MediaSessionServiceImpl::MediaSessionServiceImpl(
RenderFrameHost* render_frame_host)
- : render_frame_host_(render_frame_host) {}
+ : render_frame_host_(render_frame_host) {
+ MediaSession* session = GetMediaSession();
+ if (session)
+ session->SetMediaSessionService(this);
+}
-MediaSessionServiceImpl::~MediaSessionServiceImpl() = default;
+MediaSessionServiceImpl::~MediaSessionServiceImpl() {
+ MediaSession* session = GetMediaSession();
+ if (session)
+ session->SetMediaSessionService(nullptr);
+}
// static
void MediaSessionServiceImpl::Create(
@@ -43,22 +51,33 @@ void MediaSessionServiceImpl::SetMetadata(
return;
}
- WebContentsImpl* contents = static_cast<WebContentsImpl*>(
- WebContentsImpl::FromRenderFrameHost(render_frame_host_));
- if (contents)
- MediaSession::Get(contents)->SetMetadata(metadata);
+ MediaSession* session = GetMediaSession();
+ if (session)
+ session->SetMetadata(metadata);
}
void MediaSessionServiceImpl::EnableAction(
blink::mojom::MediaSessionAction action) {
- // TODO(zqzhang): Plumb this signal to Java. See https://crbug.com/656563
- NOTIMPLEMENTED();
+ MediaSession* session = GetMediaSession();
+ if (session)
+ session->OnMediaSessionEnabledAction(action);
}
void MediaSessionServiceImpl::DisableAction(
blink::mojom::MediaSessionAction action) {
- // TODO(zqzhang): Plumb this signal to Java. See https://crbug.com/656563
- NOTIMPLEMENTED();
+ MediaSession* session = GetMediaSession();
+ if (session)
+ session->OnMediaSessionEnabledAction(action);
+}
+
+MediaSession* MediaSessionServiceImpl::GetMediaSession() {
+ WebContentsImpl* contents = static_cast<WebContentsImpl*>(
+ WebContentsImpl::FromRenderFrameHost(render_frame_host_));
+ if (!contents)
+ return nullptr;
+ if (render_frame_host_ != contents->GetMainFrame())
+ return nullptr;
+ return MediaSession::Get(contents);
}
void MediaSessionServiceImpl::Bind(

Powered by Google App Engine
This is Rietveld 408576698