mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-24 02:51:17 -08:00
fix(cef): don't default deny location permission on cef (#1546)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Location permissions were default denied. Make sable prompt for location permissions on CEF. Fixes # #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
This commit is contained in:
1 file changed
+10
-8
+10
-8
@@ -21,7 +21,6 @@ fn prompt_cef_permission(message: String, tx: std::sync::mpsc::Sender<bool>) {
|
||||
dialog.set_title("Permission request");
|
||||
|
||||
let tx = std::cell::RefCell::new(Some(tx));
|
||||
let dialog_ptr = dialog.clone();
|
||||
dialog.connect_response(move |dlg, response| {
|
||||
if let Some(tx) = tx.take() {
|
||||
let _ = tx.send(matches!(response, ResponseType::Yes));
|
||||
@@ -100,7 +99,7 @@ fn main() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow call media capture (mic, camera, screen-share) for our webview.
|
||||
// Allow call media capture (mic, camera, screen-share) and geolocation for our webview.
|
||||
// Cache granted permissions so we only prompt once per kind.
|
||||
use std::collections::HashSet;
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
@@ -114,7 +113,7 @@ fn main() {
|
||||
return responder.deny(DenyReason::NoPolicy);
|
||||
}
|
||||
|
||||
let media_kinds: Vec<PermissionKind> = request
|
||||
let permission_kinds: Vec<PermissionKind> = request
|
||||
.kinds
|
||||
.iter()
|
||||
.filter(|kind| {
|
||||
@@ -125,17 +124,18 @@ fn main() {
|
||||
| PermissionKind::CameraPanTiltZoom
|
||||
| PermissionKind::ScreenCapture
|
||||
| PermissionKind::CapturedSurfaceControl
|
||||
| PermissionKind::Geolocation
|
||||
)
|
||||
})
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
if media_kinds.is_empty() {
|
||||
if permission_kinds.is_empty() {
|
||||
return responder.deny(DenyReason::NoPolicy);
|
||||
}
|
||||
|
||||
// Check cache: if all requested kinds were already granted, allow immediately.
|
||||
let kind_names: Vec<&'static str> = media_kinds
|
||||
let kind_names: Vec<&'static str> = permission_kinds
|
||||
.iter()
|
||||
.map(|k| match k {
|
||||
PermissionKind::Microphone => "mic",
|
||||
@@ -143,6 +143,7 @@ fn main() {
|
||||
PermissionKind::ScreenCapture | PermissionKind::CapturedSurfaceControl => {
|
||||
"screen"
|
||||
}
|
||||
PermissionKind::Geolocation => "geolocation",
|
||||
_ => "other",
|
||||
})
|
||||
.collect();
|
||||
@@ -154,14 +155,15 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
let msg = match media_kinds.as_slice() {
|
||||
let msg = match permission_kinds.as_slice() {
|
||||
[PermissionKind::Microphone] => "Sable wants to access your microphone.",
|
||||
[PermissionKind::Camera] => "Sable wants to access your camera.",
|
||||
[PermissionKind::ScreenCapture] | [PermissionKind::CapturedSurfaceControl] => {
|
||||
"Sable wants to share your screen."
|
||||
}
|
||||
_ if media_kinds.contains(&PermissionKind::Microphone)
|
||||
&& media_kinds.contains(&PermissionKind::Camera) =>
|
||||
[PermissionKind::Geolocation] => "Sable wants to access your location.",
|
||||
_ if permission_kinds.contains(&PermissionKind::Microphone)
|
||||
&& permission_kinds.contains(&PermissionKind::Camera) =>
|
||||
{
|
||||
"Sable wants to access your microphone and camera."
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user