Commit e2169993 authored by grunell@chromium.org's avatar grunell@chromium.org

Make sure we don't open audio or video device if blocked by policy.

Adding a check if the type (audio, video) was requested and allowed before adding the device to the list.

BUG=259567

Review URL: https://chromiumcodereview.appspot.com/23453012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220559 0039d316-1c4b-4281-b951-d872f2087c98
parent d623a468
...@@ -188,7 +188,8 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) { ...@@ -188,7 +188,8 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) {
const content::MediaStreamDevice* device = NULL; const content::MediaStreamDevice* device = NULL;
// For open device request pick the desired device or fall back to the // For open device request pick the desired device or fall back to the
// first available of the given type. // first available of the given type.
if (request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) { if (audio_allowed &&
request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) {
device = MediaCaptureDevicesDispatcher::GetInstance()-> device = MediaCaptureDevicesDispatcher::GetInstance()->
GetRequestedAudioDevice(request_.requested_audio_device_id); GetRequestedAudioDevice(request_.requested_audio_device_id);
// TODO(wjia): Confirm this is the intended behavior. // TODO(wjia): Confirm this is the intended behavior.
...@@ -196,7 +197,8 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) { ...@@ -196,7 +197,8 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) {
device = MediaCaptureDevicesDispatcher::GetInstance()-> device = MediaCaptureDevicesDispatcher::GetInstance()->
GetFirstAvailableAudioDevice(); GetFirstAvailableAudioDevice();
} }
} else if (request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) { } else if (video_allowed &&
request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) {
// Pepper API opens only one device at a time. // Pepper API opens only one device at a time.
device = MediaCaptureDevicesDispatcher::GetInstance()-> device = MediaCaptureDevicesDispatcher::GetInstance()->
GetRequestedVideoDevice(request_.requested_video_device_id); GetRequestedVideoDevice(request_.requested_video_device_id);
...@@ -209,41 +211,43 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) { ...@@ -209,41 +211,43 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) {
if (device) if (device)
devices.push_back(*device); devices.push_back(*device);
break; break;
} case content::MEDIA_GENERATE_STREAM: { }
bool needs_audio_device = audio_allowed; case content::MEDIA_GENERATE_STREAM: {
bool needs_video_device = video_allowed; bool get_default_audio_device = audio_allowed;
bool get_default_video_device = video_allowed;
// Get the exact audio or video device if an id is specified. // Get the exact audio or video device if an id is specified.
if (!request_.requested_audio_device_id.empty()) { if (audio_allowed && !request_.requested_audio_device_id.empty()) {
const content::MediaStreamDevice* audio_device = const content::MediaStreamDevice* audio_device =
MediaCaptureDevicesDispatcher::GetInstance()-> MediaCaptureDevicesDispatcher::GetInstance()->
GetRequestedAudioDevice(request_.requested_audio_device_id); GetRequestedAudioDevice(request_.requested_audio_device_id);
if (audio_device) { if (audio_device) {
devices.push_back(*audio_device); devices.push_back(*audio_device);
needs_audio_device = false; get_default_audio_device = false;
} }
} }
if (!request_.requested_video_device_id.empty()) { if (video_allowed && !request_.requested_video_device_id.empty()) {
const content::MediaStreamDevice* video_device = const content::MediaStreamDevice* video_device =
MediaCaptureDevicesDispatcher::GetInstance()-> MediaCaptureDevicesDispatcher::GetInstance()->
GetRequestedVideoDevice(request_.requested_video_device_id); GetRequestedVideoDevice(request_.requested_video_device_id);
if (video_device) { if (video_device) {
devices.push_back(*video_device); devices.push_back(*video_device);
needs_video_device = false; get_default_video_device = false;
} }
} }
// If either or both audio and video devices were requested but not // If either or both audio and video devices were requested but not
// specified by id, get the default devices. // specified by id, get the default devices.
if (needs_audio_device || needs_video_device) { if (get_default_audio_device || get_default_video_device) {
MediaCaptureDevicesDispatcher::GetInstance()-> MediaCaptureDevicesDispatcher::GetInstance()->
GetDefaultDevicesForProfile(profile_, GetDefaultDevicesForProfile(profile_,
needs_audio_device, get_default_audio_device,
needs_video_device, get_default_video_device,
&devices); &devices);
} }
break; break;
} case content::MEDIA_DEVICE_ACCESS: }
case content::MEDIA_DEVICE_ACCESS: {
// Get the default devices for the request. // Get the default devices for the request.
MediaCaptureDevicesDispatcher::GetInstance()-> MediaCaptureDevicesDispatcher::GetInstance()->
GetDefaultDevicesForProfile(profile_, GetDefaultDevicesForProfile(profile_,
...@@ -251,11 +255,13 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) { ...@@ -251,11 +255,13 @@ void MediaStreamDevicesController::Accept(bool update_content_setting) {
video_allowed, video_allowed,
&devices); &devices);
break; break;
case content::MEDIA_ENUMERATE_DEVICES: }
case content::MEDIA_ENUMERATE_DEVICES: {
// Do nothing. // Do nothing.
NOTREACHED(); NOTREACHED();
break; break;
} }
} // switch
// TODO(raymes): We currently set the content permission for non-https // TODO(raymes): We currently set the content permission for non-https
// websites for Pepper requests as well. This is temporary and should be // websites for Pepper requests as well. This is temporary and should be
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment