| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/android/browser_media_session_manager.h" | 5 #include "content/browser/media/android/browser_media_session_manager.h" |
| 6 | 6 |
| 7 #include "base/optional.h" |
| 7 #include "content/browser/media/session/media_session.h" | 8 #include "content/browser/media/session/media_session.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/common/media/media_metadata_sanitizer.h" | 10 #include "content/common/media/media_metadata_sanitizer.h" |
| 10 #include "content/common/media/media_session_messages_android.h" | 11 #include "content/common/media/media_session_messages_android.h" |
| 11 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
| 12 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 13 #include "content/public/common/media_metadata.h" | 14 #include "content/public/common/media_metadata.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 BrowserMediaSessionManager::BrowserMediaSessionManager( | 18 BrowserMediaSessionManager::BrowserMediaSessionManager( |
| 18 RenderFrameHost* render_frame_host) | 19 RenderFrameHost* render_frame_host) |
| 19 : render_frame_host_(render_frame_host) {} | 20 : render_frame_host_(render_frame_host) {} |
| 20 | 21 |
| 21 void BrowserMediaSessionManager::OnActivate(int session_id, int request_id) { | 22 void BrowserMediaSessionManager::OnActivate(int session_id, int request_id) { |
| 22 NOTIMPLEMENTED(); | 23 NOTIMPLEMENTED(); |
| 23 Send(new MediaSessionMsg_DidActivate(GetRoutingID(), request_id, false)); | 24 Send(new MediaSessionMsg_DidActivate(GetRoutingID(), request_id, false)); |
| 24 } | 25 } |
| 25 | 26 |
| 26 void BrowserMediaSessionManager::OnDeactivate(int session_id, int request_id) { | 27 void BrowserMediaSessionManager::OnDeactivate(int session_id, int request_id) { |
| 27 NOTIMPLEMENTED(); | 28 NOTIMPLEMENTED(); |
| 28 Send(new MediaSessionMsg_DidDeactivate(GetRoutingID(), request_id)); | 29 Send(new MediaSessionMsg_DidDeactivate(GetRoutingID(), request_id)); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void BrowserMediaSessionManager::OnSetMetadata( | 32 void BrowserMediaSessionManager::OnSetMetadata( |
| 32 int session_id, | 33 int session_id, |
| 33 const MediaMetadata& insecure_metadata) { | 34 const base::Optional<MediaMetadata>& insecure_metadata) { |
| 34 // When receiving a MediaMetadata, the browser process can't trust that it is | 35 // When receiving a MediaMetadata, the browser process can't trust that it is |
| 35 // coming from a known and secure source. It must be processed accordingly. | 36 // coming from a known and secure source. It must be processed accordingly. |
| 36 if (!MediaMetadataSanitizer::CheckSanity(insecure_metadata)) { | 37 if (insecure_metadata.has_value() && |
| 38 !MediaMetadataSanitizer::CheckSanity(insecure_metadata.value())) { |
| 37 render_frame_host_->GetProcess()->ShutdownForBadMessage(); | 39 render_frame_host_->GetProcess()->ShutdownForBadMessage(); |
| 38 return; | 40 return; |
| 39 } | 41 } |
| 40 | 42 |
| 41 NOTIMPLEMENTED(); | 43 NOTIMPLEMENTED(); |
| 42 } | 44 } |
| 43 | 45 |
| 44 int BrowserMediaSessionManager::GetRoutingID() const { | 46 int BrowserMediaSessionManager::GetRoutingID() const { |
| 45 return render_frame_host_->GetRoutingID(); | 47 return render_frame_host_->GetRoutingID(); |
| 46 } | 48 } |
| 47 | 49 |
| 48 bool BrowserMediaSessionManager::Send(IPC::Message* msg) { | 50 bool BrowserMediaSessionManager::Send(IPC::Message* msg) { |
| 49 return render_frame_host_->Send(msg); | 51 return render_frame_host_->Send(msg); |
| 50 } | 52 } |
| 51 | 53 |
| 52 } // namespace content | 54 } // namespace content |
| OLD | NEW |