From: uazo Date: Thu, 28 Sep 2023 07:56:11 +0000 Subject: Partition MediaDeviceId by default and, in windows, hide the presence of the webcam if the user has not given permission License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html --- .../core/browser/bromite_content_settings/camera.inc | 8 ++++++++ components/media_device_salt/media_device_salt_service.cc | 3 +++ content/browser/media/media_devices_util.cc | 3 +++ .../browser/renderer_host/media/media_devices_manager.cc | 5 +++++ 4 files changed, 19 insertions(+) create mode 100644 components/content_settings/core/browser/bromite_content_settings/camera.inc diff --git a/components/content_settings/core/browser/bromite_content_settings/camera.inc b/components/content_settings/core/browser/bromite_content_settings/camera.inc new file mode 100644 --- /dev/null +++ b/components/content_settings/core/browser/bromite_content_settings/camera.inc @@ -0,0 +1,8 @@ +#if !BUILDFLAG(IS_ANDROID) + + content_settings::WebsiteSettingsRegistry::GetInstance() + ->GetMutable(ContentSettingsType::MEDIASTREAM_CAMERA) + ->set_show_into_info_page() + .set_desktop_ui(); + +#endif diff --git a/components/media_device_salt/media_device_salt_service.cc b/components/media_device_salt/media_device_salt_service.cc --- a/components/media_device_salt/media_device_salt_service.cc +++ b/components/media_device_salt/media_device_salt_service.cc @@ -28,6 +28,9 @@ BASE_FEATURE(kMediaDeviceIdRandomSaltsPerStorageKey, "MediaDeviceIdRandomSaltsPerStorageKey", base::FEATURE_ENABLED_BY_DEFAULT); +SET_CROMITE_FEATURE_ENABLED(kMediaDeviceIdPartitioning); +SET_CROMITE_FEATURE_ENABLED(kMediaDeviceIdRandomSaltsPerStorageKey); + namespace { scoped_refptr CreateDatabaseTaskRunner() { diff --git a/content/browser/media/media_devices_util.cc b/content/browser/media/media_devices_util.cc --- a/content/browser/media/media_devices_util.cc +++ b/content/browser/media/media_devices_util.cc @@ -166,6 +166,9 @@ blink::WebMediaDeviceInfo TranslateMediaDeviceInfo( bool has_permission, const MediaDeviceSaltAndOrigin& salt_and_origin, const blink::WebMediaDeviceInfo& device_info) { + // If device permission is not granted by the user, + // media-device enumeration will provide at most one device per type and the + // device IDs will not be available. if (has_permission) { return blink::WebMediaDeviceInfo( GetHMACForRawMediaDeviceID(salt_and_origin, device_info.device_id), diff --git a/content/browser/renderer_host/media/media_devices_manager.cc b/content/browser/renderer_host/media/media_devices_manager.cc --- a/content/browser/renderer_host/media/media_devices_manager.cc +++ b/content/browser/renderer_host/media/media_devices_manager.cc @@ -837,6 +837,11 @@ void MediaDevicesManager::OnDevicesEnumerated( has_permissions[i], salt_and_origin, device_info)); } } +#if !BUILDFLAG(IS_ANDROID) + int video_input_index = static_cast(MediaDeviceType::kMediaVideoInput); + if (requested_types[video_input_index] && !has_permissions[video_input_index]) + translation[video_input_index].clear(); +#endif GetAudioInputCapabilities(video_input_capabilities_requested, audio_input_capabilities_requested, --