Commit fdfc92d5 authored by pastarmovj's avatar pastarmovj Committed by Commit bot

Force extension media access to obey enterprise policy.

BUG=415964
TEST=Install an extension like "Webcam" and make sure it doesn't work when policy is enabled.

Review URL: https://codereview.chromium.org/599903002

Cr-Commit-Position: refs/heads/master@{#297383}
parent b249e749
...@@ -707,14 +707,23 @@ void MediaCaptureDevicesDispatcher:: ...@@ -707,14 +707,23 @@ void MediaCaptureDevicesDispatcher::
// MediaStreamDevicesController::Accept(). Move this code into a shared method // MediaStreamDevicesController::Accept(). Move this code into a shared method
// between the two classes. // between the two classes.
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
bool audio_allowed = bool audio_allowed =
request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE && request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE &&
extension->permissions_data()->HasAPIPermission( extension->permissions_data()->HasAPIPermission(
extensions::APIPermission::kAudioCapture); extensions::APIPermission::kAudioCapture) &&
GetDevicePolicy(profile, extension->url(),
prefs::kAudioCaptureAllowed,
prefs::kAudioCaptureAllowedUrls) != ALWAYS_DENY;
bool video_allowed = bool video_allowed =
request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE && request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE &&
extension->permissions_data()->HasAPIPermission( extension->permissions_data()->HasAPIPermission(
extensions::APIPermission::kVideoCapture); extensions::APIPermission::kVideoCapture) &&
GetDevicePolicy(profile, extension->url(),
prefs::kVideoCaptureAllowed,
prefs::kVideoCaptureAllowedUrls) != ALWAYS_DENY;
bool get_default_audio_device = audio_allowed; bool get_default_audio_device = audio_allowed;
bool get_default_video_device = video_allowed; bool get_default_video_device = video_allowed;
...@@ -756,8 +765,6 @@ void MediaCaptureDevicesDispatcher:: ...@@ -756,8 +765,6 @@ void MediaCaptureDevicesDispatcher::
// 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 (get_default_audio_device || get_default_video_device) { if (get_default_audio_device || get_default_video_device) {
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
GetDefaultDevicesForProfile(profile, GetDefaultDevicesForProfile(profile,
get_default_audio_device, get_default_audio_device,
get_default_video_device, get_default_video_device,
......
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