Skip to content


Browse files Browse the repository at this point in the history
Expose setAllowUniversalAccessFromFileURLs in Android WebView
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](

Usage example:

``` jsx
return (
    source={{ html: myhtml, baseUrl: 'file://' }}
    javaScriptEnabled={true} />
Closes #8905

Differential Revision: D4147245

Pulled By: hramos

fbshipit-source-id: 7eaa884b8c0268de52b284954a34acec0fbd4061
  • Loading branch information
Thomas101 authored and Facebook Github Bot committed Nov 8, 2016
1 parent 07295e3 commit b6a38e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Libraries/Components/WebView/
Expand Up @@ -152,6 +152,14 @@ class WebView extends React.Component {
* start playing. The default value is `false`.
mediaPlaybackRequiresUserAction: PropTypes.bool,

* 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
* @platform android
allowUniversalAccessFromFileURLs: PropTypes.bool,

static defaultProps = {
Expand Down Expand Up @@ -227,6 +235,7 @@ class WebView extends React.Component {

return (
Expand Down
Expand Up @@ -375,6 +375,11 @@ public void setMediaPlaybackRequiresUserAction(WebView view, boolean requires) {

@ReactProp(name = "allowUniversalAccessFromFileURLs")
public void setAllowUniversalAccessFromFileURLs(WebView view, boolean allow) {

@ReactProp(name = "injectedJavaScript")
public void setInjectedJavaScript(WebView view, @Nullable String injectedJavaScript) {
((ReactWebView) view).setInjectedJavaScript(injectedJavaScript);
Expand Down

0 comments on commit b6a38e8

Please sign in to comment.