mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-05 17:30:38 +08:00
Expose setAllowUniversalAccessFromFileURLs in Android WebView
Summary: This pull request exposes the `setAllowUniversalAccessFromFileURLs` method of Android WebViewSettings as a property. The reason for this is when loading pages with a `file://` baseUrl it's sometimes desirable to allow loading other assets from a file base url. (For example loading an image into a canvas). More information on its use and purpose can be found [in the android docs here](https://developer.android.com/reference/android/webkit/WebSettings.html#setAllowUniversalAccessFromFileURLs%28boolean%29) Usage example: ``` jsx return ( <WebView source={{ html: myhtml, baseUrl: 'file://' }} allowUniversalAccessFromFileURLs={true} javaScriptEnabled={true} /> ) ``` Closes https://github.com/facebook/react-native/pull/8905 Differential Revision: D4147245 Pulled By: hramos fbshipit-source-id: 7eaa884b8c0268de52b284954a34acec0fbd4061
This commit is contained in:
committed by
Facebook Github Bot
parent
07295e3c08
commit
b6a38e80e0
@@ -375,6 +375,11 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
||||
view.getSettings().setMediaPlaybackRequiresUserGesture(requires);
|
||||
}
|
||||
|
||||
@ReactProp(name = "allowUniversalAccessFromFileURLs")
|
||||
public void setAllowUniversalAccessFromFileURLs(WebView view, boolean allow) {
|
||||
view.getSettings().setAllowUniversalAccessFromFileURLs(allow);
|
||||
}
|
||||
|
||||
@ReactProp(name = "injectedJavaScript")
|
||||
public void setInjectedJavaScript(WebView view, @Nullable String injectedJavaScript) {
|
||||
((ReactWebView) view).setInjectedJavaScript(injectedJavaScript);
|
||||
|
||||
Reference in New Issue
Block a user