diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java index a19a081..fa22288 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java +++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java @@ -371,6 +371,11 @@ public class RNCWebViewManager extends SimpleViewManager { view.getSettings().setMediaPlaybackRequiresUserGesture(requires); } + @ReactProp(name = "allowFileAccessFromFileURLs") + public void setAllowFileAccessFromFileURLs(WebView view, boolean allow) { + view.getSettings().setAllowFileAccessFromFileURLs(allow); + } + @ReactProp(name = "allowUniversalAccessFromFileURLs") public void setAllowUniversalAccessFromFileURLs(WebView view, boolean allow) { view.getSettings().setAllowUniversalAccessFromFileURLs(allow); diff --git a/docs/Reference.md b/docs/Reference.md index f4aa756..3ac4d0b 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -44,6 +44,7 @@ This document lays out the current public properties and methods for the React N - [`scrollEnabled`](Reference.md#scrollenabled) - [`directionalLockEnabled`](Reference.md#directionalLockEnabled) - [`geolocationEnabled`](Reference.md#geolocationenabled) +- [`allowFileAccessFromFileURLs`](Reference.md#allowFileAccessFromFileURLs) - [`allowUniversalAccessFromFileURLs`](Reference.md#allowUniversalAccessFromFileURLs) - [`allowingReadAccessToURL`](Reference.md#allowingReadAccessToURL) - [`url`](Reference.md#url) @@ -876,6 +877,16 @@ Set whether Geolocation is enabled in the `WebView`. The default value is `false --- +### `allowFileAccessFromFileURLs` + + Boolean that sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs. The default value is `false`. + +| Type | Required | Platform | +| ---- | -------- | -------- | +| bool | No | Android | + +--- + ### `allowUniversalAccessFromFileURLs` Boolean that sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from any origin. Including accessing content from other file scheme URLs. The default value is `false`. diff --git a/src/WebViewTypes.ts b/src/WebViewTypes.ts index 7027069..8face51 100644 --- a/src/WebViewTypes.ts +++ b/src/WebViewTypes.ts @@ -242,6 +242,7 @@ export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps { cacheMode?: CacheMode; allowFileAccess?: boolean; scalesPageToFit?: boolean; + allowFileAccessFromFileURLs?: boolean; allowUniversalAccessFromFileURLs?: boolean; androidHardwareAccelerationDisabled?: boolean; domStorageEnabled?: boolean; @@ -500,6 +501,15 @@ export interface AndroidWebViewProps extends WebViewSharedProps { */ geolocationEnabled?: boolean; + + /** + * Boolean that sets whether JavaScript running in the context of a file + * scheme URL should be allowed to access content from other file scheme URLs. + * Including accessing content from other file scheme URLs + * @platform android + */ + allowFileAccessFromFileURLs?: boolean; + /** * Boolean that sets whether JavaScript running in the context of a file * scheme URL should be allowed to access content from any origin.