| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/content_settings/content_settings_provider.h" | 10 #include "chrome/browser/content_settings/content_settings_provider.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 microphone_requested_ = false; | 76 microphone_requested_ = false; |
| 77 } | 77 } |
| 78 | 78 |
| 79 if (webcam_requested_ && | 79 if (webcam_requested_ && |
| 80 GetDevicePolicy(prefs::kVideoCaptureAllowed, | 80 GetDevicePolicy(prefs::kVideoCaptureAllowed, |
| 81 prefs::kVideoCaptureAllowedUrls) == ALWAYS_DENY) { | 81 prefs::kVideoCaptureAllowedUrls) == ALWAYS_DENY) { |
| 82 webcam_requested_ = false; | 82 webcam_requested_ = false; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 MediaStreamDevicesController::~MediaStreamDevicesController() {} | 86 MediaStreamDevicesController::~MediaStreamDevicesController() { |
| 87 if (!callback_.is_null()) { |
| 88 callback_.Run(content::MediaStreamDevices(), |
| 89 scoped_ptr<content::MediaStreamUI>()); |
| 90 } |
| 91 } |
| 87 | 92 |
| 88 // static | 93 // static |
| 89 void MediaStreamDevicesController::RegisterUserPrefs( | 94 void MediaStreamDevicesController::RegisterUserPrefs( |
| 90 user_prefs::PrefRegistrySyncable* prefs) { | 95 user_prefs::PrefRegistrySyncable* prefs) { |
| 91 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, | 96 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, |
| 92 true, | 97 true, |
| 93 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 98 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 94 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, | 99 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, |
| 95 true, | 100 true, |
| 96 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 101 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (update_content_setting && IsSchemeSecure() && !devices.empty()) | 193 if (update_content_setting && IsSchemeSecure() && !devices.empty()) |
| 189 SetPermission(true); | 194 SetPermission(true); |
| 190 } | 195 } |
| 191 | 196 |
| 192 scoped_ptr<content::MediaStreamUI> ui; | 197 scoped_ptr<content::MediaStreamUI> ui; |
| 193 if (!devices.empty()) { | 198 if (!devices.empty()) { |
| 194 ui = MediaCaptureDevicesDispatcher::GetInstance()-> | 199 ui = MediaCaptureDevicesDispatcher::GetInstance()-> |
| 195 GetMediaStreamCaptureIndicator()->RegisterMediaStream( | 200 GetMediaStreamCaptureIndicator()->RegisterMediaStream( |
| 196 web_contents_, devices); | 201 web_contents_, devices); |
| 197 } | 202 } |
| 198 callback_.Run(devices, ui.Pass()); | 203 content::MediaResponseCallback cb = callback_; |
| 204 callback_.Reset(); |
| 205 cb.Run(devices, ui.Pass()); |
| 199 } | 206 } |
| 200 | 207 |
| 201 void MediaStreamDevicesController::Deny(bool update_content_setting) { | 208 void MediaStreamDevicesController::Deny(bool update_content_setting) { |
| 202 // TODO(markusheintz): Replace CONTENT_SETTINGS_TYPE_MEDIA_STREAM with the | 209 // TODO(markusheintz): Replace CONTENT_SETTINGS_TYPE_MEDIA_STREAM with the |
| 203 // appropriate new CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC and | 210 // appropriate new CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC and |
| 204 // CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA. | 211 // CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA. |
| 205 if (content_settings_) { | 212 if (content_settings_) { |
| 206 content_settings_->OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM, | 213 content_settings_->OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM, |
| 207 std::string()); | 214 std::string()); |
| 208 } | 215 } |
| 209 | 216 |
| 210 if (update_content_setting) | 217 if (update_content_setting) |
| 211 SetPermission(false); | 218 SetPermission(false); |
| 212 | 219 |
| 213 callback_.Run(content::MediaStreamDevices(), | 220 content::MediaResponseCallback cb = callback_; |
| 214 scoped_ptr<content::MediaStreamUI>()); | 221 callback_.Reset(); |
| 222 cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>()); |
| 215 } | 223 } |
| 216 | 224 |
| 217 MediaStreamDevicesController::DevicePolicy | 225 MediaStreamDevicesController::DevicePolicy |
| 218 MediaStreamDevicesController::GetDevicePolicy( | 226 MediaStreamDevicesController::GetDevicePolicy( |
| 219 const char* policy_name, | 227 const char* policy_name, |
| 220 const char* whitelist_policy_name) const { | 228 const char* whitelist_policy_name) const { |
| 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 222 | 230 |
| 223 // If the security origin policy matches a value in the whitelist, allow it. | 231 // If the security origin policy matches a value in the whitelist, allow it. |
| 224 // Otherwise, check the |policy_name| master switch for the default behavior. | 232 // Otherwise, check the |policy_name| master switch for the default behavior. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 } | 374 } |
| 367 if (webcam_requested_) { | 375 if (webcam_requested_) { |
| 368 profile_->GetHostContentSettingsMap()->SetContentSetting( | 376 profile_->GetHostContentSettingsMap()->SetContentSetting( |
| 369 primary_pattern, | 377 primary_pattern, |
| 370 ContentSettingsPattern::Wildcard(), | 378 ContentSettingsPattern::Wildcard(), |
| 371 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 379 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 372 std::string(), | 380 std::string(), |
| 373 content_setting); | 381 content_setting); |
| 374 } | 382 } |
| 375 } | 383 } |
| OLD | NEW |