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

Side by Side Diff: chrome/browser/media/media_capture_devices_dispatcher.cc

Issue 562263002: Check media permissions through RenderFrameHostDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render_frame_get_sources
Patch Set: Updated unit test MediaStreamDispatcherHost. 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
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 "chrome/browser/media/media_capture_devices_dispatcher.h" 5 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 type == content::MEDIA_DEVICE_AUDIO_CAPTURE 396 type == content::MEDIA_DEVICE_AUDIO_CAPTURE
397 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC 397 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
398 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 398 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
399 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) { 399 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) {
400 return true; 400 return true;
401 } 401 }
402 402
403 return false; 403 return false;
404 } 404 }
405 405
406 bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission(
407 content::WebContents* web_contents,
408 const GURL& security_origin,
409 content::MediaStreamType type,
410 const extensions::Extension* extension) {
411 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
412 DCHECK(type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
413 type == content::MEDIA_DEVICE_VIDEO_CAPTURE);
414
415 if (extension && (extension->is_platform_app() ||
416 IsMediaRequestWhitelistedForExtension(extension))) {
417 return extension->permissions_data()->HasAPIPermission(
418 type == content::MEDIA_DEVICE_AUDIO_CAPTURE
419 ? extensions::APIPermission::kAudioCapture
420 : extensions::APIPermission::kVideoCapture);
421 }
422
423 Profile* profile =
424 Profile::FromBrowserContext(web_contents->GetBrowserContext());
425
426 if (CheckAllowAllMediaStreamContentForOrigin(profile, security_origin))
427 return true;
428
429 const char* policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE
430 ? prefs::kAudioCaptureAllowed
431 : prefs::kVideoCaptureAllowed;
432 const char* list_policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE
433 ? prefs::kAudioCaptureAllowedUrls
434 : prefs::kVideoCaptureAllowedUrls;
435 if (GetDevicePolicy(
436 profile, security_origin, policy_name, list_policy_name) ==
437 ALWAYS_ALLOW) {
438 return true;
439 }
440
441 // There's no secondary URL for these content types, hence duplicating
442 // |security_origin|.
443 if (profile->GetHostContentSettingsMap()->GetContentSetting(
444 security_origin,
445 security_origin,
446 type == content::MEDIA_DEVICE_AUDIO_CAPTURE
447 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
448 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
449 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) {
450 return true;
451 }
452
453 return false;
454 }
455
406 void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest( 456 void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest(
407 content::WebContents* web_contents, 457 content::WebContents* web_contents,
408 const content::MediaStreamRequest& request, 458 const content::MediaStreamRequest& request,
409 const content::MediaResponseCallback& callback, 459 const content::MediaResponseCallback& callback,
410 const extensions::Extension* extension) { 460 const extensions::Extension* extension) {
411 content::MediaStreamDevices devices; 461 content::MediaStreamDevices devices;
412 scoped_ptr<content::MediaStreamUI> ui; 462 scoped_ptr<content::MediaStreamUI> ui;
413 463
414 if (request.video_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) { 464 if (request.video_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) {
415 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass()); 465 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass());
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1051
1002 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( 1052 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices(
1003 const MediaStreamDevices& devices) { 1053 const MediaStreamDevices& devices) {
1004 test_audio_devices_ = devices; 1054 test_audio_devices_ = devices;
1005 } 1055 }
1006 1056
1007 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( 1057 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices(
1008 const MediaStreamDevices& devices) { 1058 const MediaStreamDevices& devices) {
1009 test_video_devices_ = devices; 1059 test_video_devices_ = devices;
1010 } 1060 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698