Browse Source

feat(android): allowFileAccessFromFileURLs prop added (#831)

* add allowFileAccessFromFileURLs propery to do the expected on android

* Added types

* Update WebViewTypes.ts
Borut Balazek 4 years ago
parent
commit
4db3d84dda

+ 5
- 0
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java View File

371
     view.getSettings().setMediaPlaybackRequiresUserGesture(requires);
371
     view.getSettings().setMediaPlaybackRequiresUserGesture(requires);
372
   }
372
   }
373
 
373
 
374
+  @ReactProp(name = "allowFileAccessFromFileURLs")
375
+  public void setAllowFileAccessFromFileURLs(WebView view, boolean allow) {
376
+    view.getSettings().setAllowFileAccessFromFileURLs(allow);
377
+  }
378
+
374
   @ReactProp(name = "allowUniversalAccessFromFileURLs")
379
   @ReactProp(name = "allowUniversalAccessFromFileURLs")
375
   public void setAllowUniversalAccessFromFileURLs(WebView view, boolean allow) {
380
   public void setAllowUniversalAccessFromFileURLs(WebView view, boolean allow) {
376
     view.getSettings().setAllowUniversalAccessFromFileURLs(allow);
381
     view.getSettings().setAllowUniversalAccessFromFileURLs(allow);

+ 11
- 0
docs/Reference.md View File

44
 - [`scrollEnabled`](Reference.md#scrollenabled)
44
 - [`scrollEnabled`](Reference.md#scrollenabled)
45
 - [`directionalLockEnabled`](Reference.md#directionalLockEnabled)
45
 - [`directionalLockEnabled`](Reference.md#directionalLockEnabled)
46
 - [`geolocationEnabled`](Reference.md#geolocationenabled)
46
 - [`geolocationEnabled`](Reference.md#geolocationenabled)
47
+- [`allowFileAccessFromFileURLs`](Reference.md#allowFileAccessFromFileURLs)
47
 - [`allowUniversalAccessFromFileURLs`](Reference.md#allowUniversalAccessFromFileURLs)
48
 - [`allowUniversalAccessFromFileURLs`](Reference.md#allowUniversalAccessFromFileURLs)
48
 - [`allowingReadAccessToURL`](Reference.md#allowingReadAccessToURL)
49
 - [`allowingReadAccessToURL`](Reference.md#allowingReadAccessToURL)
49
 - [`url`](Reference.md#url)
50
 - [`url`](Reference.md#url)
876
 
877
 
877
 ---
878
 ---
878
 
879
 
880
+### `allowFileAccessFromFileURLs`
881
+
882
+ 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`.
883
+
884
+| Type | Required | Platform |
885
+| ---- | -------- | -------- |
886
+| bool | No       | Android  |
887
+
888
+---
889
+
879
 ### `allowUniversalAccessFromFileURLs`
890
 ### `allowUniversalAccessFromFileURLs`
880
 
891
 
881
 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`.
892
 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`.

+ 10
- 0
src/WebViewTypes.ts View File

242
   cacheMode?: CacheMode;
242
   cacheMode?: CacheMode;
243
   allowFileAccess?: boolean;
243
   allowFileAccess?: boolean;
244
   scalesPageToFit?: boolean;
244
   scalesPageToFit?: boolean;
245
+  allowFileAccessFromFileURLs?: boolean;
245
   allowUniversalAccessFromFileURLs?: boolean;
246
   allowUniversalAccessFromFileURLs?: boolean;
246
   androidHardwareAccelerationDisabled?: boolean;
247
   androidHardwareAccelerationDisabled?: boolean;
247
   domStorageEnabled?: boolean;
248
   domStorageEnabled?: boolean;
500
    */
501
    */
501
   geolocationEnabled?: boolean;
502
   geolocationEnabled?: boolean;
502
 
503
 
504
+  
505
+  /**
506
+   * Boolean that sets whether JavaScript running in the context of a file 
507
+   * scheme URL should be allowed to access content from other file scheme URLs. 
508
+   * Including accessing content from other file scheme URLs
509
+   * @platform android
510
+   */
511
+  allowFileAccessFromFileURLs?: boolean;
512
+  
503
   /**
513
   /**
504
    * Boolean that sets whether JavaScript running in the context of a file
514
    * Boolean that sets whether JavaScript running in the context of a file
505
    * scheme URL should be allowed to access content from any origin.
515
    * scheme URL should be allowed to access content from any origin.