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

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: git cl format. Don't blame me. 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 type == content::MEDIA_DEVICE_AUDIO_CAPTURE 439 type == content::MEDIA_DEVICE_AUDIO_CAPTURE
440 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC 440 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
441 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 441 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
442 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) { 442 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) {
443 return true; 443 return true;
444 } 444 }
445 445
446 return false; 446 return false;
447 } 447 }
448 448
449 bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission(
450 content::WebContents* web_contents,
451 const GURL& security_origin,
452 content::MediaStreamType type,
453 const extensions::Extension* extension) {
454 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
455 DCHECK(type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
456 type == content::MEDIA_DEVICE_VIDEO_CAPTURE);
457
458 if (extension && (extension->is_platform_app() ||
459 IsMediaRequestWhitelistedForExtension(extension))) {
460 return extension->permissions_data()->HasAPIPermission(
461 type == content::MEDIA_DEVICE_AUDIO_CAPTURE
462 ? extensions::APIPermission::kAudioCapture
463 : extensions::APIPermission::kVideoCapture);
464 }
465
466 Profile* profile =
467 Profile::FromBrowserContext(web_contents->GetBrowserContext());
468
469 if (CheckAllowAllMediaStreamContentForOrigin(profile, security_origin))
470 return true;
471
472 const char* policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE
473 ? prefs::kAudioCaptureAllowed
474 : prefs::kVideoCaptureAllowed;
475 const char* list_policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE
476 ? prefs::kAudioCaptureAllowedUrls
477 : prefs::kVideoCaptureAllowedUrls;
478 if (GetDevicePolicy(
479 profile, security_origin, policy_name, list_policy_name) ==
480 ALWAYS_ALLOW) {
481 return true;
482 }
483
484 // There's no secondary URL for these content types, hence duplicating
485 // |security_origin|.
486 if (profile->GetHostContentSettingsMap()->GetContentSetting(
487 security_origin,
488 security_origin,
489 type == content::MEDIA_DEVICE_AUDIO_CAPTURE
490 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
491 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
492 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) {
493 return true;
494 }
495
496 return false;
497 }
498
449 void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest( 499 void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest(
450 content::WebContents* web_contents, 500 content::WebContents* web_contents,
451 const content::MediaStreamRequest& request, 501 const content::MediaStreamRequest& request,
452 const content::MediaResponseCallback& callback, 502 const content::MediaResponseCallback& callback,
453 const extensions::Extension* extension) { 503 const extensions::Extension* extension) {
454 content::MediaStreamDevices devices; 504 content::MediaStreamDevices devices;
455 scoped_ptr<content::MediaStreamUI> ui; 505 scoped_ptr<content::MediaStreamUI> ui;
456 506
457 if (request.video_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) { 507 if (request.video_type != content::MEDIA_DESKTOP_VIDEO_CAPTURE) {
458 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass()); 508 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass());
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1139
1090 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( 1140 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices(
1091 const MediaStreamDevices& devices) { 1141 const MediaStreamDevices& devices) {
1092 test_audio_devices_ = devices; 1142 test_audio_devices_ = devices;
1093 } 1143 }
1094 1144
1095 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( 1145 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices(
1096 const MediaStreamDevices& devices) { 1146 const MediaStreamDevices& devices) {
1097 test_video_devices_ = devices; 1147 test_video_devices_ = devices;
1098 } 1148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698