From 62b560a546ec92519ee96fe71cc170252422acdf Mon Sep 17 00:00:00 2001 From: Thibault Malbranche Date: Fri, 14 Sep 2018 01:09:39 +0200 Subject: [PATCH 1/3] imported https://github.com/facebook/react-native/commit/0c576ef84a1c7f79b228f205cc687ab1b945bda1 --- .../reactnativecommunity/webview/RCTWebViewManager.java | 7 +++++++ js/WebView.android.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewManager.java b/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewManager.java index 966a88c..251c1b3 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewManager.java +++ b/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewManager.java @@ -574,6 +574,13 @@ public class RCTWebViewManager extends SimpleViewManager { } } + @ReactProp(name = "allowFileAccess") + public void setAllowFileAccess( + WebView view, + @Nullable Boolean allowFileAccess) { + view.getSettings().setAllowFileAccess(allowFileAccess != null && allowFileAccess); + } + @ReactProp(name = "geolocationEnabled") public void setGeolocationEnabled( WebView view, diff --git a/js/WebView.android.js b/js/WebView.android.js index d2c8338..2e38c1b 100644 --- a/js/WebView.android.js +++ b/js/WebView.android.js @@ -67,6 +67,7 @@ class WebView extends React.Component { javaScriptEnabled: true, thirdPartyCookiesEnabled: true, scalesPageToFit: true, + allowFileAccess: false, saveFormDataDisabled: false, originWhitelist: WebViewShared.defaultOriginWhitelist, }; @@ -143,6 +144,7 @@ class WebView extends React.Component { style={webViewStyles} source={resolveAssetSource(source)} scalesPageToFit={this.props.scalesPageToFit} + allowFileAccess={this.props.allowFileAccess} injectedJavaScript={this.props.injectedJavaScript} userAgent={this.props.userAgent} javaScriptEnabled={this.props.javaScriptEnabled} From 10054e10ab6983c0006c364a0f810d5a2e52103d Mon Sep 17 00:00:00 2001 From: Thibault Malbranche Date: Fri, 14 Sep 2018 01:14:31 +0200 Subject: [PATCH 2/3] Added flow type --- js/WebViewTypes.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/WebViewTypes.js b/js/WebViewTypes.js index ca3e31e..ed96633 100644 --- a/js/WebViewTypes.js +++ b/js/WebViewTypes.js @@ -232,6 +232,12 @@ export type AndroidWebViewProps = $ReadOnly<{| */ allowUniversalAccessFromFileURLs?: ?boolean, + /** + * Sets whether the webview allow access to file system. + * @platform android + */ + allowFileAccess: ?boolean, + /** * Used on Android only, controls whether form autocomplete data should be saved * @platform android From e3127bb066b2fcbdbc226ae5e2d9a060e4bd7bec Mon Sep 17 00:00:00 2001 From: Thibault Malbranche Date: Fri, 14 Sep 2018 01:22:47 +0200 Subject: [PATCH 3/3] fix flow --- js/WebViewTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/WebViewTypes.js b/js/WebViewTypes.js index ed96633..5731787 100644 --- a/js/WebViewTypes.js +++ b/js/WebViewTypes.js @@ -236,7 +236,7 @@ export type AndroidWebViewProps = $ReadOnly<{| * Sets whether the webview allow access to file system. * @platform android */ - allowFileAccess: ?boolean, + allowFileAccess?: ?boolean, /** * Used on Android only, controls whether form autocomplete data should be saved