Skip to content

Add CefPermissionHandler binding (GH #34) - #53

Merged
Thrameos merged 1 commit into
masterfrom
backport/cef-permission-handler
Sep 6, 2026
Merged

Thrameos merged 1 commit into
masterfrom
backport/cef-permission-handler

Conversation

@Thrameos

@Thrameos Thrameos commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Previously there was no way for a JCEF app to grant/deny camera, mic, or geolocation requests at all -- Alloy style silently denies everything. Adds CefPermissionHandler (onRequestMediaAccessPermission, onShowPermissionPrompt, onDismissPermissionPrompt), wired into client_handler.cpp/CefClient the same way as every other handler.
  • Adds CefMediaAccessCallback and CefPermissionPromptCallback (new _N callback classes, following the existing CefJSDialogCallback_N pattern). Permission result/media-permission-type bit flags are passed as raw ints with a nested constants class (CefContextMenuParams.TypeFlags' existing convention), matching cef_media_access_permission_types_t/cef_permission_request_result_t's declaration order exactly.
  • Backport of coverage/phase1-value-objects-phase2-handlers's 17ba666 -- the CefPermissionHandler half; CefFrameHandler from the same source commit landed separately in PR Add CefFrameHandler binding (GH #33) #52 for cheaper review.
  • JCEF_TRACE calls dropped (not on master).
  • Not covered by an automated end-to-end test: getUserMedia() requires a secure context and this suite's test URLs are http://test.com, so the request would be rejected by Blink before ever reaching CEF's permission layer (same limitation the source commit's own message documents). Extended CefClientTest's existing addAndRemoveEveryHandlerType() wiring smoke test instead -- the cheapest coverage that actually exercises this change (add/remove round-trip through the real native ref).
  • New _N JNI classes registered in tools/make_all_jni_headers.{sh,bat} per this repo's convention for regenerating hand-edited JNI headers.

Test plan

  • Full clean rebuild (fresh cmake reconfigure to pick up the new native sources, + ninja -C jcef_build jcef under -Werror, + tools/compile.sh linux64)
  • Extended CefClientTest.addAndRemoveEveryHandlerType() to add/remove a CefPermissionHandlerAdapter
  • Full local suite: 123/123 tests passing, including the updated test
  • Post-suite Aborted (core dumped) after the JUnit summary is the already-tracked, pre-existing GH Release build: SIGSEGV in libc.so.6 during JVM shutdown after all tests pass #10 shutdown SIGSEGV, unrelated to this change
  • CI (build/test/coverage jobs)

🤖 Generated with Claude Code

https://claude.ai/code/session_01HBFmQs6JDypYP5qdC99yDq

@Thrameos Thrameos added the enhancement New feature or request label Sep 6, 2026
@Override
protected void finalize() throws Throwable {
Cancel();
super.finalize();
@Override
protected void finalize() throws Throwable {
Continue(CefPermissionHandler.PermissionRequestResult.IGNORE);
super.finalize();
@codecov

codecov Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 9.72222% with 130 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.48%. Comparing base (e0afbde) to head (d259ed7).

Files with missing lines Patch % Lines
native/permission_handler.cpp 0.00% 56 Missing ⚠️
native/CefMediaAccessCallback_N.cpp 0.00% 19 Missing ⚠️
...ava/org/cef/callback/CefMediaAccessCallback_N.java 0.00% 14 Missing ⚠️
native/CefPermissionPromptCallback_N.cpp 0.00% 12 Missing ⚠️
java/org/cef/CefClient.java 31.25% 10 Missing and 1 partial ⚠️
...rg/cef/callback/CefPermissionPromptCallback_N.java 0.00% 9 Missing ⚠️
...a/org/cef/handler/CefPermissionHandlerAdapter.java 25.00% 3 Missing ⚠️
java/org/cef/handler/CefClientHandler.java 60.00% 2 Missing ⚠️
java/org/cef/handler/CefPermissionHandler.java 0.00% 2 Missing ⚠️
native/client_handler.cpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #53      +/-   ##
============================================
- Coverage     40.68%   40.48%   -0.20%     
- Complexity      823      826       +3     
============================================
  Files           256      263       +7     
  Lines         15349    15493     +144     
  Branches       2506     2520      +14     
============================================
+ Hits           6244     6273      +29     
- Misses         7831     7943     +112     
- Partials       1274     1277       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Previously there was no way for a JCEF app to grant/deny camera, mic, or
geolocation requests at all -- Alloy style silently denies everything.
Adds CefPermissionHandler (onRequestMediaAccessPermission,
onShowPermissionPrompt, onDismissPermissionPrompt), wired into
client_handler.cpp/CefClient the same way as every other handler.

Adds CefMediaAccessCallback and CefPermissionPromptCallback (new _N
callback classes, following the existing CefJSDialogCallback_N pattern).
Permission result/media-permission-type bit flags are passed as raw ints
with a nested constants class (CefContextMenuParams.TypeFlags' existing
convention), matching cef_media_access_permission_types_t/
cef_permission_request_result_t's declaration order exactly.

Backport of coverage/phase1-value-objects-phase2-handlers's 17ba666 (the
CefPermissionHandler half; CefFrameHandler landed separately in PR #52).
JCEF_TRACE calls dropped (not on master).

Not covered by an automated end-to-end test: getUserMedia() requires a
secure context and this suite's test URLs are http://test.com, so the
request would be rejected by Blink before ever reaching CEF's permission
layer. Extended CefClientTest's existing addAndRemoveEveryHandlerType()
wiring smoke test instead, the cheapest coverage that actually exercises
this change (add/remove round-trip through the real native ref).

New _N JNI classes registered in tools/make_all_jni_headers.{sh,bat} per
this repo's convention for regenerating hand-edited JNI headers.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HBFmQs6JDypYP5qdC99yDq
@Thrameos
Thrameos force-pushed the backport/cef-permission-handler branch from 9b41218 to d259ed7 Compare September 6, 2026 03:29
@Thrameos
Thrameos merged commit f7dacd9 into master Sep 6, 2026
11 of 13 checks passed
@Thrameos
Thrameos deleted the backport/cef-permission-handler branch September 6, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants