Webview disable save form prop

Summary:
Adds functionality to be able to disable saving of form data and thereby disabling autocomplete in webview on Android. Can be used as a workaround for #13241

Manual testing that autocomplete is disabled when the property is set to true, and still enabled when it is unset or set to false.
Closes https://github.com/facebook/react-native/pull/13271

Differential Revision: D4858899

Pulled By: ericvicenti

fbshipit-source-id: 62738b0685e4c1958c8a32e184fa2fe4f711b336
This commit is contained in:
Faraz Sherwani 2017-04-09 21:32:57 -07:00 committed by Facebook Github Bot
parent 2336ac299c
commit 8591d8ae71
2 changed files with 13 additions and 0 deletions

View File

@ -184,11 +184,18 @@ class WebView extends React.Component {
'always',
'compatibility'
]),
/**
* Used on Android only, controls whether form autocomplete data should be saved
* @platform android
*/
saveFormDataDisabled: PropTypes.bool,
};
static defaultProps = {
javaScriptEnabled : true,
scalesPageToFit: true,
saveFormDataDisabled: false
};
state = {
@ -261,6 +268,7 @@ class WebView extends React.Component {
mediaPlaybackRequiresUserAction={this.props.mediaPlaybackRequiresUserAction}
allowUniversalAccessFromFileURLs={this.props.allowUniversalAccessFromFileURLs}
mixedContentMode={this.props.mixedContentMode}
saveFormDataDisabled={this.props.saveFormDataDisabled}
/>;
return (

View File

@ -397,6 +397,11 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
public void setAllowUniversalAccessFromFileURLs(WebView view, boolean allow) {
view.getSettings().setAllowUniversalAccessFromFileURLs(allow);
}
@ReactProp(name = "saveFormDataDisabled")
public void setSaveFormDataDisabled(WebView view, boolean disable) {
view.getSettings().setSaveFormData(!disable);
}
@ReactProp(name = "injectedJavaScript")
public void setInjectedJavaScript(WebView view, @Nullable String injectedJavaScript) {