Skip to content

Commit bdb4a9d

Browse files
authored
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. -->
2 parents c160f50 + f5cc97d commit bdb4a9d

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src-tauri/src/main.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ fn prompt_cef_permission(message: String, tx: std::sync::mpsc::Sender<bool>) {
2121
dialog.set_title("Permission request");
2222

2323
let tx = std::cell::RefCell::new(Some(tx));
24-
let dialog_ptr = dialog.clone();
2524
dialog.connect_response(move |dlg, response| {
2625
if let Some(tx) = tx.take() {
2726
let _ = tx.send(matches!(response, ResponseType::Yes));
@@ -100,7 +99,7 @@ fn main() {
10099
return;
101100
}
102101

103-
// Allow call media capture (mic, camera, screen-share) for our webview.
102+
// Allow call media capture (mic, camera, screen-share) and geolocation for our webview.
104103
// Cache granted permissions so we only prompt once per kind.
105104
use std::collections::HashSet;
106105
use std::sync::{Mutex, OnceLock};
@@ -114,7 +113,7 @@ fn main() {
114113
return responder.deny(DenyReason::NoPolicy);
115114
}
116115

117-
let media_kinds: Vec<PermissionKind> = request
116+
let permission_kinds: Vec<PermissionKind> = request
118117
.kinds
119118
.iter()
120119
.filter(|kind| {
@@ -125,24 +124,26 @@ fn main() {
125124
| PermissionKind::CameraPanTiltZoom
126125
| PermissionKind::ScreenCapture
127126
| PermissionKind::CapturedSurfaceControl
127+
| PermissionKind::Geolocation
128128
)
129129
})
130130
.cloned()
131131
.collect();
132132

133-
if media_kinds.is_empty() {
133+
if permission_kinds.is_empty() {
134134
return responder.deny(DenyReason::NoPolicy);
135135
}
136136

137137
// Check cache: if all requested kinds were already granted, allow immediately.
138-
let kind_names: Vec<&'static str> = media_kinds
138+
let kind_names: Vec<&'static str> = permission_kinds
139139
.iter()
140140
.map(|k| match k {
141141
PermissionKind::Microphone => "mic",
142142
PermissionKind::Camera | PermissionKind::CameraPanTiltZoom => "cam",
143143
PermissionKind::ScreenCapture | PermissionKind::CapturedSurfaceControl => {
144144
"screen"
145145
}
146+
PermissionKind::Geolocation => "geolocation",
146147
_ => "other",
147148
})
148149
.collect();
@@ -154,14 +155,15 @@ fn main() {
154155
}
155156
}
156157

157-
let msg = match media_kinds.as_slice() {
158+
let msg = match permission_kinds.as_slice() {
158159
[PermissionKind::Microphone] => "Sable wants to access your microphone.",
159160
[PermissionKind::Camera] => "Sable wants to access your camera.",
160161
[PermissionKind::ScreenCapture] | [PermissionKind::CapturedSurfaceControl] => {
161162
"Sable wants to share your screen."
162163
}
163-
_ if media_kinds.contains(&PermissionKind::Microphone)
164-
&& media_kinds.contains(&PermissionKind::Camera) =>
164+
[PermissionKind::Geolocation] => "Sable wants to access your location.",
165+
_ if permission_kinds.contains(&PermissionKind::Microphone)
166+
&& permission_kinds.contains(&PermissionKind::Camera) =>
165167
{
166168
"Sable wants to access your microphone and camera."
167169
}

0 commit comments

Comments
 (0)