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 "base/optional.h" |
8 #include "content/browser/media/session/media_session.h" | 8 #include "content/browser/media/session/media_session.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/common/media/media_metadata_sanitizer.h" | 10 #include "content/common/media/media_metadata_sanitizer.h" |
11 #include "content/common/media/media_session_messages_android.h" | 11 #include "content/common/media/media_session_messages_android.h" |
12 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
13 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
14 #include "content/public/common/media_metadata.h" | |
15 | 14 |
16 namespace content { | 15 namespace content { |
17 | 16 |
18 BrowserMediaSessionManager::BrowserMediaSessionManager( | 17 BrowserMediaSessionManager::BrowserMediaSessionManager( |
19 RenderFrameHost* render_frame_host) | 18 RenderFrameHost* render_frame_host, |
20 : render_frame_host_(render_frame_host) {} | 19 WebContentsImpl* contents) |
20 : render_frame_host_(render_frame_host), contents_(contents) {} | |
21 | |
22 BrowserMediaSessionManager::~BrowserMediaSessionManager() = default; | |
23 | |
24 const base::Optional<MediaMetadata>& | |
25 BrowserMediaSessionManager::media_metadata() const { | |
26 return media_metadata_; | |
whywhat
2016/09/13 16:23:26
nit: this is allowed to be inlined in the header I
Zhiqiang Zhang (Slow)
2016/09/13 18:51:52
Done.
| |
27 } | |
21 | 28 |
22 void BrowserMediaSessionManager::OnActivate(int session_id, int request_id) { | 29 void BrowserMediaSessionManager::OnActivate(int session_id, int request_id) { |
23 NOTIMPLEMENTED(); | 30 NOTIMPLEMENTED(); |
24 Send(new MediaSessionMsg_DidActivate(GetRoutingID(), request_id, false)); | 31 Send(new MediaSessionMsg_DidActivate(GetRoutingID(), request_id, false)); |
25 } | 32 } |
26 | 33 |
27 void BrowserMediaSessionManager::OnDeactivate(int session_id, int request_id) { | 34 void BrowserMediaSessionManager::OnDeactivate(int session_id, int request_id) { |
28 NOTIMPLEMENTED(); | 35 NOTIMPLEMENTED(); |
29 Send(new MediaSessionMsg_DidDeactivate(GetRoutingID(), request_id)); | 36 Send(new MediaSessionMsg_DidDeactivate(GetRoutingID(), request_id)); |
30 } | 37 } |
31 | 38 |
32 void BrowserMediaSessionManager::OnSetMetadata( | 39 void BrowserMediaSessionManager::OnSetMetadata( |
33 int session_id, | 40 int session_id, |
34 const base::Optional<MediaMetadata>& insecure_metadata) { | 41 const base::Optional<MediaMetadata>& insecure_metadata) { |
whywhat
2016/09/13 16:23:26
nit: the declaration of the method has this named
Zhiqiang Zhang (Slow)
2016/09/13 18:51:52
Done. Updated the header file.
| |
42 // Non-top-level frames should not receive metadata. | |
43 if (render_frame_host_->GetParent()) { | |
44 render_frame_host_->GetProcess()->ShutdownForBadMessage(); | |
whywhat
2016/09/13 16:23:26
This is a preventative measure against p0wned rend
Zhiqiang Zhang (Slow)
2016/09/13 17:15:56
There are sanity check and sanitizing when the ren
| |
45 return; | |
46 } | |
47 | |
35 // When receiving a MediaMetadata, the browser process can't trust that it is | 48 // When receiving a MediaMetadata, the browser process can't trust that it is |
36 // coming from a known and secure source. It must be processed accordingly. | 49 // coming from a known and secure source. It must be processed accordingly. |
37 if (insecure_metadata.has_value() && | 50 if (insecure_metadata.has_value() && |
38 !MediaMetadataSanitizer::CheckSanity(insecure_metadata.value())) { | 51 !MediaMetadataSanitizer::CheckSanity(insecure_metadata.value())) { |
whywhat
2016/09/13 16:23:26
nit: This Sanitizer looks a bit odd: it checks the
Zhiqiang Zhang (Slow)
2016/09/13 17:15:56
I'm also trying to remember but I forgot most of i
| |
39 render_frame_host_->GetProcess()->ShutdownForBadMessage(); | 52 render_frame_host_->GetProcess()->ShutdownForBadMessage(); |
40 return; | 53 return; |
41 } | 54 } |
42 | 55 |
43 NOTIMPLEMENTED(); | 56 media_metadata_ = insecure_metadata; |
57 contents_->OnMediaSessionStateChanged(); | |
44 } | 58 } |
45 | 59 |
46 int BrowserMediaSessionManager::GetRoutingID() const { | 60 int BrowserMediaSessionManager::GetRoutingID() const { |
47 return render_frame_host_->GetRoutingID(); | 61 return render_frame_host_->GetRoutingID(); |
48 } | 62 } |
49 | 63 |
50 bool BrowserMediaSessionManager::Send(IPC::Message* msg) { | 64 bool BrowserMediaSessionManager::Send(IPC::Message* msg) { |
51 return render_frame_host_->Send(msg); | 65 return render_frame_host_->Send(msg); |
52 } | 66 } |
53 | 67 |
54 } // namespace content | 68 } // namespace content |
OLD | NEW |