Chromium Code Reviews| Index: chrome/browser/media/media_capture_devices_dispatcher.cc |
| diff --git a/chrome/browser/media/media_capture_devices_dispatcher.cc b/chrome/browser/media/media_capture_devices_dispatcher.cc |
| index def0efa240eadcec162d11fc3b25e436fe2ac12d..21140474deff423561ab8a54af09f1af82feef98 100644 |
| --- a/chrome/browser/media/media_capture_devices_dispatcher.cc |
| +++ b/chrome/browser/media/media_capture_devices_dispatcher.cc |
| @@ -626,12 +626,15 @@ void MediaCaptureDevicesDispatcher::ProcessScreenCaptureAccessRequest( |
| ui = GetDevicesForDesktopCapture(devices, screen_id, capture_audio, |
| display_notification, application_title, |
| application_title); |
| + DCHECK(!devices.empty()); |
| } |
| } |
| + // The only case when devices can be empty is if the user has denied |
| + // permission. |
|
tommi (sloooow) - chröme
2014/09/20 14:45:23
or !screen_capture_enabled or !origin_is_secure?
Henrik Grunell
2014/09/22 09:16:14
Ah, right.
|
| callback.Run( |
| devices, |
| - devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : |
| + devices.empty() ? content::MEDIA_DEVICE_PERMISSION_DENIED : |
| content::MEDIA_DEVICE_OK, |
| ui.Pass()); |
| } |
| @@ -711,7 +714,21 @@ void MediaCaptureDevicesDispatcher:: |
| content::MediaStreamDevices devices; |
| + // Set an initial error result. If neither audio or video is allowed, we'll |
| + // never try to get any device below but will just create |ui| and return an |
| + // empty list with "invalid state" result. If at least one is allowed, we'll |
| + // try to get device(s), and if failure, we want to return "no hardware" |
| + // result. |
| + // TODO(grunell): The invalid state result should be changed to a new denied |
| + // result + a dcheck to ensure at least one of audio or video types is |
| + // capture. |
| + content::MediaStreamRequestResult result = |
| + audio_allowed || video_allowed ? content::MEDIA_DEVICE_NO_HARDWARE |
| + : content::MEDIA_DEVICE_INVALID_STATE; |
|
tommi (sloooow) - chröme
2014/09/20 14:45:23
instead of invalid state, should it be permission
Henrik Grunell
2014/09/22 09:16:14
Same reply as above, as the todo also says.
|
| + |
| // Get the exact audio or video device if an id is specified. |
| + // We only set any error result here and before running the callback change |
| + // it to OK if we have any device. |
| if (audio_allowed && !request.requested_audio_device_id.empty()) { |
| const content::MediaStreamDevice* audio_device = |
| GetRequestedAudioDevice(request.requested_audio_device_id); |
| @@ -742,6 +759,7 @@ void MediaCaptureDevicesDispatcher:: |
| scoped_ptr<content::MediaStreamUI> ui; |
| if (!devices.empty()) { |
| + result = content::MEDIA_DEVICE_OK; |
| ui = media_stream_capture_indicator_->RegisterMediaStream( |
| web_contents, devices); |
| } |