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

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

Issue 2583463002: [MediaSession] Add playbackState attribute to Blink MediaSession and use it to determine playback s… (Closed)
Patch Set: rebased Created 4 years 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_impl.h" 8 #include "content/browser/media/session/media_session_impl.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 playback_state_(blink::mojom::MediaSessionPlaybackState::NONE) {
18 MediaSessionImpl* session = GetMediaSession(); 19 MediaSessionImpl* session = GetMediaSession();
19 if (session) 20 if (session)
20 session->OnServiceCreated(this); 21 session->OnServiceCreated(this);
21 } 22 }
22 23
23 MediaSessionServiceImpl::~MediaSessionServiceImpl() { 24 MediaSessionServiceImpl::~MediaSessionServiceImpl() {
24 MediaSessionImpl* session = GetMediaSession(); 25 MediaSessionImpl* session = GetMediaSession();
25 if (session) 26 if (session)
26 session->OnServiceDestroyed(this); 27 session->OnServiceDestroyed(this);
27 } 28 }
28 29
29 // static 30 // static
30 void MediaSessionServiceImpl::Create( 31 void MediaSessionServiceImpl::Create(
31 RenderFrameHost* render_frame_host, 32 RenderFrameHost* render_frame_host,
32 blink::mojom::MediaSessionServiceRequest request) { 33 blink::mojom::MediaSessionServiceRequest request) {
33 MediaSessionServiceImpl* impl = 34 MediaSessionServiceImpl* impl =
34 new MediaSessionServiceImpl(render_frame_host); 35 new MediaSessionServiceImpl(render_frame_host);
35 impl->Bind(std::move(request)); 36 impl->Bind(std::move(request));
36 } 37 }
37 38
38 void MediaSessionServiceImpl::SetClient( 39 void MediaSessionServiceImpl::SetClient(
39 blink::mojom::MediaSessionClientPtr client) { 40 blink::mojom::MediaSessionClientPtr client) {
40 client_ = std::move(client); 41 client_ = std::move(client);
41 } 42 }
42 43
44 void MediaSessionServiceImpl::SetPlaybackState(
45 blink::mojom::MediaSessionPlaybackState state) {
46 playback_state_ = state;
47 MediaSessionImpl* session = GetMediaSession();
48 if (session)
49 session->OnMediaSessionPlaybackStateChanged(this);
50 }
51
43 void MediaSessionServiceImpl::SetMetadata( 52 void MediaSessionServiceImpl::SetMetadata(
44 const base::Optional<content::MediaMetadata>& metadata) { 53 const base::Optional<content::MediaMetadata>& metadata) {
45 // When receiving a MediaMetadata, the browser process can't trust that it is 54 // When receiving a MediaMetadata, the browser process can't trust that it is
46 // coming from a known and secure source. It must be processed accordingly. 55 // coming from a known and secure source. It must be processed accordingly.
47 if (metadata.has_value() && 56 if (metadata.has_value() &&
48 !MediaMetadataSanitizer::CheckSanity(metadata.value())) { 57 !MediaMetadataSanitizer::CheckSanity(metadata.value())) {
49 render_frame_host_->GetProcess()->ShutdownForBadMessage( 58 render_frame_host_->GetProcess()->ShutdownForBadMessage(
50 RenderProcessHost::CrashReportMode::GENERATE_CRASH_DUMP); 59 RenderProcessHost::CrashReportMode::GENERATE_CRASH_DUMP);
51 return; 60 return;
52 } 61 }
(...skipping 28 matching lines...) Expand all
81 return MediaSessionImpl::Get(contents); 90 return MediaSessionImpl::Get(contents);
82 } 91 }
83 92
84 void MediaSessionServiceImpl::Bind( 93 void MediaSessionServiceImpl::Bind(
85 blink::mojom::MediaSessionServiceRequest request) { 94 blink::mojom::MediaSessionServiceRequest request) {
86 binding_.reset(new mojo::Binding<blink::mojom::MediaSessionService>( 95 binding_.reset(new mojo::Binding<blink::mojom::MediaSessionService>(
87 this, std::move(request))); 96 this, std::move(request)));
88 } 97 }
89 98
90 } // namespace content 99 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698