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::OPEN_DEVICE) { | |
no longer working on chromium
2012/12/10 10:17:56
thanks, the code is much clearer now since we are
| |
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 std::string audio_device_id; | 103 std::string audio_device_id; |
92 std::string video_device_id; | 104 std::string video_device_id; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 GetAlwaysAllowedDevices(&audio, &video); | 143 GetAlwaysAllowedDevices(&audio, &video); |
132 if ((has_audio_ && audio.empty()) || (has_video_ && video.empty())) { | 144 if ((has_audio_ && audio.empty()) || (has_video_ && video.empty())) { |
133 // If there is no "always allowed" device for the origin, or the device is | 145 // If there is no "always allowed" device for the origin, or the device is |
134 // not available in the device lists, Check the default setting to see if | 146 // not available in the device lists, Check the default setting to see if |
135 // the user has blocked the access to the media device. | 147 // the user has blocked the access to the media device. |
136 if (IsMediaDeviceBlocked()) { | 148 if (IsMediaDeviceBlocked()) { |
137 Deny(); | 149 Deny(); |
138 return true; | 150 return true; |
139 } | 151 } |
140 | 152 |
141 // Show the infobar. | |
142 return false; | 153 return false; |
143 } | 154 } |
144 | 155 |
145 // Dismiss the infobar by selecting the "always allowed" devices. | 156 // Dismiss the infobar by selecting the "always allowed" devices. |
146 Accept(audio, video, false); | 157 Accept(audio, video, false); |
147 return true; | 158 return true; |
148 } | 159 } |
149 | 160 |
150 content::MediaStreamDevices | 161 content::MediaStreamDevices |
151 MediaStreamDevicesController::GetAudioDevices() const { | 162 MediaStreamDevicesController::GetAudioDevices() const { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 for (content::MediaStreamDevices::const_iterator device_it = | 393 for (content::MediaStreamDevices::const_iterator device_it = |
383 it->second.begin(); | 394 it->second.begin(); |
384 device_it != it->second.end(); ++device_it) { | 395 device_it != it->second.end(); ++device_it) { |
385 const content::MediaStreamDevice& candidate = *device_it; | 396 const content::MediaStreamDevice& candidate = *device_it; |
386 if (candidate.device_id == device_id) | 397 if (candidate.device_id == device_id) |
387 return &candidate; | 398 return &candidate; |
388 } | 399 } |
389 } | 400 } |
390 return NULL; | 401 return NULL; |
391 } | 402 } |
OLD | NEW |