Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(647)

Unified Diff: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java

Issue 2628863004: [Android WebView] Ensure we have user consent before uploading minidumps (Closed)
Patch Set: Check user consent before copying minidumps, delete minidumps in app dir if no consent, add unit te… Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
index b7fb06b95604bf6e1b142f2741731eb1ae1a8c55..279e0b922748483a2e2c7b2c5c1eb2ba502d2d6b 100644
--- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
+++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
@@ -49,6 +49,7 @@ import org.chromium.android_webview.AwSettings;
import org.chromium.android_webview.HttpAuthDatabase;
import org.chromium.android_webview.PlatformServiceBridge;
import org.chromium.android_webview.ResourcesContextWrapperFactory;
+import org.chromium.android_webview.command_line.CommandLineUtil;
import org.chromium.base.BuildConfig;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
@@ -83,7 +84,6 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
private static final String CHROMIUM_PREFS_NAME = "WebViewChromiumPrefs";
private static final String VERSION_CODE_PREF = "lastVersionCodeUsed";
- private static final String COMMAND_LINE_FILE = "/data/local/tmp/webview-command-line";
private static final String HTTP_AUTH_DATABASE_FILE = "http_auth.db";
private class WebViewChromiumRunQueue {
@@ -215,10 +215,10 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
// WebView needs to make sure to always use the wrapped application context.
ContextUtils.initApplicationContext(ResourcesContextWrapperFactory.get(ctx));
- if (isBuildDebuggable()) {
+ if (CommandLineUtil.isBuildDebuggable()) {
// Suppress the StrictMode violation as this codepath is only hit on debuggable builds.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
- CommandLine.initFromFile(COMMAND_LINE_FILE);
+ CommandLine.initFromFile(CommandLineUtil.WEBVIEW_COMMAND_LINE_FILE);
StrictMode.setThreadPolicy(oldPolicy);
} else {
CommandLine.init(null);
@@ -270,10 +270,6 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
}
}
- private static boolean isBuildDebuggable() {
- return !Build.TYPE.equals("user");
- }
-
/**
* Both versionCodes should be from a WebView provider package implemented by Chromium.
* VersionCodes from other kinds of packages won't make any sense in this method.
@@ -406,7 +402,27 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
final boolean isExternalService = true;
AwBrowserProcess.configureChildProcessLauncher(webViewPackageName, isExternalService);
AwBrowserProcess.start();
- AwBrowserProcess.handleMinidumps(webViewPackageName);
+
+ boolean enableMinidumpUploadingForTesting = CommandLine.getInstance().hasSwitch(
+ CommandLineUtil.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH);
sgurun-gerrit only 2017/01/24 08:58:49 Is this only for convenience, to ease the manual t
gsennton 2017/01/24 10:41:47 It's also useful for devices that do not have the
sgurun-gerrit only 2017/01/24 18:55:27 I think we should be a little bit stingy while add
gsennton 2017/01/25 10:35:13 Which flag are we talking about here now? Are you
+ if (enableMinidumpUploadingForTesting) {
+ AwBrowserProcess.handleMinidumps(webViewPackageName, true /* enabled */);
+ } else {
+ // Copy minidumps if Android Checkbox is toggled on.
gsennton 2017/01/23 18:33:53 TODO merge this with the queryMetricsSetting call
sgurun-gerrit only 2017/01/24 08:58:49 +1
gsennton 2017/01/24 10:41:47 Why aren't we checking canUseGms() in the call bel
sgurun-gerrit only 2017/01/24 18:55:27 you need to check for canUseGms() only if you don'
gsennton 2017/01/25 10:35:13 Done.
+ PlatformServiceBridge platformServiceBridge =
+ PlatformServiceBridge.getInstance(context);
+ if (platformServiceBridge.canUseGms()) {
+ platformServiceBridge.queryMetricsSetting(new ValueCallback<Boolean>() {
+ @Override
+ public void onReceiveValue(Boolean enabled) {
+ AwBrowserProcess.handleMinidumps(webViewPackageName, enabled);
+ }
+ });
+ } else {
+ // Gms is not available - don't copy minidumps.
+ AwBrowserProcess.handleMinidumps(webViewPackageName, false /* enabled */);
+ }
+ }
PlatformServiceBridge.getInstance(context)
.queryMetricsSetting(new ValueCallback<Boolean>() {
@@ -416,7 +432,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
}
});
- if (isBuildDebuggable()) {
+ if (CommandLineUtil.isBuildDebuggable()) {
setWebContentsDebuggingEnabled(true);
}
@@ -512,7 +528,7 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
@Override
public void setWebContentsDebuggingEnabled(boolean enable) {
// Web Contents debugging is always enabled on debug builds.
- if (!isBuildDebuggable()) {
+ if (!CommandLineUtil.isBuildDebuggable()) {
WebViewChromiumFactoryProvider.this.setWebContentsDebuggingEnabled(
enable);
}

Powered by Google App Engine
This is Rietveld 408576698