| 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" |
| 7 #include "content/common/media/media_session_messages_android.h" | 9 #include "content/common/media/media_session_messages_android.h" |
| 8 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
| 9 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
| 10 #include "content/public/common/media_metadata.h" | 12 #include "content/public/common/media_metadata.h" |
| 11 | 13 |
| 12 namespace content { | 14 namespace content { |
| 13 | 15 |
| 14 BrowserMediaSessionManager::BrowserMediaSessionManager( | 16 BrowserMediaSessionManager::BrowserMediaSessionManager( |
| 15 RenderFrameHost* render_frame_host) | 17 RenderFrameHost* render_frame_host) |
| 16 : render_frame_host_(render_frame_host) {} | 18 : render_frame_host_(render_frame_host) {} |
| (...skipping 13 matching lines...) Expand all Loading... |
| 30 const MediaMetadata& insecure_metadata) { | 32 const MediaMetadata& insecure_metadata) { |
| 31 // When receiving a MediaMetadata, the browser process can't trust that it is | 33 // 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. | 34 // coming from a known and secure source. It must be processed accordingly. |
| 33 MediaMetadata metadata; | 35 MediaMetadata metadata; |
| 34 metadata.title = | 36 metadata.title = |
| 35 insecure_metadata.title.substr(0, MediaMetadata::kMaxIPCStringLength); | 37 insecure_metadata.title.substr(0, MediaMetadata::kMaxIPCStringLength); |
| 36 metadata.artist = | 38 metadata.artist = |
| 37 insecure_metadata.artist.substr(0, MediaMetadata::kMaxIPCStringLength); | 39 insecure_metadata.artist.substr(0, MediaMetadata::kMaxIPCStringLength); |
| 38 metadata.album = | 40 metadata.album = |
| 39 insecure_metadata.album.substr(0, MediaMetadata::kMaxIPCStringLength); | 41 insecure_metadata.album.substr(0, MediaMetadata::kMaxIPCStringLength); |
| 42 for (const auto& artwork : insecure_metadata.artwork) { |
| 43 auto sanitized_artwork = |
| 44 MediaMetadata::SanitizeArtwork(artwork); |
| 45 if (sanitized_artwork) |
| 46 metadata.artwork.push_back(sanitized_artwork.value()); |
| 47 |
| 48 if (metadata.artwork.size() >= MediaMetadata::kMaxNumberOfArtworkImages) |
| 49 break; |
| 50 } |
| 40 | 51 |
| 41 if (metadata != insecure_metadata) { | 52 if (metadata != insecure_metadata) { |
| 42 render_frame_host_->GetProcess()->ShutdownForBadMessage(); | 53 render_frame_host_->GetProcess()->ShutdownForBadMessage(); |
| 43 return; | 54 return; |
| 44 } | 55 } |
| 45 | 56 |
| 46 NOTIMPLEMENTED(); | 57 NOTIMPLEMENTED(); |
| 47 } | 58 } |
| 48 | 59 |
| 49 int BrowserMediaSessionManager::GetRoutingID() const { | 60 int BrowserMediaSessionManager::GetRoutingID() const { |
| 50 return render_frame_host_->GetRoutingID(); | 61 return render_frame_host_->GetRoutingID(); |
| 51 } | 62 } |
| 52 | 63 |
| 53 bool BrowserMediaSessionManager::Send(IPC::Message* msg) { | 64 bool BrowserMediaSessionManager::Send(IPC::Message* msg) { |
| 54 return render_frame_host_->Send(msg); | 65 return render_frame_host_->Send(msg); |
| 55 } | 66 } |
| 56 | 67 |
| 57 } // namespace content | 68 } // namespace content |
| OLD | NEW |