| 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_stream_devices_controller.h" | 5 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/content_settings/content_settings_provider.h" | 8 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 10 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 10 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, | 73 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, |
| 74 true, | 74 true, |
| 75 PrefService::UNSYNCABLE_PREF); | 75 PrefService::UNSYNCABLE_PREF); |
| 76 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, | 76 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, |
| 77 true, | 77 true, |
| 78 PrefService::UNSYNCABLE_PREF); | 78 PrefService::UNSYNCABLE_PREF); |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { | 82 bool MediaStreamDevicesController::DismissInfoBarAndTakeActionOnSettings() { |
| 83 // If this is a no UI check for policies only go straight to accept - policy |
| 84 // check will be done automatically on the way. |
| 85 if (request_.request_type == content::MEDIA_OPEN_DEVICE) { |
| 86 std::string audio, video; |
| 87 if (has_audio_) |
| 88 audio = GetFirstDeviceId(content::MEDIA_DEVICE_AUDIO_CAPTURE); |
| 89 if (has_video_) |
| 90 video = GetFirstDeviceId(content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| 91 Accept(audio, video, false); |
| 92 return true; |
| 93 } |
| 94 |
| 83 // For tab media requests, we need to make sure the request came from the | 95 // For tab media requests, we need to make sure the request came from the |
| 84 // extension API, so we check the registry here. | 96 // extension API, so we check the registry here. |
| 85 content::MediaStreamDeviceMap::const_iterator tab_video = | 97 content::MediaStreamDeviceMap::const_iterator tab_video = |
| 86 request_.devices.find(content::MEDIA_TAB_VIDEO_CAPTURE); | 98 request_.devices.find(content::MEDIA_TAB_VIDEO_CAPTURE); |
| 87 content::MediaStreamDeviceMap::const_iterator tab_audio = | 99 content::MediaStreamDeviceMap::const_iterator tab_audio = |
| 88 request_.devices.find(content::MEDIA_TAB_AUDIO_CAPTURE); | 100 request_.devices.find(content::MEDIA_TAB_AUDIO_CAPTURE); |
| 89 if (tab_video != request_.devices.end() || | 101 if (tab_video != request_.devices.end() || |
| 90 tab_audio != request_.devices.end()) { | 102 tab_audio != request_.devices.end()) { |
| 91 extensions::TabCaptureRegistry* registry = | 103 extensions::TabCaptureRegistry* registry = |
| 92 extensions::TabCaptureRegistryFactory::GetForProfile(profile_); | 104 extensions::TabCaptureRegistryFactory::GetForProfile(profile_); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 GetAlwaysAllowedDevices(&audio, &video); | 146 GetAlwaysAllowedDevices(&audio, &video); |
| 135 if ((has_audio_ && audio.empty()) || (has_video_ && video.empty())) { | 147 if ((has_audio_ && audio.empty()) || (has_video_ && video.empty())) { |
| 136 // If there is no "always allowed" device for the origin, or the device is | 148 // If there is no "always allowed" device for the origin, or the device is |
| 137 // not available in the device lists, Check the default setting to see if | 149 // not available in the device lists, Check the default setting to see if |
| 138 // the user has blocked the access to the media device. | 150 // the user has blocked the access to the media device. |
| 139 if (IsMediaDeviceBlocked() || IsRequestBlockedByDefault()) { | 151 if (IsMediaDeviceBlocked() || IsRequestBlockedByDefault()) { |
| 140 Deny(); | 152 Deny(); |
| 141 return true; | 153 return true; |
| 142 } | 154 } |
| 143 | 155 |
| 144 // Show the infobar. | |
| 145 return false; | 156 return false; |
| 146 } | 157 } |
| 147 | 158 |
| 148 // Dismiss the infobar by selecting the "always allowed" devices. | 159 // Dismiss the infobar by selecting the "always allowed" devices. |
| 149 Accept(audio, video, false); | 160 Accept(audio, video, false); |
| 150 return true; | 161 return true; |
| 151 } | 162 } |
| 152 | 163 |
| 153 content::MediaStreamDevices | 164 content::MediaStreamDevices |
| 154 MediaStreamDevicesController::GetAudioDevices() const { | 165 MediaStreamDevicesController::GetAudioDevices() const { |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 const content::MediaStreamDevice& candidate = *device_it; | 448 const content::MediaStreamDevice& candidate = *device_it; |
| 438 if (candidate.device_id == device_id) | 449 if (candidate.device_id == device_id) |
| 439 return &candidate; | 450 return &candidate; |
| 440 } | 451 } |
| 441 // Return the first device if the preferred device is not available. | 452 // Return the first device if the preferred device is not available. |
| 442 if (device_it == it->second.end()) | 453 if (device_it == it->second.end()) |
| 443 return &(*it->second.begin()); | 454 return &(*it->second.begin()); |
| 444 } | 455 } |
| 445 return NULL; | 456 return NULL; |
| 446 } | 457 } |
| OLD | NEW |