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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(), |
| 134 content::MEDIA_DEVICE_INVALID_STATE, |
134 scoped_ptr<content::MediaStreamUI>()); | 135 scoped_ptr<content::MediaStreamUI>()); |
135 } | 136 } |
136 } | 137 } |
137 | 138 |
138 // static | 139 // static |
139 void MediaStreamDevicesController::RegisterProfilePrefs( | 140 void MediaStreamDevicesController::RegisterProfilePrefs( |
140 user_prefs::PrefRegistrySyncable* prefs) { | 141 user_prefs::PrefRegistrySyncable* prefs) { |
141 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, | 142 prefs->RegisterBooleanPref(prefs::kVideoCaptureAllowed, |
142 true, | 143 true, |
143 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 144 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 } | 329 } |
329 | 330 |
330 scoped_ptr<content::MediaStreamUI> ui; | 331 scoped_ptr<content::MediaStreamUI> ui; |
331 if (!devices.empty()) { | 332 if (!devices.empty()) { |
332 ui = MediaCaptureDevicesDispatcher::GetInstance()-> | 333 ui = MediaCaptureDevicesDispatcher::GetInstance()-> |
333 GetMediaStreamCaptureIndicator()->RegisterMediaStream( | 334 GetMediaStreamCaptureIndicator()->RegisterMediaStream( |
334 web_contents_, devices); | 335 web_contents_, devices); |
335 } | 336 } |
336 content::MediaResponseCallback cb = callback_; | 337 content::MediaResponseCallback cb = callback_; |
337 callback_.Reset(); | 338 callback_.Reset(); |
338 cb.Run(devices, ui.Pass()); | 339 cb.Run(devices, content::MEDIA_DEVICE_OK, ui.Pass()); |
339 } | 340 } |
340 | 341 |
341 void MediaStreamDevicesController::Deny(bool update_content_setting) { | 342 void MediaStreamDevicesController::Deny(bool update_content_setting) { |
342 NotifyUIRequestDenied(); | 343 NotifyUIRequestDenied(); |
343 | 344 |
344 if (update_content_setting) | 345 if (update_content_setting) |
345 SetPermission(false); | 346 SetPermission(false); |
346 | 347 |
347 content::MediaResponseCallback cb = callback_; | 348 content::MediaResponseCallback cb = callback_; |
348 callback_.Reset(); | 349 callback_.Reset(); |
349 cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>()); | 350 cb.Run(content::MediaStreamDevices(), |
| 351 update_content_setting ? |
| 352 content::MEDIA_DEVICE_PERMISSION_DENIED : |
| 353 content::MEDIA_DEVICE_PERMISSION_DISMISSED, |
| 354 scoped_ptr<content::MediaStreamUI>()); |
350 } | 355 } |
351 | 356 |
352 base::string16 MediaStreamDevicesController::GetMessageText() const { | 357 base::string16 MediaStreamDevicesController::GetMessageText() const { |
353 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 358 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
354 if (!HasAudio()) | 359 if (!HasAudio()) |
355 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 360 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
356 else if (!HasVideo()) | 361 else if (!HasVideo()) |
357 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | 362 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; |
358 return l10n_util::GetStringFUTF16( | 363 return l10n_util::GetStringFUTF16( |
359 message_id, base::UTF8ToUTF16(GetSecurityOriginSpec())); | 364 message_id, base::UTF8ToUTF16(GetSecurityOriginSpec())); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 it->second.permission == MEDIA_ALLOWED); | 625 it->second.permission == MEDIA_ALLOWED); |
621 } | 626 } |
622 | 627 |
623 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() | 628 bool MediaStreamDevicesController::IsDeviceVideoCaptureRequestedAndAllowed() |
624 const { | 629 const { |
625 MediaStreamTypeSettingsMap::const_iterator it = | 630 MediaStreamTypeSettingsMap::const_iterator it = |
626 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); | 631 request_permissions_.find(content::MEDIA_DEVICE_VIDEO_CAPTURE); |
627 return (it != request_permissions_.end() && | 632 return (it != request_permissions_.end() && |
628 it->second.permission == MEDIA_ALLOWED); | 633 it->second.permission == MEDIA_ALLOWED); |
629 } | 634 } |
OLD | NEW |