Bläddra i källkod

Merge pull request #42 from react-native-community/import/0c576ef-allow-file-access-android

Import/0c576ef allow file access android
Thibault Malbranche 6 år sedan
förälder
incheckning
8da81b22d4
No account linked to committer's email address

+ 7
- 0
android/src/main/java/com/reactnativecommunity/webview/RCTWebViewManager.java Visa fil

@@ -589,6 +589,13 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
589 589
     }
590 590
   }
591 591
 
592
+  @ReactProp(name = "allowFileAccess")
593
+  public void setAllowFileAccess(
594
+    WebView view,
595
+    @Nullable Boolean allowFileAccess) {
596
+    view.getSettings().setAllowFileAccess(allowFileAccess != null && allowFileAccess);
597
+  }
598
+
592 599
   @ReactProp(name = "geolocationEnabled")
593 600
   public void setGeolocationEnabled(
594 601
     WebView view,

+ 2
- 0
js/WebView.android.js Visa fil

@@ -67,6 +67,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
67 67
     javaScriptEnabled: true,
68 68
     thirdPartyCookiesEnabled: true,
69 69
     scalesPageToFit: true,
70
+    allowFileAccess: false,
70 71
     saveFormDataDisabled: false,
71 72
     originWhitelist: WebViewShared.defaultOriginWhitelist,
72 73
   };
@@ -143,6 +144,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
143 144
         style={webViewStyles}
144 145
         source={resolveAssetSource(source)}
145 146
         scalesPageToFit={this.props.scalesPageToFit}
147
+        allowFileAccess={this.props.allowFileAccess}
146 148
         injectedJavaScript={this.props.injectedJavaScript}
147 149
         userAgent={this.props.userAgent}
148 150
         javaScriptEnabled={this.props.javaScriptEnabled}

+ 6
- 0
js/WebViewTypes.js Visa fil

@@ -232,6 +232,12 @@ export type AndroidWebViewProps = $ReadOnly<{|
232 232
    */
233 233
   allowUniversalAccessFromFileURLs?: ?boolean,
234 234
 
235
+  /**
236
+   * Sets whether the webview allow access to file system.
237
+   * @platform android
238
+   */
239
+  allowFileAccess?: ?boolean,
240
+
235 241
   /**
236 242
    * Used on Android only, controls whether form autocomplete data should be saved
237 243
    * @platform android