Skip to content

Add in-dialog camera permission request option to payment handler - #12

Merged
stephenmcgruer merged 2 commits into
GoogleChromeLabs:mainfrom
luis-antunes:dialog-camera-access
Aug 11, 2026
Merged

Add in-dialog camera permission request option to payment handler#12
stephenmcgruer merged 2 commits into
GoogleChromeLabs:mainfrom
luis-antunes:dialog-camera-access

Conversation

@luis-antunes

@luis-antunes luis-antunes commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Adds a "Grant Camera Access inside this Dialog" option to camera_test.html to test native in-dialog permission prompts, with feature flag gating when unsupported.

Changes

  • In-dialog permission request: Invokes getUserMedia() directly inside the payment handler dialog, releases tracks immediately upon granting, and updates permission UI.
  • Feature flag gating: When kPaymentHandlerCameraAccess is disabled, getUserMedia() rejects with NotSupportedError. The page catches this, hides the camera grant options, and notifies the user that the feature flag is disabled.

Currently, the camera test page (camera_test.html) provides two options
when camera access is tested:
1. "Start Camera": invokes getUserMedia and renders video to a <video> element.
2. "Grant Camera Access in Popup Window": opens a separate popup window
   to trigger the permission prompt externally (previously required when
   payment handler dialogs did not support native permission prompts).

To test native permission handling directly inside the payment handler
dialog, this change adds a "Grant Camera Access inside this Dialog" link.

When clicked, it calls navigator.mediaDevices.getUserMedia() directly
within the dialog, stops all tracks immediately upon granting, and
updates the permission status UI. The link is visible when camera
permission is in 'prompt' or 'denied' state, matching the popup link.
When the kPaymentHandlerCameraAccess or kPaymentHandlerCameraAccessUx
feature flag is disabled in Chromium,
WebContentsDelegate does not handle camera access requests for payment
handler dialogs, and getUserMedia() rejects with NotSupportedError.

This CL handles NotSupportedError in camera_test.html by:
1. Dynamically marking camera access as unsupported.
2. Hiding the "Grant Camera Access" links to avoid
   confusing partners when the feature flag is disabled.
@stephenmcgruer
stephenmcgruer merged commit 729b5d1 into GoogleChromeLabs:main Aug 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants