Files
electron/patches/chromium/short-circuit_permissions_checks_in_mediastreamdevicescontroller.patch
electron-roller[bot] 1cc2fce905 chore: bump chromium to 143.0.7477.0 (main) (#48584)
* chore: bump chromium in DEPS to 143.0.7477.0

* 7049117: [CodeCache] Adjust PersistentCache for CodeCache feature

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7049117

* chore: update patches

* chore: add missing includes of ui/gfx/image/image_skia.h

* 7028738: Rename several ipc_* files used by param_traits*

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7028738

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-10-19 21:46:34 +02:00

110 lines
4.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Rose <japthorp@slack-corp.com>
Date: Tue, 12 Jul 2022 16:51:43 -0700
Subject: short-circuit permissions checks in MediaStreamDevicesController
The //components/permissions architecture is complicated and not that
widely used in Chromium, and mostly oriented around showing permissions
UI and/or remembering per-site permissions, which we're not interested
in.
Since we do a permissions check prior to invoking the
MediaStreamDevicesController, and don't (yet) provide the ability to set
granular permissions (e.g. allow video but not audio), just
short-circuit all the permissions checks in MSDC for now to allow us to
unduplicate this code.
diff --git a/components/webrtc/media_stream_devices_controller.cc b/components/webrtc/media_stream_devices_controller.cc
index 0e528c5356f333f1397e569d0403c6c121f1b175..3c1ca4e67547118ebf2ec1ddf3847c741f2d00f3 100644
--- a/components/webrtc/media_stream_devices_controller.cc
+++ b/components/webrtc/media_stream_devices_controller.cc
@@ -57,7 +57,8 @@ bool PermissionIsRequested(blink::PermissionType permission,
void MediaStreamDevicesController::RequestPermissions(
const content::MediaStreamRequest& request,
MediaStreamDeviceEnumerator* enumerator,
- ResultCallback callback) {
+ ResultCallback callback,
+ bool previously_approved) {
content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
request.render_process_id, request.render_frame_id);
// The RFH may have been destroyed by the time the request is processed.
@@ -92,7 +93,7 @@ void MediaStreamDevicesController::RequestPermissions(
std::move(callback)));
std::vector<blink::mojom::PermissionDescriptorPtr> permission_types;
-
+#if 0
content::PermissionController* permission_controller =
web_contents->GetBrowserContext()->GetPermissionController();
@@ -174,19 +175,31 @@ void MediaStreamDevicesController::RequestPermissions(
requested_audio_capture_device_ids;
permission_request_description.requested_video_capture_device_ids =
requested_video_capture_device_ids;
-
+#endif
// It is OK to ignore `request.security_origin` because it will be calculated
// from `render_frame_host` and we always ignore `requesting_origin` for
// `AUDIO_CAPTURE` and `VIDEO_CAPTURE`.
// `render_frame_host->GetMainFrame()->GetLastCommittedOrigin()` will be used
// instead.
- rfh->GetBrowserContext()
- ->GetPermissionController()
- ->RequestPermissionsFromCurrentDocument(
- rfh, permission_request_description,
- base::BindOnce(
- &MediaStreamDevicesController::PromptAnsweredGroupedRequest,
- std::move(controller)));
+ if (previously_approved) {
+ controller->PromptAnsweredGroupedRequest(
+ {content::PermissionResult(
+ content::PermissionStatus::GRANTED /*audio*/,
+ content::PermissionStatusSource::UNSPECIFIED),
+ content::PermissionResult(
+ content::PermissionStatus::GRANTED /*video*/,
+ content::PermissionStatusSource::UNSPECIFIED)});
+ } else {
+ rfh->GetBrowserContext()
+ ->GetPermissionController()
+ ->RequestPermissionsFromCurrentDocument(
+ rfh,
+ content::PermissionRequestDescription(std::move(permission_types),
+ request.user_gesture),
+ base::BindOnce(
+ &MediaStreamDevicesController::PromptAnsweredGroupedRequest,
+ std::move(controller)));
+ }
}
MediaStreamDevicesController::~MediaStreamDevicesController() {
@@ -436,6 +449,7 @@ bool MediaStreamDevicesController::PermissionIsBlockedForReason(
return false;
}
+#if 0
// TODO(raymes): This function wouldn't be needed if
// PermissionManager::RequestPermissions returned a denial reason.
content::PermissionResult result =
@@ -449,6 +463,7 @@ bool MediaStreamDevicesController::PermissionIsBlockedForReason(
DCHECK_EQ(blink::mojom::PermissionStatus::DENIED, result.status);
return true;
}
+#endif
return false;
}
diff --git a/components/webrtc/media_stream_devices_controller.h b/components/webrtc/media_stream_devices_controller.h
index 5e46e66f51994d3eef3b19ee57b37e6cf32658e8..d01403717a0df2c18b3d88495d9a4f85f242693a 100644
--- a/components/webrtc/media_stream_devices_controller.h
+++ b/components/webrtc/media_stream_devices_controller.h
@@ -50,7 +50,8 @@ class MediaStreamDevicesController {
// synchronously or asynchronously returned via |callback|.
static void RequestPermissions(const content::MediaStreamRequest& request,
MediaStreamDeviceEnumerator* enumerator,
- ResultCallback callback);
+ ResultCallback callback,
+ bool previously_approved = false);
~MediaStreamDevicesController();