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