From cb68b97289ad8fa98e7195a4dadd44135f044e17 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Fri, 17 Feb 2017 18:21:20 -0800 Subject: [PATCH] android: stop logging console logs from webview Summary: We're logging all console logs from webview. This strips console logging for non debug builds Reviewed By: AaaChiuuu Differential Revision: D4578071 fbshipit-source-id: 79b21012a6ef215eb35701911662a720cb6be280 --- .../react/views/webview/ReactWebViewManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java index c9b08b45b..bc18f86b0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java @@ -24,6 +24,7 @@ import android.net.Uri; import android.os.Build; import android.text.TextUtils; import android.view.ViewGroup.LayoutParams; +import android.webkit.ConsoleMessage; import android.webkit.GeolocationPermissions; import android.webkit.WebChromeClient; import android.webkit.WebView; @@ -331,6 +332,15 @@ public class ReactWebViewManager extends SimpleViewManager { protected WebView createViewInstance(ThemedReactContext reactContext) { ReactWebView webView = new ReactWebView(reactContext); webView.setWebChromeClient(new WebChromeClient() { + @Override + public boolean onConsoleMessage(ConsoleMessage message) { + if (ReactBuildConfig.DEBUG) { + return super.onConsoleMessage(message); + } + // Ignore console logs in non debug builds. + return true; + } + @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false);