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

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

Issue 2442303002: Adding new media controls to MediaNotification (Closed)
Patch Set: rebased onto MediaSession refactoring 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 f0f5431c2300325fc6dee976a70fdfd53b47f572..a9bb2fffc5249cf051d82e2bb991f6cc73d6e492 100644
--- a/content/browser/media/session/media_session_service_impl.cc
+++ b/content/browser/media/session/media_session_service_impl.cc
@@ -14,9 +14,15 @@ namespace content {
MediaSessionServiceImpl::MediaSessionServiceImpl(
RenderFrameHost* render_frame_host)
- : render_frame_host_(render_frame_host) {}
+ : render_frame_host_(render_frame_host) {
+ if (MediaSessionImpl* session = GetMediaSession())
+ session->SetMediaSessionService(this);
+}
-MediaSessionServiceImpl::~MediaSessionServiceImpl() = default;
+MediaSessionServiceImpl::~MediaSessionServiceImpl() {
+ if (MediaSessionImpl* session = GetMediaSession())
whywhat 2016/10/28 16:10:23 nit: can this be null here and below? I'd avoid in
Zhiqiang Zhang (Slow) 2016/11/01 15:24:15 Yes, currently we only bind the top-level frame se
+ session->SetMediaSessionService(nullptr);
+}
// static
void MediaSessionServiceImpl::Create(
@@ -43,22 +49,30 @@ void MediaSessionServiceImpl::SetMetadata(
return;
}
- WebContentsImpl* contents = static_cast<WebContentsImpl*>(
- WebContentsImpl::FromRenderFrameHost(render_frame_host_));
- if (contents)
- MediaSessionImpl::Get(contents)->SetMetadata(metadata);
+ if (MediaSessionImpl* session = GetMediaSession())
+ session->SetMetadata(metadata);
}
void MediaSessionServiceImpl::EnableAction(
blink::mojom::MediaSessionAction action) {
- // TODO(zqzhang): Plumb this signal to Java. See https://crbug.com/656563
- NOTIMPLEMENTED();
+ if (MediaSessionImpl* session = GetMediaSession())
+ session->OnMediaSessionEnabledAction(action);
}
void MediaSessionServiceImpl::DisableAction(
blink::mojom::MediaSessionAction action) {
- // TODO(zqzhang): Plumb this signal to Java. See https://crbug.com/656563
- NOTIMPLEMENTED();
+ if (MediaSessionImpl* session = GetMediaSession())
+ session->OnMediaSessionDisabledAction(action);
+}
+
+MediaSessionImpl* 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 MediaSessionImpl::Get(contents);
}
void MediaSessionServiceImpl::Bind(

Powered by Google App Engine
This is Rietveld 408576698