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