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( |