OLD | NEW |
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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 390 |
391 if (extension && (extension->is_platform_app() || | 391 if (extension && (extension->is_platform_app() || |
392 IsMediaRequestWhitelistedForExtension(extension))) { | 392 IsMediaRequestWhitelistedForExtension(extension))) { |
393 return extension->permissions_data()->HasAPIPermission( | 393 return extension->permissions_data()->HasAPIPermission( |
394 type == content::MEDIA_DEVICE_AUDIO_CAPTURE | 394 type == content::MEDIA_DEVICE_AUDIO_CAPTURE |
395 ? extensions::APIPermission::kAudioCapture | 395 ? extensions::APIPermission::kAudioCapture |
396 : extensions::APIPermission::kVideoCapture); | 396 : extensions::APIPermission::kVideoCapture); |
397 } | 397 } |
398 #endif | 398 #endif |
399 | 399 |
400 if (CheckAllowAllMediaStreamContentForOrigin(profile, security_origin)) | 400 ContentSettingsType contentSettingsType = |
| 401 type == content::MEDIA_DEVICE_AUDIO_CAPTURE |
| 402 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC |
| 403 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; |
| 404 |
| 405 if (CheckAllowAllMediaStreamContentForOrigin( |
| 406 profile, security_origin, contentSettingsType)) |
401 return true; | 407 return true; |
402 | 408 |
403 const char* policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE | 409 const char* policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE |
404 ? prefs::kAudioCaptureAllowed | 410 ? prefs::kAudioCaptureAllowed |
405 : prefs::kVideoCaptureAllowed; | 411 : prefs::kVideoCaptureAllowed; |
406 const char* list_policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE | 412 const char* list_policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE |
407 ? prefs::kAudioCaptureAllowedUrls | 413 ? prefs::kAudioCaptureAllowedUrls |
408 : prefs::kVideoCaptureAllowedUrls; | 414 : prefs::kVideoCaptureAllowedUrls; |
409 if (GetDevicePolicy( | 415 if (GetDevicePolicy( |
410 profile, security_origin, policy_name, list_policy_name) == | 416 profile, security_origin, policy_name, list_policy_name) == |
411 ALWAYS_ALLOW) { | 417 ALWAYS_ALLOW) { |
412 return true; | 418 return true; |
413 } | 419 } |
414 | 420 |
415 // There's no secondary URL for these content types, hence duplicating | 421 // There's no secondary URL for these content types, hence duplicating |
416 // |security_origin|. | 422 // |security_origin|. |
417 if (profile->GetHostContentSettingsMap()->GetContentSetting( | 423 if (profile->GetHostContentSettingsMap()->GetContentSetting( |
418 security_origin, | 424 security_origin, |
419 security_origin, | 425 security_origin, |
420 type == content::MEDIA_DEVICE_AUDIO_CAPTURE | 426 contentSettingsType, |
421 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC | |
422 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | |
423 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) { | 427 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) { |
424 return true; | 428 return true; |
425 } | 429 } |
426 | 430 |
427 return false; | 431 return false; |
428 } | 432 } |
429 | 433 |
430 bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission( | 434 bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission( |
431 content::WebContents* web_contents, | 435 content::WebContents* web_contents, |
432 const GURL& security_origin, | 436 const GURL& security_origin, |
433 content::MediaStreamType type) { | 437 content::MediaStreamType type) { |
434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
435 DCHECK(type == content::MEDIA_DEVICE_AUDIO_CAPTURE || | 439 DCHECK(type == content::MEDIA_DEVICE_AUDIO_CAPTURE || |
436 type == content::MEDIA_DEVICE_VIDEO_CAPTURE); | 440 type == content::MEDIA_DEVICE_VIDEO_CAPTURE); |
437 | 441 |
438 Profile* profile = | 442 Profile* profile = |
439 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 443 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
440 | 444 |
441 if (CheckAllowAllMediaStreamContentForOrigin(profile, security_origin)) | 445 ContentSettingsType contentSettingsType = |
| 446 type == content::MEDIA_DEVICE_AUDIO_CAPTURE |
| 447 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC |
| 448 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; |
| 449 |
| 450 if (CheckAllowAllMediaStreamContentForOrigin( |
| 451 profile, security_origin, contentSettingsType)) |
442 return true; | 452 return true; |
443 | 453 |
444 const char* policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE | 454 const char* policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE |
445 ? prefs::kAudioCaptureAllowed | 455 ? prefs::kAudioCaptureAllowed |
446 : prefs::kVideoCaptureAllowed; | 456 : prefs::kVideoCaptureAllowed; |
447 const char* list_policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE | 457 const char* list_policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE |
448 ? prefs::kAudioCaptureAllowedUrls | 458 ? prefs::kAudioCaptureAllowedUrls |
449 : prefs::kVideoCaptureAllowedUrls; | 459 : prefs::kVideoCaptureAllowedUrls; |
450 if (GetDevicePolicy( | 460 if (GetDevicePolicy( |
451 profile, security_origin, policy_name, list_policy_name) == | 461 profile, security_origin, policy_name, list_policy_name) == |
452 ALWAYS_ALLOW) { | 462 ALWAYS_ALLOW) { |
453 return true; | 463 return true; |
454 } | 464 } |
455 | 465 |
456 // There's no secondary URL for these content types, hence duplicating | 466 // There's no secondary URL for these content types, hence duplicating |
457 // |security_origin|. | 467 // |security_origin|. |
458 if (profile->GetHostContentSettingsMap()->GetContentSetting( | 468 if (profile->GetHostContentSettingsMap()->GetContentSetting( |
459 security_origin, | 469 security_origin, |
460 security_origin, | 470 security_origin, |
461 type == content::MEDIA_DEVICE_AUDIO_CAPTURE | 471 contentSettingsType, |
462 ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC | |
463 : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | |
464 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) { | 472 NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) { |
465 return true; | 473 return true; |
466 } | 474 } |
467 | 475 |
468 return false; | 476 return false; |
469 } | 477 } |
470 | 478 |
471 #if defined(ENABLE_EXTENSIONS) | 479 #if defined(ENABLE_EXTENSIONS) |
472 bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission( | 480 bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission( |
473 content::WebContents* web_contents, | 481 content::WebContents* web_contents, |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 | 1144 |
1137 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 1145 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
1138 const MediaStreamDevices& devices) { | 1146 const MediaStreamDevices& devices) { |
1139 test_audio_devices_ = devices; | 1147 test_audio_devices_ = devices; |
1140 } | 1148 } |
1141 | 1149 |
1142 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 1150 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
1143 const MediaStreamDevices& devices) { | 1151 const MediaStreamDevices& devices) { |
1144 test_video_devices_ = devices; | 1152 test_video_devices_ = devices; |
1145 } | 1153 } |
OLD | NEW |