diff --git a/android/src/main/java/ee/forgr/capacitor_inappbrowser/CapgoInAppBrowserPlugin.java b/android/src/main/java/ee/forgr/capacitor_inappbrowser/CapgoInAppBrowserPlugin.java index 7a18211b149af0c74aab9e7f7c2ec5abf0a83a39..7bcab0549d4c15fcf8da0bd27ec4a549c1a91f74 100644 --- a/android/src/main/java/ee/forgr/capacitor_inappbrowser/CapgoInAppBrowserPlugin.java +++ b/android/src/main/java/ee/forgr/capacitor_inappbrowser/CapgoInAppBrowserPlugin.java @@ -66,6 +66,9 @@ import org.json.JSONObject; ) public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.PermissionHandler { + /** EO Nexus patch: viewed pages never get camera or microphone capture. */ + private static final boolean DENY_WEB_CAPTURE = true; + private static final ExecutorService PROXY_RESPONSE_EXECUTOR = Executors.newFixedThreadPool( Math.max(4, Runtime.getRuntime().availableProcessors()), (runnable) -> { @@ -573,7 +576,9 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per return; } - if (!needsCamera && !needsMicrophone) { + // EO Nexus patch (MPL-2.0): a page shown in the viewer never gets the camera or the + // microphone. Every capture request is denied instead of being granted or asked for. + if (DENY_WEB_CAPTURE || (!needsCamera && !needsMicrophone)) { request.deny(); return; } diff --git a/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java b/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java index d2a5efc6e50ddac3b3d700d2b69c372d3714b325..93fa324e2cab883b7cf5a7d1727885de2cd16cea 100644 --- a/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +++ b/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java @@ -3070,9 +3070,8 @@ public class WebViewDialog extends ComponentDialog implements ProxyResponseRouti @Override public void onGeolocationPermissionsShowPrompt(String origin, android.webkit.GeolocationPermissions.Callback callback) { Log.i("INAPPBROWSER", "onGeolocationPermissionsShowPrompt for origin: " + origin); - // Grant geolocation permission automatically for openWebView - // This allows websites to access location when opened with openWebView - callback.invoke(origin, true, false); + // EO Nexus patch (MPL-2.0): a page shown in the viewer never gets the location. + callback.invoke(origin, false, false); } // This method will be called at page load, a good place to inject customizations diff --git a/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift b/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift index 0b963202522dcb341db3a957b0a9606152ce459d..a214b2d4b90ea3c85f03a37eb66b19316f12c1dc 100644 --- a/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift +++ b/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift @@ -3599,22 +3599,17 @@ extension WKWebViewController: WKUIDelegate { public func webView(_ webView: WKWebView, requestGeolocationPermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, decisionHandler: @escaping (WKPermissionDecision) -> Void) { print("[InAppBrowser] Geolocation permission requested for origin: \(origin.host)") - // Grant geolocation permission automatically for openWebView - // This allows websites to access location when opened with openWebView - decisionHandler(.grant) + // EO Nexus patch (MPL-2.0): a page shown in the viewer never gets the location. + decisionHandler(.deny) } @available(iOS 15.0, *) public func webView(_ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void) { print("[InAppBrowser] Media capture permission requested for origin: \(origin.host)") - // Grant media capture permission automatically, matching Capacitor core's - // WebViewDelegationHandler. The OS-level camera/microphone permission - // (Info.plist usage description + system prompt) still applies — this only - // suppresses WebKit's extra per-origin prompt, which is not persisted - // across app launches (WebKit bug 220416) and would otherwise re-prompt - // users on every cold start. - decisionHandler(.grant) + // EO Nexus patch (MPL-2.0): a page shown in the viewer never gets the camera or the + // microphone, even after the app itself was given the camera for its QR scanner. + decisionHandler(.deny) } }