detached ef83d2a

fix(cef): extract permission type conversion to satisfy funlen

commit
ef83d2ae38abd2d9244e9b3a656e046f820feaff
author
brice · · 2026-10-03 06:22 UTC
committer
brice · · 2026-10-03 07:50 UTC
parent
664e13e
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +30 -25
M internal/ui/coordinator/content/callbacks.go +29 -22
@@ -203,28 +203,7 @@ func (c *Coordinator) handlePermissionRequest(
203203 ) bool {
204204 log := logging.FromContext(ctx)
205205
206- // Convert string permission types to entity types
207- entityTypes := make([]entity.PermissionType, 0, len(permTypes))
208- for _, pt := range permTypes {
209- switch pt {
210- case "microphone":
211- entityTypes = append(entityTypes, entity.PermissionTypeMicrophone)
212- case "camera":
213- entityTypes = append(entityTypes, entity.PermissionTypeCamera)
214- case "display":
215- entityTypes = append(entityTypes, entity.PermissionTypeDisplay)
216- case "notification":
217- entityTypes = append(entityTypes, entity.PermissionTypeNotification)
218- case "geolocation":
219- entityTypes = append(entityTypes, entity.PermissionTypeGeolocation)
220- case "device_info":
221- entityTypes = append(entityTypes, entity.PermissionTypeDeviceInfo)
222- case "website_data_access":
223- entityTypes = append(entityTypes, entity.PermissionTypeWebsiteDataAccess)
224- default:
225- log.Warn().Str("type", pt).Msg("unknown permission type, skipping")
226- }
227- }
206+ entityTypes := permissionTypesFromStrings(ctx, permTypes)
228207
229208 if len(entityTypes) == 0 {
230209 log.Warn().Str("origin", origin).Msg("permission request with no valid types, denying")
@@ -285,6 +264,34 @@ func (c *Coordinator) handlePermissionRequest(
285264 return true
286265 }
287266
267+// permissionTypesFromStrings converts engine permission type strings to entity
268+// types, skipping unknown ones.
269+func permissionTypesFromStrings(ctx context.Context, permTypes []string) []entity.PermissionType {
270+ log := logging.FromContext(ctx)
271+ entityTypes := make([]entity.PermissionType, 0, len(permTypes))
272+ for _, pt := range permTypes {
273+ switch pt {
274+ case "microphone":
275+ entityTypes = append(entityTypes, entity.PermissionTypeMicrophone)
276+ case "camera":
277+ entityTypes = append(entityTypes, entity.PermissionTypeCamera)
278+ case "display":
279+ entityTypes = append(entityTypes, entity.PermissionTypeDisplay)
280+ case "notification":
281+ entityTypes = append(entityTypes, entity.PermissionTypeNotification)
282+ case "geolocation":
283+ entityTypes = append(entityTypes, entity.PermissionTypeGeolocation)
284+ case "device_info":
285+ entityTypes = append(entityTypes, entity.PermissionTypeDeviceInfo)
286+ case "website_data_access":
287+ entityTypes = append(entityTypes, entity.PermissionTypeWebsiteDataAccess)
288+ default:
289+ log.Warn().Str("type", pt).Msg("unknown permission type, skipping")
290+ }
291+ }
292+ return entityTypes
293+}
294+
288295 func filterWebRTCPermissionTypes(types []entity.PermissionType) []entity.PermissionType {
289296 filtered := make([]entity.PermissionType, 0, len(types))
290297 for _, permType := range types {
@@ -203,28 +203,7 @@ func (c *Coordinator) handlePermissionRequest(
203 ) bool {203 ) bool {
204 log := logging.FromContext(ctx)204 log := logging.FromContext(ctx)
205 205
206- // Convert string permission types to entity types206+ entityTypes := permissionTypesFromStrings(ctx, permTypes)
207- entityTypes := make([]entity.PermissionType, 0, len(permTypes))
208- for _, pt := range permTypes {
209- switch pt {
210- case "microphone":
211- entityTypes = append(entityTypes, entity.PermissionTypeMicrophone)
212- case "camera":
213- entityTypes = append(entityTypes, entity.PermissionTypeCamera)
214- case "display":
215- entityTypes = append(entityTypes, entity.PermissionTypeDisplay)
216- case "notification":
217- entityTypes = append(entityTypes, entity.PermissionTypeNotification)
218- case "geolocation":
219- entityTypes = append(entityTypes, entity.PermissionTypeGeolocation)
220- case "device_info":
221- entityTypes = append(entityTypes, entity.PermissionTypeDeviceInfo)
222- case "website_data_access":
223- entityTypes = append(entityTypes, entity.PermissionTypeWebsiteDataAccess)
224- default:
225- log.Warn().Str("type", pt).Msg("unknown permission type, skipping")
226- }
227- }
228 207
229 if len(entityTypes) == 0 {208 if len(entityTypes) == 0 {
230 log.Warn().Str("origin", origin).Msg("permission request with no valid types, denying")209 log.Warn().Str("origin", origin).Msg("permission request with no valid types, denying")
@@ -285,6 +264,34 @@ func (c *Coordinator) handlePermissionRequest(
285 return true264 return true
286 }265 }
287 266
267+// permissionTypesFromStrings converts engine permission type strings to entity
268+// types, skipping unknown ones.
269+func permissionTypesFromStrings(ctx context.Context, permTypes []string) []entity.PermissionType {
270+ log := logging.FromContext(ctx)
271+ entityTypes := make([]entity.PermissionType, 0, len(permTypes))
272+ for _, pt := range permTypes {
273+ switch pt {
274+ case "microphone":
275+ entityTypes = append(entityTypes, entity.PermissionTypeMicrophone)
276+ case "camera":
277+ entityTypes = append(entityTypes, entity.PermissionTypeCamera)
278+ case "display":
279+ entityTypes = append(entityTypes, entity.PermissionTypeDisplay)
280+ case "notification":
281+ entityTypes = append(entityTypes, entity.PermissionTypeNotification)
282+ case "geolocation":
283+ entityTypes = append(entityTypes, entity.PermissionTypeGeolocation)
284+ case "device_info":
285+ entityTypes = append(entityTypes, entity.PermissionTypeDeviceInfo)
286+ case "website_data_access":
287+ entityTypes = append(entityTypes, entity.PermissionTypeWebsiteDataAccess)
288+ default:
289+ log.Warn().Str("type", pt).Msg("unknown permission type, skipping")
290+ }
291+ }
292+ return entityTypes
293+}
294+
288 func filterWebRTCPermissionTypes(types []entity.PermissionType) []entity.PermissionType {295 func filterWebRTCPermissionTypes(types []entity.PermissionType) []entity.PermissionType {
289 filtered := make([]entity.PermissionType, 0, len(types))296 filtered := make([]entity.PermissionType, 0, len(types))
290 for _, permType := range types {297 for _, permType := range types {
M internal/ui/coordinator/content/permission_prompt_test.go +1 -3
@@ -19,9 +19,7 @@ func TestHandlePermissionRequest_BindsDialogBeforeUseCaseForNonWebRTCRequest(t *
1919 permRepo := portmocks.NewMockPermissionRepository(t)
2020 dialog := portmocks.NewMockPermissionDialogPresenter(t)
2121 // The use case starts without a dialog presenter, like in production.
22- uc := usecase.NewHandlePermissionUseCase(permRepo, nil, func(ctx context.Context) *zerolog.Logger {
23- return zerolog.Ctx(ctx)
24- })
22+ uc := usecase.NewHandlePermissionUseCase(permRepo, nil, zerolog.Ctx)
2523
2624 permRepo.EXPECT().Get(mock.Anything, "https://maps.example.com", entity.PermissionTypeGeolocation).
2725 Return(nil, nil)
@@ -19,9 +19,7 @@ func TestHandlePermissionRequest_BindsDialogBeforeUseCaseForNonWebRTCRequest(t *
19 permRepo := portmocks.NewMockPermissionRepository(t)19 permRepo := portmocks.NewMockPermissionRepository(t)
20 dialog := portmocks.NewMockPermissionDialogPresenter(t)20 dialog := portmocks.NewMockPermissionDialogPresenter(t)
21 // The use case starts without a dialog presenter, like in production.21 // The use case starts without a dialog presenter, like in production.
22- uc := usecase.NewHandlePermissionUseCase(permRepo, nil, func(ctx context.Context) *zerolog.Logger {22+ uc := usecase.NewHandlePermissionUseCase(permRepo, nil, zerolog.Ctx)
23- return zerolog.Ctx(ctx)
24- })
25 23
26 permRepo.EXPECT().Get(mock.Anything, "https://maps.example.com", entity.PermissionTypeGeolocation).24 permRepo.EXPECT().Get(mock.Anything, "https://maps.example.com", entity.PermissionTypeGeolocation).
27 Return(nil, nil)25 Return(nil, nil)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close