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

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

Issue 287383002: Implement getMediaDevices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review fix, a minor test refactoring. And rebase, sorry. Created 6 years, 6 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)
20 : BrowserMessageFilter(MediaStreamMsgStart), 21 : BrowserMessageFilter(MediaStreamMsgStart),
21 render_process_id_(render_process_id), 22 render_process_id_(render_process_id),
22 salt_callback_(salt_callback), 23 salt_callback_(salt_callback),
23 media_stream_manager_(media_stream_manager) { 24 media_stream_manager_(media_stream_manager),
25 resource_context_(resource_context) {
24 } 26 }
25 27
26 void MediaStreamDispatcherHost::StreamGenerated( 28 void MediaStreamDispatcherHost::StreamGenerated(
27 int render_view_id, 29 int render_view_id,
28 int page_request_id, 30 int page_request_id,
29 const std::string& label, 31 const std::string& label,
30 const StreamDeviceInfoArray& audio_devices, 32 const StreamDeviceInfoArray& audio_devices,
31 const StreamDeviceInfoArray& video_devices) { 33 const StreamDeviceInfoArray& video_devices) {
32 DCHECK_CURRENTLY_ON(BrowserThread::IO); 34 DCHECK_CURRENTLY_ON(BrowserThread::IO);
33 DVLOG(1) << "MediaStreamDispatcherHost::StreamGenerated(" 35 DVLOG(1) << "MediaStreamDispatcherHost::StreamGenerated("
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 const GURL& security_origin) { 173 const GURL& security_origin) {
172 DVLOG(1) << "MediaStreamDispatcherHost::OnEnumerateDevices(" 174 DVLOG(1) << "MediaStreamDispatcherHost::OnEnumerateDevices("
173 << render_view_id << ", " 175 << render_view_id << ", "
174 << page_request_id << ", " 176 << page_request_id << ", "
175 << type << ", " 177 << type << ", "
176 << security_origin.spec() << ")"; 178 << security_origin.spec() << ")";
177 179
178 if (!IsURLAllowed(security_origin)) 180 if (!IsURLAllowed(security_origin))
179 return; 181 return;
180 182
183 bool have_permission = type == MEDIA_DEVICE_AUDIO_CAPTURE ?
no longer working on chromium 2014/06/02 11:57:42 will type be others? if not, add DCHECK(type == ME
Henrik Grunell 2014/06/03 07:52:27 No. Done.
184 resource_context_->AllowMicAccess(security_origin) :
185 resource_context_->AllowCameraAccess(security_origin);
186
181 media_stream_manager_->EnumerateDevices( 187 media_stream_manager_->EnumerateDevices(
182 this, render_process_id_, render_view_id, salt_callback_, 188 this, render_process_id_, render_view_id, salt_callback_,
183 page_request_id, type, security_origin); 189 page_request_id, type, security_origin, have_permission);
184 } 190 }
185 191
186 void MediaStreamDispatcherHost::OnCancelEnumerateDevices( 192 void MediaStreamDispatcherHost::OnCancelEnumerateDevices(
187 int render_view_id, 193 int render_view_id,
188 int page_request_id) { 194 int page_request_id) {
189 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelEnumerateDevices(" 195 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelEnumerateDevices("
190 << render_view_id << ", " 196 << render_view_id << ", "
191 << page_request_id << ")"; 197 << page_request_id << ")";
192 media_stream_manager_->CancelRequest(render_process_id_, render_view_id, 198 media_stream_manager_->CancelRequest(render_process_id_, render_view_id,
193 page_request_id); 199 page_request_id);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( 234 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(
229 render_process_id_, url)) { 235 render_process_id_, url)) {
230 LOG(ERROR) << "MSDH: Renderer requested a URL it's not allowed to use."; 236 LOG(ERROR) << "MSDH: Renderer requested a URL it's not allowed to use.";
231 return false; 237 return false;
232 } 238 }
233 239
234 return true; 240 return true;
235 } 241 }
236 242
237 } // namespace content 243 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698