| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 GetDevicePolicy(prefs::kAudioCaptureAllowed) == ALWAYS_DENY) { | 57 GetDevicePolicy(prefs::kAudioCaptureAllowed) == ALWAYS_DENY) { |
| 58 microphone_requested_ = false; | 58 microphone_requested_ = false; |
| 59 } | 59 } |
| 60 | 60 |
| 61 if (webcam_requested_ && | 61 if (webcam_requested_ && |
| 62 GetDevicePolicy(prefs::kVideoCaptureAllowed) == ALWAYS_DENY) { | 62 GetDevicePolicy(prefs::kVideoCaptureAllowed) == ALWAYS_DENY) { |
| 63 webcam_requested_ = false; | 63 webcam_requested_ = false; |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 MediaStreamDevicesController::~MediaStreamDevicesController() {} | 67 MediaStreamDevicesController::~MediaStreamDevicesController() { |
| 68 if (!callback_.is_null()) { |
| 69 callback_.Run(content::MediaStreamDevices(), |
| 70 scoped_ptr<content::MediaStreamUI>()); |
| 71 } |
| 72 } |
| 68 | 73 |
| 69 // static | 74 // static |
| 70 void MediaStreamDevicesController::RegisterUserPrefs( | 75 void MediaStreamDevicesController::RegisterUserPrefs( |
| 71 PrefRegistrySyncable* prefs) { | 76 PrefRegistrySyncable* prefs) { |
| 72 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, | 77 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, |
| 73 true, | 78 true, |
| 74 PrefRegistrySyncable::UNSYNCABLE_PREF); | 79 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 75 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, | 80 prefs->RegisterBooleanPref(prefs::kAudioCaptureAllowed, |
| 76 true, | 81 true, |
| 77 PrefRegistrySyncable::UNSYNCABLE_PREF); | 82 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 if (update_content_setting && IsSchemeSecure() && !devices.empty()) | 170 if (update_content_setting && IsSchemeSecure() && !devices.empty()) |
| 166 SetPermission(true); | 171 SetPermission(true); |
| 167 } | 172 } |
| 168 | 173 |
| 169 scoped_ptr<content::MediaStreamUI> ui; | 174 scoped_ptr<content::MediaStreamUI> ui; |
| 170 if (!devices.empty()) { | 175 if (!devices.empty()) { |
| 171 ui = MediaCaptureDevicesDispatcher::GetInstance()-> | 176 ui = MediaCaptureDevicesDispatcher::GetInstance()-> |
| 172 GetMediaStreamCaptureIndicator()->RegisterMediaStream( | 177 GetMediaStreamCaptureIndicator()->RegisterMediaStream( |
| 173 web_contents_, devices); | 178 web_contents_, devices); |
| 174 } | 179 } |
| 175 callback_.Run(devices, ui.Pass()); | 180 content::MediaResponseCallback cb = callback_; |
| 181 callback_.Reset(); |
| 182 cb.Run(devices, ui.Pass()); |
| 176 } | 183 } |
| 177 | 184 |
| 178 void MediaStreamDevicesController::Deny(bool update_content_setting) { | 185 void MediaStreamDevicesController::Deny(bool update_content_setting) { |
| 179 // TODO(markusheintz): Replace CONTENT_SETTINGS_TYPE_MEDIA_STREAM with the | 186 // TODO(markusheintz): Replace CONTENT_SETTINGS_TYPE_MEDIA_STREAM with the |
| 180 // appropriate new CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC and | 187 // appropriate new CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC and |
| 181 // CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA. | 188 // CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA. |
| 182 if (content_settings_) { | 189 if (content_settings_) { |
| 183 content_settings_->OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM, | 190 content_settings_->OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM, |
| 184 std::string()); | 191 std::string()); |
| 185 } | 192 } |
| 186 | 193 |
| 187 if (update_content_setting) | 194 if (update_content_setting) |
| 188 SetPermission(false); | 195 SetPermission(false); |
| 189 | 196 |
| 190 callback_.Run(content::MediaStreamDevices(), | 197 content::MediaResponseCallback cb = callback_; |
| 191 scoped_ptr<content::MediaStreamUI>()); | 198 callback_.Reset(); |
| 199 cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>()); |
| 192 } | 200 } |
| 193 | 201 |
| 194 MediaStreamDevicesController::DevicePolicy | 202 MediaStreamDevicesController::DevicePolicy |
| 195 MediaStreamDevicesController::GetDevicePolicy(const char* policy_name) const { | 203 MediaStreamDevicesController::GetDevicePolicy(const char* policy_name) const { |
| 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 197 | 205 |
| 198 PrefService* prefs = profile_->GetPrefs(); | 206 PrefService* prefs = profile_->GetPrefs(); |
| 199 if (!prefs->IsManagedPreference(policy_name)) | 207 if (!prefs->IsManagedPreference(policy_name)) |
| 200 return POLICY_NOT_SET; | 208 return POLICY_NOT_SET; |
| 201 | 209 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } | 317 } |
| 310 if (webcam_requested_) { | 318 if (webcam_requested_) { |
| 311 profile_->GetHostContentSettingsMap()->SetContentSetting( | 319 profile_->GetHostContentSettingsMap()->SetContentSetting( |
| 312 primary_pattern, | 320 primary_pattern, |
| 313 ContentSettingsPattern::Wildcard(), | 321 ContentSettingsPattern::Wildcard(), |
| 314 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 322 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 315 std::string(), | 323 std::string(), |
| 316 content_setting); | 324 content_setting); |
| 317 } | 325 } |
| 318 } | 326 } |
| OLD | NEW |