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

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

Issue 2589893002: [Blink>MediaSession] Use setActionCallback() instead of event listeners for media control actions (Closed)
Patch Set: more 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"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 metadata_ = metadata; 62 metadata_ = metadata;
63 63
64 MediaSessionImpl* session = GetMediaSession(); 64 MediaSessionImpl* session = GetMediaSession();
65 if (session) 65 if (session)
66 session->OnMediaSessionMetadataChanged(this); 66 session->OnMediaSessionMetadataChanged(this);
67 } 67 }
68 68
69 void MediaSessionServiceImpl::EnableAction( 69 void MediaSessionServiceImpl::EnableAction(
70 blink::mojom::MediaSessionAction action) { 70 blink::mojom::MediaSessionAction action) {
71 // Action already enabled
72 if (actions_.find(action) != actions_.end())
73 return;
74
71 actions_.insert(action); 75 actions_.insert(action);
72 MediaSessionImpl* session = GetMediaSession(); 76 MediaSessionImpl* session = GetMediaSession();
73 if (session) 77 if (session)
74 session->OnMediaSessionActionsChanged(this); 78 session->OnMediaSessionActionsChanged(this);
75 } 79 }
76 80
77 void MediaSessionServiceImpl::DisableAction( 81 void MediaSessionServiceImpl::DisableAction(
78 blink::mojom::MediaSessionAction action) { 82 blink::mojom::MediaSessionAction action) {
83 // Action already disabled
84 if (actions_.find(action) == actions_.end())
85 return;
86
79 actions_.erase(action); 87 actions_.erase(action);
80 MediaSessionImpl* session = GetMediaSession(); 88 MediaSessionImpl* session = GetMediaSession();
81 if (session) 89 if (session)
82 session->OnMediaSessionActionsChanged(this); 90 session->OnMediaSessionActionsChanged(this);
83 } 91 }
84 92
85 MediaSessionImpl* MediaSessionServiceImpl::GetMediaSession() { 93 MediaSessionImpl* MediaSessionServiceImpl::GetMediaSession() {
86 WebContentsImpl* contents = static_cast<WebContentsImpl*>( 94 WebContentsImpl* contents = static_cast<WebContentsImpl*>(
87 WebContentsImpl::FromRenderFrameHost(render_frame_host_)); 95 WebContentsImpl::FromRenderFrameHost(render_frame_host_));
88 if (!contents) 96 if (!contents)
89 return nullptr; 97 return nullptr;
90 return MediaSessionImpl::Get(contents); 98 return MediaSessionImpl::Get(contents);
91 } 99 }
92 100
93 void MediaSessionServiceImpl::Bind( 101 void MediaSessionServiceImpl::Bind(
94 blink::mojom::MediaSessionServiceRequest request) { 102 blink::mojom::MediaSessionServiceRequest request) {
95 binding_.reset(new mojo::Binding<blink::mojom::MediaSessionService>( 103 binding_.reset(new mojo::Binding<blink::mojom::MediaSessionService>(
96 this, std::move(request))); 104 this, std::move(request)));
97 } 105 }
98 106
99 } // namespace content 107 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698