Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2257)

Unified Diff: chrome/browser/media/media_capture_devices_dispatcher.cc

Issue 585263002: Change two media request "invalid state" results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698