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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 void MediaCaptureDevicesDispatcher:: | 690 void MediaCaptureDevicesDispatcher:: |
691 ProcessMediaAccessRequestFromPlatformAppOrExtension( | 691 ProcessMediaAccessRequestFromPlatformAppOrExtension( |
692 content::WebContents* web_contents, | 692 content::WebContents* web_contents, |
693 const content::MediaStreamRequest& request, | 693 const content::MediaStreamRequest& request, |
694 const content::MediaResponseCallback& callback, | 694 const content::MediaResponseCallback& callback, |
695 const extensions::Extension* extension) { | 695 const extensions::Extension* extension) { |
696 // TODO(vrk): This code is largely duplicated in | 696 // TODO(vrk): This code is largely duplicated in |
697 // MediaStreamDevicesController::Accept(). Move this code into a shared method | 697 // MediaStreamDevicesController::Accept(). Move this code into a shared method |
698 // between the two classes. | 698 // between the two classes. |
699 | 699 |
| 700 Profile* profile = |
| 701 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 702 |
700 bool audio_allowed = | 703 bool audio_allowed = |
701 request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE && | 704 request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE && |
702 extension->permissions_data()->HasAPIPermission( | 705 extension->permissions_data()->HasAPIPermission( |
703 extensions::APIPermission::kAudioCapture); | 706 extensions::APIPermission::kAudioCapture) && |
| 707 GetDevicePolicy(profile, extension->url(), |
| 708 prefs::kAudioCaptureAllowed, |
| 709 prefs::kAudioCaptureAllowedUrls) != ALWAYS_DENY; |
704 bool video_allowed = | 710 bool video_allowed = |
705 request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE && | 711 request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE && |
706 extension->permissions_data()->HasAPIPermission( | 712 extension->permissions_data()->HasAPIPermission( |
707 extensions::APIPermission::kVideoCapture); | 713 extensions::APIPermission::kVideoCapture) && |
| 714 GetDevicePolicy(profile, extension->url(), |
| 715 prefs::kVideoCaptureAllowed, |
| 716 prefs::kVideoCaptureAllowedUrls) != ALWAYS_DENY; |
708 | 717 |
709 bool get_default_audio_device = audio_allowed; | 718 bool get_default_audio_device = audio_allowed; |
710 bool get_default_video_device = video_allowed; | 719 bool get_default_video_device = video_allowed; |
711 | 720 |
712 content::MediaStreamDevices devices; | 721 content::MediaStreamDevices devices; |
713 | 722 |
714 // Get the exact audio or video device if an id is specified. | 723 // Get the exact audio or video device if an id is specified. |
715 if (audio_allowed && !request.requested_audio_device_id.empty()) { | 724 if (audio_allowed && !request.requested_audio_device_id.empty()) { |
716 const content::MediaStreamDevice* audio_device = | 725 const content::MediaStreamDevice* audio_device = |
717 GetRequestedAudioDevice(request.requested_audio_device_id); | 726 GetRequestedAudioDevice(request.requested_audio_device_id); |
718 if (audio_device) { | 727 if (audio_device) { |
719 devices.push_back(*audio_device); | 728 devices.push_back(*audio_device); |
720 get_default_audio_device = false; | 729 get_default_audio_device = false; |
721 } | 730 } |
722 } | 731 } |
723 if (video_allowed && !request.requested_video_device_id.empty()) { | 732 if (video_allowed && !request.requested_video_device_id.empty()) { |
724 const content::MediaStreamDevice* video_device = | 733 const content::MediaStreamDevice* video_device = |
725 GetRequestedVideoDevice(request.requested_video_device_id); | 734 GetRequestedVideoDevice(request.requested_video_device_id); |
726 if (video_device) { | 735 if (video_device) { |
727 devices.push_back(*video_device); | 736 devices.push_back(*video_device); |
728 get_default_video_device = false; | 737 get_default_video_device = false; |
729 } | 738 } |
730 } | 739 } |
731 | 740 |
732 // If either or both audio and video devices were requested but not | 741 // If either or both audio and video devices were requested but not |
733 // specified by id, get the default devices. | 742 // specified by id, get the default devices. |
734 if (get_default_audio_device || get_default_video_device) { | 743 if (get_default_audio_device || get_default_video_device) { |
735 Profile* profile = | |
736 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
737 GetDefaultDevicesForProfile(profile, | 744 GetDefaultDevicesForProfile(profile, |
738 get_default_audio_device, | 745 get_default_audio_device, |
739 get_default_video_device, | 746 get_default_video_device, |
740 &devices); | 747 &devices); |
741 } | 748 } |
742 | 749 |
743 scoped_ptr<content::MediaStreamUI> ui; | 750 scoped_ptr<content::MediaStreamUI> ui; |
744 if (!devices.empty()) { | 751 if (!devices.empty()) { |
745 ui = media_stream_capture_indicator_->RegisterMediaStream( | 752 ui = media_stream_capture_indicator_->RegisterMediaStream( |
746 web_contents, devices); | 753 web_contents, devices); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 | 1071 |
1065 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 1072 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
1066 const MediaStreamDevices& devices) { | 1073 const MediaStreamDevices& devices) { |
1067 test_audio_devices_ = devices; | 1074 test_audio_devices_ = devices; |
1068 } | 1075 } |
1069 | 1076 |
1070 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 1077 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
1071 const MediaStreamDevices& devices) { | 1078 const MediaStreamDevices& devices) { |
1072 test_video_devices_ = devices; | 1079 test_video_devices_ = devices; |
1073 } | 1080 } |
OLD | NEW |