Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: content/browser/renderer_host/media/media_stream_dispatcher_host.cc

Issue 483523006: Check all settings when checking mic and camera access (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix for Android. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/media/media_stream_dispatcher_host.h" 5 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h"
6 6
7 #include "content/browser/browser_main_loop.h" 7 #include "content/browser/browser_main_loop.h"
8 #include "content/browser/child_process_security_policy_impl.h" 8 #include "content/browser/child_process_security_policy_impl.h"
9 #include "content/common/media/media_stream_messages.h" 9 #include "content/common/media/media_stream_messages.h"
10 #include "content/common/media/media_stream_options.h" 10 #include "content/common/media/media_stream_options.h"
11 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 MediaStreamDispatcherHost::MediaStreamDispatcherHost( 16 MediaStreamDispatcherHost::MediaStreamDispatcherHost(
17 int render_process_id, 17 int render_process_id,
18 const ResourceContext::SaltCallback& salt_callback, 18 const ResourceContext::SaltCallback& salt_callback,
19 MediaStreamManager* media_stream_manager, 19 MediaStreamManager* media_stream_manager)
20 ResourceContext* resource_context)
21 : BrowserMessageFilter(MediaStreamMsgStart), 20 : BrowserMessageFilter(MediaStreamMsgStart),
22 render_process_id_(render_process_id), 21 render_process_id_(render_process_id),
23 salt_callback_(salt_callback), 22 salt_callback_(salt_callback),
24 media_stream_manager_(media_stream_manager), 23 media_stream_manager_(media_stream_manager) {
25 resource_context_(resource_context) {
26 } 24 }
27 25
28 void MediaStreamDispatcherHost::StreamGenerated( 26 void MediaStreamDispatcherHost::StreamGenerated(
29 int render_frame_id, 27 int render_frame_id,
30 int page_request_id, 28 int page_request_id,
31 const std::string& label, 29 const std::string& label,
32 const StreamDeviceInfoArray& audio_devices, 30 const StreamDeviceInfoArray& audio_devices,
33 const StreamDeviceInfoArray& video_devices) { 31 const StreamDeviceInfoArray& video_devices) {
34 DCHECK_CURRENTLY_ON(BrowserThread::IO); 32 DCHECK_CURRENTLY_ON(BrowserThread::IO);
35 DVLOG(1) << "MediaStreamDispatcherHost::StreamGenerated(" 33 DVLOG(1) << "MediaStreamDispatcherHost::StreamGenerated("
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 const GURL& security_origin) { 170 const GURL& security_origin) {
173 DVLOG(1) << "MediaStreamDispatcherHost::OnEnumerateDevices(" 171 DVLOG(1) << "MediaStreamDispatcherHost::OnEnumerateDevices("
174 << render_frame_id << ", " 172 << render_frame_id << ", "
175 << page_request_id << ", " 173 << page_request_id << ", "
176 << type << ", " 174 << type << ", "
177 << security_origin.spec() << ")"; 175 << security_origin.spec() << ")";
178 176
179 if (!IsURLAllowed(security_origin)) 177 if (!IsURLAllowed(security_origin))
180 return; 178 return;
181 179
182 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE ||
183 type == MEDIA_DEVICE_VIDEO_CAPTURE ||
184 type == MEDIA_DEVICE_AUDIO_OUTPUT);
185 bool have_permission =
186 type == MEDIA_DEVICE_AUDIO_CAPTURE || type == MEDIA_DEVICE_AUDIO_OUTPUT ?
187 resource_context_->AllowMicAccess(security_origin) :
188 resource_context_->AllowCameraAccess(security_origin);
189
190 media_stream_manager_->EnumerateDevices( 180 media_stream_manager_->EnumerateDevices(
191 this, render_process_id_, render_frame_id, salt_callback_, 181 this, render_process_id_, render_frame_id, salt_callback_,
192 page_request_id, type, security_origin, have_permission); 182 page_request_id, type, security_origin);
193 } 183 }
194 184
195 void MediaStreamDispatcherHost::OnCancelEnumerateDevices( 185 void MediaStreamDispatcherHost::OnCancelEnumerateDevices(
196 int render_frame_id, 186 int render_frame_id,
197 int page_request_id) { 187 int page_request_id) {
198 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelEnumerateDevices(" 188 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelEnumerateDevices("
199 << render_frame_id << ", " 189 << render_frame_id << ", "
200 << page_request_id << ")"; 190 << page_request_id << ")";
201 media_stream_manager_->CancelRequest(render_process_id_, render_frame_id, 191 media_stream_manager_->CancelRequest(render_process_id_, render_frame_id,
202 page_request_id); 192 page_request_id);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( 227 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(
238 render_process_id_, url)) { 228 render_process_id_, url)) {
239 LOG(ERROR) << "MSDH: Renderer requested a URL it's not allowed to use."; 229 LOG(ERROR) << "MSDH: Renderer requested a URL it's not allowed to use.";
240 return false; 230 return false;
241 } 231 }
242 232
243 return true; 233 return true;
244 } 234 }
245 235
246 } // namespace content 236 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698