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

Unified Diff: chrome/browser/media/media_capture_devices_dispatcher.cc

Issue 562263002: Check media permissions through RenderFrameHostDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render_frame_get_sources
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/media_capture_devices_dispatcher.cc
diff --git a/chrome/browser/media/media_capture_devices_dispatcher.cc b/chrome/browser/media/media_capture_devices_dispatcher.cc
index a3a1ddcf23d30ab14882fad7b5f4cd158dd6d2a9..ed05b5ff608efc02b28b52acda481457011afd05 100644
--- a/chrome/browser/media/media_capture_devices_dispatcher.cc
+++ b/chrome/browser/media/media_capture_devices_dispatcher.cc
@@ -403,6 +403,69 @@ bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission(
return false;
}
+bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission(
+ content::WebContents* web_contents,
+ const GURL& security_origin,
+ content::MediaStreamType type) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
+ type == content::MEDIA_DEVICE_VIDEO_CAPTURE);
+
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+
+ if (CheckAllowAllMediaStreamContentForOrigin(profile, security_origin))
+ return true;
+
+ const char* policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE
+ ? prefs::kAudioCaptureAllowed
+ : prefs::kVideoCaptureAllowed;
+ const char* list_policy_name = type == content::MEDIA_DEVICE_AUDIO_CAPTURE
+ ? prefs::kAudioCaptureAllowedUrls
+ : prefs::kVideoCaptureAllowedUrls;
+ if (GetDevicePolicy(
+ profile, security_origin, policy_name, list_policy_name) ==
+ ALWAYS_ALLOW) {
+ return true;
+ }
+
+ // There's no secondary URL for these content types, hence duplicating
+ // |security_origin|.
+ if (profile->GetHostContentSettingsMap()->GetContentSetting(
+ security_origin,
+ security_origin,
+ type == content::MEDIA_DEVICE_AUDIO_CAPTURE
+ ? CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
+ : CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
+ NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) {
+ return true;
+ }
+
+ return false;
+}
+
+#if defined(ENABLE_EXTENSIONS)
+bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission(
+ content::WebContents* web_contents,
+ const GURL& security_origin,
+ content::MediaStreamType type,
+ const extensions::Extension* extension) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
+ type == content::MEDIA_DEVICE_VIDEO_CAPTURE);
+
+ if (extension->is_platform_app() ||
+ IsMediaRequestWhitelistedForExtension(extension)) {
+ return extension->permissions_data()->HasAPIPermission(
+ type == content::MEDIA_DEVICE_AUDIO_CAPTURE
+ ? extensions::APIPermission::kAudioCapture
+ : extensions::APIPermission::kVideoCapture);
+ }
+
+ return CheckMediaAccessPermission(web_contents, security_origin, type);
+}
+#endif
+
void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
« no previous file with comments | « chrome/browser/media/media_capture_devices_dispatcher.h ('k') | chrome/browser/ui/app_list/start_page_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698