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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/renderer/media/user_media_client_impl.h" 5 #include "content/renderer/media/user_media_client_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 base::Passed(&controls), request_settings)); 382 base::Passed(&controls), request_settings));
383 } 383 }
384 384
385 void UserMediaClientImpl::FinalizeSelectVideoDeviceSourceSettings( 385 void UserMediaClientImpl::FinalizeSelectVideoDeviceSourceSettings(
386 int request_id, 386 int request_id,
387 const blink::WebUserMediaRequest& user_media_request, 387 const blink::WebUserMediaRequest& user_media_request,
388 std::unique_ptr<StreamControls> controls, 388 std::unique_ptr<StreamControls> controls,
389 const RequestSettings& request_settings, 389 const RequestSettings& request_settings,
390 const VideoCaptureSourceSelectionResult& selection_result) { 390 const VideoCaptureSourceSelectionResult& selection_result) {
391 DCHECK(CalledOnValidThread()); 391 DCHECK(CalledOnValidThread());
392 // Select video device. 392 if (selection_result.has_value()) {
393 if (!selection_result.has_value()) { 393 controls->video.device_id = selection_result.settings.device_id();
394 } else {
395 // TODO(guidou): Abort the request in all cases where |selection_result|
396 // has no value, as the spec mandates.
397 // Currently, some applications rely on the nonstandard behavior of asking
398 // for permission even if constraints cannot be satisfied or there are no
399 // devices. Fix once the standard behavior ceases to be disruptive.
400 // See http://crbug.com/690491.
394 blink::WebString failed_constraint_name = 401 blink::WebString failed_constraint_name =
395 blink::WebString::fromASCII(selection_result.failed_constraint_name); 402 blink::WebString::fromASCII(selection_result.failed_constraint_name);
396 MediaStreamRequestResult result = 403 blink::WebString device_id_constraint_name = blink::WebString::fromASCII(
397 failed_constraint_name.isEmpty() 404 user_media_request.videoConstraints().basic().deviceId.name());
398 ? MEDIA_DEVICE_NO_HARDWARE 405 if (failed_constraint_name.equals(device_id_constraint_name)) {
399 : MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED; 406 GetUserMediaRequestFailed(user_media_request,
400 GetUserMediaRequestFailed(user_media_request, result, 407 MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED,
401 failed_constraint_name); 408 failed_constraint_name);
402 return; 409 return;
410 }
403 } 411 }
404 controls->video.device_id = selection_result.settings.device_id();
405 FinalizeRequestUserMedia(request_id, user_media_request, std::move(controls), 412 FinalizeRequestUserMedia(request_id, user_media_request, std::move(controls),
406 request_settings); 413 request_settings);
407 } 414 }
408 415
409 void UserMediaClientImpl::FinalizeRequestUserMedia( 416 void UserMediaClientImpl::FinalizeRequestUserMedia(
410 int request_id, 417 int request_id,
411 const blink::WebUserMediaRequest& user_media_request, 418 const blink::WebUserMediaRequest& user_media_request,
412 std::unique_ptr<StreamControls> controls, 419 std::unique_ptr<StreamControls> controls,
413 const RequestSettings& request_settings) { 420 const RequestSettings& request_settings) {
414 DCHECK(CalledOnValidThread()); 421 DCHECK(CalledOnValidThread());
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 sources_waiting_for_callback_.end(), source); 1242 sources_waiting_for_callback_.end(), source);
1236 if (found != sources_waiting_for_callback_.end()) 1243 if (found != sources_waiting_for_callback_.end())
1237 OnTrackStarted(source, result, result_name); 1244 OnTrackStarted(source, result, result_name);
1238 } 1245 }
1239 1246
1240 void UserMediaClientImpl::OnDestruct() { 1247 void UserMediaClientImpl::OnDestruct() {
1241 delete this; 1248 delete this;
1242 } 1249 }
1243 1250
1244 } // namespace content 1251 } // namespace content
OLDNEW
« 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