Commit 8052888c authored by Hazem Ashmawy's avatar Hazem Ashmawy Committed by Commit Bot

[AW] Mirror JS console messages in logcat only if debuggable

Mirror WebView Js console messages to logcat only if the application or
the device is debuggable.

Bug: 905251
Change-Id: I934e20a6881413b17c4f2b6221a0a4e9a15a53bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1496364
Commit-Queue: Hazem Ashmawy <hazems@chromium.org>
Reviewed-by: default avatarTobias Sargeant <tobiasjs@chromium.org>
Reviewed-by: default avatarPaul Miller <paulmiller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638113}
parent 536ccf28
......@@ -8,6 +8,7 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
......@@ -152,11 +153,17 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate {
Log.w(TAG, "Unknown message level, defaulting to DEBUG");
break;
}
// Calling onConsoleMessage(...) even that the result is ignored if it's a non-debuggable
// app or device as it can be overriden by the user with some custom logic that is expected
// to be always run.
boolean result = mContentsClient.onConsoleMessage(
new AwConsoleMessage(message, sourceId, lineNumber, messageLevel));
if (result && message != null && message.startsWith("[blocked]")) {
Log.e(TAG, "Blocked URL: " + message);
boolean isAppDebuggable = mContext.getApplicationInfo().FLAG_DEBUGGABLE != 0;
boolean isOsDebuggable = !Build.TYPE.equals("user");
// Always return true if not debuggable so js console messages won't be mirrored to logcat
// for privacy.
if (!isAppDebuggable && !isOsDebuggable) {
return true;
}
return result;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment