Handle WebView media-capture permission requests#199
Merged
Conversation
Adds WebViewPermissionDelegate alongside the existing GeolocationPermissionDelegate. It plugs into WebChromeClient.onPermissionRequest and supports both RESOURCE_AUDIO_CAPTURE (RECORD_AUDIO + MODIFY_AUDIO_SETTINGS) and RESOURCE_VIDEO_CAPTURE (CAMERA), runtime-requesting only the dangerous permissions and denying the whole request when any required manifest entry is missing. VisitDestination and HotwireDestination get a new activityMultiplePermissionsResultLauncher hook so a single result launcher can return Map<String, Boolean> for combined audio + video requests; both HotwireWebFragment and HotwireWebBottomSheetFragment route the new HOTWIRE_REQUEST_CODE_WEBVIEW_PERMISSION code to the launcher registered in HotwireWebFragmentDelegate via RequestMultiplePermissions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
A second WebView PermissionRequest could previously orphan the first by overwriting pendingRequest without giving the WebView a verdict, and a canceled request could still be granted/denied later when the runtime permission result arrived. WebViewPermissionDelegate now denies any held request before storing a new one and exposes onCancel to clear matching pending state. HotwireWebChromeClient forwards onPermissionRequestCanceled to the delegate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Very nice feature! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for WebView-issued
PermissionRequests for camera and microphone, so pages can usegetUserMedia({ audio, video })without the host app having to wire upWebChromeClient.onPermissionRequestitself.Key Changes
WebViewPermissionDelegate— New delegate alongside the existingGeolocationPermissionDelegate. HandlesRESOURCE_AUDIO_CAPTURE(requiresRECORD_AUDIO+MODIFY_AUDIO_SETTINGS) andRESOURCE_VIDEO_CAPTURE(requiresCAMERA). Only the runtime-level permissions are requested;MODIFY_AUDIO_SETTINGSis install-time but must still be declared, otherwise Chromium's audio pipeline fails withUnable to select communication device!even afterRECORD_AUDIOis granted. If a required manifest entry is missing the whole request is denied (and a warning logged) so the page seesNotAllowedError.activityMultiplePermissionsResultLauncher— New hook onVisitDestination/HotwireDestination, mirroring the existing single-permission hook.HotwireWebFragmentDelegateregisters aRequestMultiplePermissionslauncher forHOTWIRE_REQUEST_CODE_WEBVIEW_PERMISSIONso a combined audio + video request can be resolved in one prompt.Cancellation safety —
HotwireWebChromeClientforwardsonPermissionRequestCanceledto the delegate, which clears any matching pending state. The delegate also denies a previously-held request before storing a new one, so the WebView always gets a verdict instead of an orphaned request being silently dropped.Host app requirements
Client apps that want to enable media capture must declare the relevant permissions in their
AndroidManifest.xml: