| 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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 request_permissions_.insert(std::make_pair( | 123 request_permissions_.insert(std::make_pair( |
| 124 content::MEDIA_DEVICE_VIDEO_CAPTURE, | 124 content::MEDIA_DEVICE_VIDEO_CAPTURE, |
| 125 MediaStreamTypeSettings(MEDIA_ALLOWED, | 125 MediaStreamTypeSettings(MEDIA_ALLOWED, |
| 126 request.requested_video_device_id))); | 126 request.requested_video_device_id))); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 MediaStreamDevicesController::~MediaStreamDevicesController() { | 131 MediaStreamDevicesController::~MediaStreamDevicesController() { |
| 132 if (!callback_.is_null()) { | 132 if (!callback_.is_null()) { |
| 133 callback_.Run(content::MediaStreamDevices(), | 133 callback_.Run(content::MediaStreamDevices(), content::INVALID_STATE, |
| 134 scoped_ptr<content::MediaStreamUI>()); | 134 scoped_ptr<content::MediaStreamUI>()); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 // static | 138 // static |
| 139 void MediaStreamDevicesController::RegisterProfilePrefs( | 139 void MediaStreamDevicesController::RegisterProfilePrefs( |
| 140 user_prefs::PrefRegistrySyncable* prefs) { | 140 user_prefs::PrefRegistrySyncable* prefs) { |
| 141 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, | 141 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, |
| 142 true, | 142 true, |
| 143 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 143 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 | 329 |
| 330 scoped_ptr<content::MediaStreamUI> ui; | 330 scoped_ptr<content::MediaStreamUI> ui; |
| 331 if (!devices.empty()) { | 331 if (!devices.empty()) { |
| 332 ui = MediaCaptureDevicesDispatcher::GetInstance()-> | 332 ui = MediaCaptureDevicesDispatcher::GetInstance()-> |
| 333 GetMediaStreamCaptureIndicator()->RegisterMediaStream( | 333 GetMediaStreamCaptureIndicator()->RegisterMediaStream( |
| 334 web_contents_, devices); | 334 web_contents_, devices); |
| 335 } | 335 } |
| 336 content::MediaResponseCallback cb = callback_; | 336 content::MediaResponseCallback cb = callback_; |
| 337 callback_.Reset(); | 337 callback_.Reset(); |
| 338 cb.Run(devices, ui.Pass()); | 338 cb.Run(devices, content::OK, ui.Pass()); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void MediaStreamDevicesController::Deny(bool update_content_setting) { | 341 void MediaStreamDevicesController::Deny(bool update_content_setting) { |
| 342 NotifyUIRequestDenied(); | 342 NotifyUIRequestDenied(); |
| 343 | 343 |
| 344 if (update_content_setting) | 344 if (update_content_setting) |
| 345 SetPermission(false); | 345 SetPermission(false); |
| 346 | 346 |
| 347 content::MediaResponseCallback cb = callback_; | 347 content::MediaResponseCallback cb = callback_; |
| 348 callback_.Reset(); | 348 callback_.Reset(); |
| 349 cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>()); | 349 cb.Run(content::MediaStreamDevices(), |
| 350 update_content_setting ? |
| 351 content::PERMISSION_DENIED : |
| 352 content::PERMISSION_DISMISSED, |
| 353 scoped_ptr<content::MediaStreamUI>()); |
| 350 } | 354 } |
| 351 | 355 |
| 352 base::string16 MediaStreamDevicesController::GetMessageText() const { | 356 base::string16 MediaStreamDevicesController::GetMessageText() const { |
| 353 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 357 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
| 354 if (!HasAudio()) | 358 if (!HasAudio()) |
| 355 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 359 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
| 356 else if (!HasVideo()) | 360 else if (!HasVideo()) |
| 357 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | 361 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; |
| 358 return l10n_util::GetStringFUTF16( | 362 return l10n_util::GetStringFUTF16( |
| 359 message_id, base::UTF8ToUTF16(GetSecurityOriginSpec())); | 363 message_id, base::UTF8ToUTF16(GetSecurityOriginSpec())); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 it->second.permission == MEDIA_ALLOWED); | 624 it->second.permission == MEDIA_ALLOWED); |
| 621 } | 625 } |
| 622 | 626 |
| 623 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() | 627 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() |
| 624 const { | 628 const { |
| 625 MediaStreamTypeSettingsMap::const_iterator it = | 629 MediaStreamTypeSettingsMap::const_iterator it = |
| 626 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); | 630 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); |
| 627 return (it != request_permissions_.end() && | 631 return (it != request_permissions_.end() && |
| 628 it->second.permission == MEDIA_ALLOWED); | 632 it->second.permission == MEDIA_ALLOWED); |
| 629 } | 633 } |
| OLD | NEW |