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

Side by Side Diff: content/renderer/media/user_media_client_impl.cc

Issue 2749893004: Do not ask for permissions if getUserMedia() video-device constraints cannot be satisfied. (Closed)
Patch Set: Created 3 years, 9 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 base::Passed(&controls), request_settings)); 386 base::Passed(&controls), request_settings));
387 } 387 }
388 388
389 void UserMediaClientImpl::FinalizeSelectVideoDeviceSourceSettings( 389 void UserMediaClientImpl::FinalizeSelectVideoDeviceSourceSettings(
390 int request_id, 390 int request_id,
391 const blink::WebUserMediaRequest& user_media_request, 391 const blink::WebUserMediaRequest& user_media_request,
392 std::unique_ptr<StreamControls> controls, 392 std::unique_ptr<StreamControls> controls,
393 const RequestSettings& request_settings, 393 const RequestSettings& request_settings,
394 const VideoDeviceCaptureSourceSelectionResult& selection_result) { 394 const VideoDeviceCaptureSourceSelectionResult& selection_result) {
395 DCHECK(CalledOnValidThread()); 395 DCHECK(CalledOnValidThread());
396 if (selection_result.HasValue()) { 396 if (!selection_result.HasValue()) {
397 controls->video.device_id = selection_result.device_id();
398 } else {
399 // TODO(guidou): Abort the request in all cases where |selection_result|
400 // has no value, as the spec mandates.
401 // Currently, some applications rely on the nonstandard behavior of asking
402 // for permission even if constraints cannot be satisfied or there are no
403 // devices. Fix once the standard behavior ceases to be disruptive.
404 // See http://crbug.com/690491.
405 blink::WebString failed_constraint_name = 397 blink::WebString failed_constraint_name =
406 blink::WebString::fromASCII(selection_result.failed_constraint_name()); 398 blink::WebString::fromASCII(selection_result.failed_constraint_name());
407 blink::WebString device_id_constraint_name = blink::WebString::fromASCII( 399 MediaStreamRequestResult result =
408 user_media_request.videoConstraints().basic().deviceId.name()); 400 failed_constraint_name.isEmpty()
409 if (failed_constraint_name.equals(device_id_constraint_name)) { 401 ? MEDIA_DEVICE_NO_HARDWARE
410 GetUserMediaRequestFailed(user_media_request, 402 : MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED;
411 MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED, 403 GetUserMediaRequestFailed(user_media_request, result,
412 failed_constraint_name); 404 failed_constraint_name);
413 return; 405 return;
414 }
415 } 406 }
407 controls->video.device_id = selection_result.device_id();
416 FinalizeRequestUserMedia(request_id, user_media_request, std::move(controls), 408 FinalizeRequestUserMedia(request_id, user_media_request, std::move(controls),
417 request_settings); 409 request_settings);
418 } 410 }
419 411
420 void UserMediaClientImpl::FinalizeRequestUserMedia( 412 void UserMediaClientImpl::FinalizeRequestUserMedia(
421 int request_id, 413 int request_id,
422 const blink::WebUserMediaRequest& user_media_request, 414 const blink::WebUserMediaRequest& user_media_request,
423 std::unique_ptr<StreamControls> controls, 415 std::unique_ptr<StreamControls> controls,
424 const RequestSettings& request_settings) { 416 const RequestSettings& request_settings) {
425 DCHECK(CalledOnValidThread()); 417 DCHECK(CalledOnValidThread());
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 sources_waiting_for_callback_.end(), source); 1238 sources_waiting_for_callback_.end(), source);
1247 if (found != sources_waiting_for_callback_.end()) 1239 if (found != sources_waiting_for_callback_.end())
1248 OnTrackStarted(source, result, result_name); 1240 OnTrackStarted(source, result, result_name);
1249 } 1241 }
1250 1242
1251 void UserMediaClientImpl::OnDestruct() { 1243 void UserMediaClientImpl::OnDestruct() {
1252 delete this; 1244 delete this;
1253 } 1245 }
1254 1246
1255 } // namespace content 1247 } // 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