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

Side by Side Diff: content/browser/media/session/media_session_service_impl.cc

Issue 2426653002: Adding mojo MediaSessionClient to support media controls (Closed)
Patch Set: rebased and nits Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/media/session/media_session_service_impl.h" 5 #include "content/browser/media/session/media_session_service_impl.h"
6 6
7 #include "content/browser/media/session/media_metadata_sanitizer.h" 7 #include "content/browser/media/session/media_metadata_sanitizer.h"
8 #include "content/browser/media/session/media_session.h" 8 #include "content/browser/media/session/media_session.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 MediaSessionServiceImpl::MediaSessionServiceImpl( 15 MediaSessionServiceImpl::MediaSessionServiceImpl(
16 RenderFrameHost* render_frame_host) 16 RenderFrameHost* render_frame_host)
17 : render_frame_host_(render_frame_host) {} 17 : render_frame_host_(render_frame_host) {}
18 18
19 MediaSessionServiceImpl::~MediaSessionServiceImpl() = default; 19 MediaSessionServiceImpl::~MediaSessionServiceImpl() = default;
20 20
21 // static 21 // static
22 void MediaSessionServiceImpl::Create( 22 void MediaSessionServiceImpl::Create(
23 RenderFrameHost* render_frame_host, 23 RenderFrameHost* render_frame_host,
24 blink::mojom::MediaSessionServiceRequest request) { 24 blink::mojom::MediaSessionServiceRequest request) {
25 MediaSessionServiceImpl* impl = 25 MediaSessionServiceImpl* impl =
26 new MediaSessionServiceImpl(render_frame_host); 26 new MediaSessionServiceImpl(render_frame_host);
27 impl->Bind(std::move(request)); 27 impl->Bind(std::move(request));
28 } 28 }
29 29
30 void MediaSessionServiceImpl::SetClient(
31 blink::mojom::MediaSessionClientPtr client) {
32 client_ = std::move(client);
33 }
34
30 void MediaSessionServiceImpl::SetMetadata( 35 void MediaSessionServiceImpl::SetMetadata(
31 const base::Optional<content::MediaMetadata>& metadata) { 36 const base::Optional<content::MediaMetadata>& metadata) {
32 // When receiving a MediaMetadata, the browser process can't trust that it is 37 // When receiving a MediaMetadata, the browser process can't trust that it is
33 // coming from a known and secure source. It must be processed accordingly. 38 // coming from a known and secure source. It must be processed accordingly.
34 if (metadata.has_value() && 39 if (metadata.has_value() &&
35 !MediaMetadataSanitizer::CheckSanity(metadata.value())) { 40 !MediaMetadataSanitizer::CheckSanity(metadata.value())) {
36 render_frame_host_->GetProcess()->ShutdownForBadMessage( 41 render_frame_host_->GetProcess()->ShutdownForBadMessage(
37 RenderProcessHost::CrashReportMode::GENERATE_CRASH_DUMP); 42 RenderProcessHost::CrashReportMode::GENERATE_CRASH_DUMP);
38 return; 43 return;
39 } 44 }
40 45
41 WebContentsImpl* contents = static_cast<WebContentsImpl*>( 46 WebContentsImpl* contents = static_cast<WebContentsImpl*>(
42 WebContentsImpl::FromRenderFrameHost(render_frame_host_)); 47 WebContentsImpl::FromRenderFrameHost(render_frame_host_));
43 if (contents) 48 if (contents)
44 MediaSession::Get(contents)->SetMetadata(metadata); 49 MediaSession::Get(contents)->SetMetadata(metadata);
45 } 50 }
46 51
52 void MediaSessionServiceImpl::EnableAction(
53 blink::mojom::MediaSessionAction action) {
54 // TODO(zqzhang): Plumb this signal to Java. See https://crbug.com/656563
55 NOTIMPLEMENTED();
56 }
57
58 void MediaSessionServiceImpl::DisableAction(
59 blink::mojom::MediaSessionAction action) {
60 // TODO(zqzhang): Plumb this signal to Java. See https://crbug.com/656563
61 NOTIMPLEMENTED();
62 }
63
47 void MediaSessionServiceImpl::Bind( 64 void MediaSessionServiceImpl::Bind(
48 blink::mojom::MediaSessionServiceRequest request) { 65 blink::mojom::MediaSessionServiceRequest request) {
49 binding_.reset(new mojo::Binding<blink::mojom::MediaSessionService>( 66 binding_.reset(new mojo::Binding<blink::mojom::MediaSessionService>(
50 this, std::move(request))); 67 this, std::move(request)));
51 } 68 }
52 69
53 } // namespace content 70 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698