Skip to content

Commit

Permalink
Webview disable save form prop
Browse files Browse the repository at this point in the history
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 #13271

Differential Revision: D4858899

Pulled By: ericvicenti

fbshipit-source-id: 62738b0685e4c1958c8a32e184fa2fe4f711b336
  • Loading branch information
Faraz Sherwani authored and facebook-github-bot committed Apr 10, 2017
1 parent 2336ac2 commit 8591d8a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Libraries/Components/WebView/WebView.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ public void setMediaPlaybackRequiresUserAction(WebView view, boolean requires) {
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) {
Expand Down

0 comments on commit 8591d8a

Please sign in to comment.