Permalink
Browse files

Breaking change - Disable WebView geolocation by default

Reviewed By: yungsters

Differential Revision: D7846198

fbshipit-source-id: 8d6daff4b794d3569b5ddba2d8d62af8c7ff5b03
  • Loading branch information...
mdvacca authored and facebook-github-bot committed May 2, 2018
1 parent ba88292 commit 23d61b35fb6fdbfb84f77b6d99ff155a0ff868e6
@@ -138,6 +138,12 @@ class WebView extends React.Component {
*/
domStorageEnabled: PropTypes.bool,
/**
* Sets whether Geolocation is enabled. The default is false.
* @platform android
*/
geolocationEnabled: PropTypes.bool,
/**
* Sets the JS to be injected when the webpage loads.
*/
@@ -310,6 +316,7 @@ class WebView extends React.Component {
onLoadingFinish={this.onLoadingFinish}
onLoadingError={this.onLoadingError}
testID={this.props.testID}
geolocationEnabled={this.props.geolocationEnabled}
mediaPlaybackRequiresUserAction={this.props.mediaPlaybackRequiresUserAction}
allowUniversalAccessFromFileURLs={this.props.allowUniversalAccessFromFileURLs}
mixedContentMode={this.props.mixedContentMode}
@@ -384,6 +384,7 @@ public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermiss
new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
setGeolocationEnabled(webView, false);
if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
@@ -538,6 +539,13 @@ public void setUrlPrefixesForDefaultIntent(
}
}
@ReactProp(name = "geolocationEnabled")
public void setGeolocationEnabled(
WebView view,
@Nullable Boolean isGeolocationEnabled) {
view.getSettings().setGeolocationEnabled(isGeolocationEnabled != null && isGeolocationEnabled);
}
@Override
protected void addEventEmitters(ThemedReactContext reactContext, WebView view) {
// Do not register default touch emitter and let WebView implementation handle touches

0 comments on commit 23d61b3

Please sign in to comment.