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

Side by Side 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 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 "chrome/browser/media/media_capture_devices_dispatcher.h" 5 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 (request.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE && 619 (request.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE &&
620 loopback_audio_supported); 620 loopback_audio_supported);
621 621
622 // Unless we're being invoked from a component extension, register to 622 // Unless we're being invoked from a component extension, register to
623 // display the notification for stream capture. 623 // display the notification for stream capture.
624 bool display_notification = !component_extension; 624 bool display_notification = !component_extension;
625 625
626 ui = GetDevicesForDesktopCapture(devices, screen_id, capture_audio, 626 ui = GetDevicesForDesktopCapture(devices, screen_id, capture_audio,
627 display_notification, application_title, 627 display_notification, application_title,
628 application_title); 628 application_title);
629 DCHECK(!devices.empty());
629 } 630 }
630 } 631 }
631 632
633 // The only case when devices can be empty is if the user has denied
634 // 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.
632 callback.Run( 635 callback.Run(
633 devices, 636 devices,
634 devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : 637 devices.empty() ? content::MEDIA_DEVICE_PERMISSION_DENIED :
635 content::MEDIA_DEVICE_OK, 638 content::MEDIA_DEVICE_OK,
636 ui.Pass()); 639 ui.Pass());
637 } 640 }
638 641
639 void MediaCaptureDevicesDispatcher::ProcessTabCaptureAccessRequest( 642 void MediaCaptureDevicesDispatcher::ProcessTabCaptureAccessRequest(
640 content::WebContents* web_contents, 643 content::WebContents* web_contents,
641 const content::MediaStreamRequest& request, 644 const content::MediaStreamRequest& request,
642 const content::MediaResponseCallback& callback, 645 const content::MediaResponseCallback& callback,
643 const extensions::Extension* extension) { 646 const extensions::Extension* extension) {
644 content::MediaStreamDevices devices; 647 content::MediaStreamDevices devices;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 bool video_allowed = 707 bool video_allowed =
705 request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE && 708 request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE &&
706 extension->permissions_data()->HasAPIPermission( 709 extension->permissions_data()->HasAPIPermission(
707 extensions::APIPermission::kVideoCapture); 710 extensions::APIPermission::kVideoCapture);
708 711
709 bool get_default_audio_device = audio_allowed; 712 bool get_default_audio_device = audio_allowed;
710 bool get_default_video_device = video_allowed; 713 bool get_default_video_device = video_allowed;
711 714
712 content::MediaStreamDevices devices; 715 content::MediaStreamDevices devices;
713 716
717 // Set an initial error result. If neither audio or video is allowed, we'll
718 // never try to get any device below but will just create |ui| and return an
719 // empty list with "invalid state" result. If at least one is allowed, we'll
720 // try to get device(s), and if failure, we want to return "no hardware"
721 // result.
722 // TODO(grunell): The invalid state result should be changed to a new denied
723 // result + a dcheck to ensure at least one of audio or video types is
724 // capture.
725 content::MediaStreamRequestResult result =
726 audio_allowed || video_allowed ? content::MEDIA_DEVICE_NO_HARDWARE
727 : 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.
728
714 // Get the exact audio or video device if an id is specified. 729 // Get the exact audio or video device if an id is specified.
730 // We only set any error result here and before running the callback change
731 // it to OK if we have any device.
715 if (audio_allowed && !request.requested_audio_device_id.empty()) { 732 if (audio_allowed && !request.requested_audio_device_id.empty()) {
716 const content::MediaStreamDevice* audio_device = 733 const content::MediaStreamDevice* audio_device =
717 GetRequestedAudioDevice(request.requested_audio_device_id); 734 GetRequestedAudioDevice(request.requested_audio_device_id);
718 if (audio_device) { 735 if (audio_device) {
719 devices.push_back(*audio_device); 736 devices.push_back(*audio_device);
720 get_default_audio_device = false; 737 get_default_audio_device = false;
721 } 738 }
722 } 739 }
723 if (video_allowed && !request.requested_video_device_id.empty()) { 740 if (video_allowed && !request.requested_video_device_id.empty()) {
724 const content::MediaStreamDevice* video_device = 741 const content::MediaStreamDevice* video_device =
(...skipping 10 matching lines...) Expand all
735 Profile* profile = 752 Profile* profile =
736 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 753 Profile::FromBrowserContext(web_contents->GetBrowserContext());
737 GetDefaultDevicesForProfile(profile, 754 GetDefaultDevicesForProfile(profile,
738 get_default_audio_device, 755 get_default_audio_device,
739 get_default_video_device, 756 get_default_video_device,
740 &devices); 757 &devices);
741 } 758 }
742 759
743 scoped_ptr<content::MediaStreamUI> ui; 760 scoped_ptr<content::MediaStreamUI> ui;
744 if (!devices.empty()) { 761 if (!devices.empty()) {
762 result = content::MEDIA_DEVICE_OK;
745 ui = media_stream_capture_indicator_->RegisterMediaStream( 763 ui = media_stream_capture_indicator_->RegisterMediaStream(
746 web_contents, devices); 764 web_contents, devices);
747 } 765 }
748 callback.Run( 766 callback.Run(
749 devices, 767 devices,
750 devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : 768 devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE :
tommi (sloooow) - chröme 2014/09/20 14:45:23 did you mean to use |result| here?
tommi (sloooow) - chröme 2014/09/22 20:15:02 I guess you missed this comment?
Henrik Grunell 2014/09/23 07:39:28 Yep. It's fixed now.
751 content::MEDIA_DEVICE_OK, 769 content::MEDIA_DEVICE_OK,
752 ui.Pass()); 770 ui.Pass());
753 } 771 }
754 772
755 void MediaCaptureDevicesDispatcher::ProcessRegularMediaAccessRequest( 773 void MediaCaptureDevicesDispatcher::ProcessRegularMediaAccessRequest(
756 content::WebContents* web_contents, 774 content::WebContents* web_contents,
757 const content::MediaStreamRequest& request, 775 const content::MediaStreamRequest& request,
758 const content::MediaResponseCallback& callback) { 776 const content::MediaResponseCallback& callback) {
759 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 777 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
760 778
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 1082
1065 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( 1083 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices(
1066 const MediaStreamDevices& devices) { 1084 const MediaStreamDevices& devices) {
1067 test_audio_devices_ = devices; 1085 test_audio_devices_ = devices;
1068 } 1086 }
1069 1087
1070 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( 1088 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices(
1071 const MediaStreamDevices& devices) { 1089 const MediaStreamDevices& devices) {
1072 test_video_devices_ = devices; 1090 test_video_devices_ = devices;
1073 } 1091 }
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