Chromium Code Reviews| 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 metadata.artworks = insecure_metadata.artworks; | |
| 40 | 43 |
| 41 if (metadata != insecure_metadata) { | 44 if (metadata != insecure_metadata) { |
| 42 render_frame_host_->GetProcess()->ShutdownForBadMessage(); | 45 render_frame_host_->GetProcess()->ShutdownForBadMessage(); |
| 43 return; | 46 return; |
| 44 } | 47 } |
| 45 | 48 |
| 46 NOTIMPLEMENTED(); | 49 WebContentsImpl* contents = static_cast<WebContentsImpl*>( |
| 50 WebContents::FromRenderFrameHost(render_frame_host_)); | |
| 51 if (contents) | |
| 52 // TODO(zqzhang): many-to-one relationship between WebMediaSession | |
| 53 // & MediaSession? | |
| 54 MediaSession::Get(contents)->SetMetadata(metadata); | |
|
mlamouri (slow - plz ping)
2016/06/10 10:54:58
Better to leave this as-is. It should be plumbed w
Zhiqiang Zhang (Slow)
2016/06/14 13:16:17
Acknowledged.
| |
| 47 } | 55 } |
| 48 | 56 |
| 49 int BrowserMediaSessionManager::GetRoutingID() const { | 57 int BrowserMediaSessionManager::GetRoutingID() const { |
| 50 return render_frame_host_->GetRoutingID(); | 58 return render_frame_host_->GetRoutingID(); |
| 51 } | 59 } |
| 52 | 60 |
| 53 bool BrowserMediaSessionManager::Send(IPC::Message* msg) { | 61 bool BrowserMediaSessionManager::Send(IPC::Message* msg) { |
| 54 return render_frame_host_->Send(msg); | 62 return render_frame_host_->Send(msg); |
| 55 } | 63 } |
| 56 | 64 |
| 57 } // namespace content | 65 } // namespace content |
| OLD | NEW |