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

Unified Diff: content/renderer/media/user_media_client_impl.cc

Issue 2683053004: Make getUserMedia() ask for permission if video constraints cannot be satisfied. (Closed)
Patch Set: Created 3 years, 10 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: content/renderer/media/user_media_client_impl.cc
diff --git a/content/renderer/media/user_media_client_impl.cc b/content/renderer/media/user_media_client_impl.cc
index 1ff102e63cf2d33cf5ea60318325dac991b6a813..691e768b3b1c2f186d9b218d774e8466c3bfb73e 100644
--- a/content/renderer/media/user_media_client_impl.cc
+++ b/content/renderer/media/user_media_client_impl.cc
@@ -389,19 +389,26 @@ void UserMediaClientImpl::FinalizeSelectVideoDeviceSourceSettings(
const RequestSettings& request_settings,
const VideoCaptureSourceSelectionResult& selection_result) {
DCHECK(CalledOnValidThread());
- // Select video device.
- if (!selection_result.has_value()) {
+ if (selection_result.has_value()) {
+ controls->video.device_id = selection_result.settings.device_id();
+ } else {
+ // TODO(guidou): Abort the request in all cases where |selection_result|
+ // has no value, as the spec mandates.
+ // Currently, some applications rely on the nonstandard behavior of asking
+ // for permission even if constraints cannot be satisfied or there are no
+ // devices. Fix once the standard behavior ceases to be disruptive.
+ // See http://crbug.com/690491.
blink::WebString failed_constraint_name =
blink::WebString::fromASCII(selection_result.failed_constraint_name);
- MediaStreamRequestResult result =
- failed_constraint_name.isEmpty()
- ? MEDIA_DEVICE_NO_HARDWARE
- : MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED;
- GetUserMediaRequestFailed(user_media_request, result,
- failed_constraint_name);
- return;
+ blink::WebString device_id_constraint_name = blink::WebString::fromASCII(
+ user_media_request.videoConstraints().basic().deviceId.name());
+ if (failed_constraint_name.equals(device_id_constraint_name)) {
+ GetUserMediaRequestFailed(user_media_request,
+ MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED,
+ failed_constraint_name);
+ return;
+ }
}
- controls->video.device_id = selection_result.settings.device_id();
FinalizeRequestUserMedia(request_id, user_media_request, std::move(controls),
request_settings);
}
« 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