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

Unified Diff: android_webview/java/src/org/chromium/android_webview/command_line/CommandLineUtil.java

Issue 2628863004: [Android WebView] Ensure we have user consent before uploading minidumps (Closed)
Patch Set: Minor cleanups + comment fixes. 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/java/src/org/chromium/android_webview/command_line/CommandLineUtil.java
diff --git a/android_webview/java/src/org/chromium/android_webview/command_line/CommandLineUtil.java b/android_webview/java/src/org/chromium/android_webview/command_line/CommandLineUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..00f508ed5fa1db2f282ff459ba5b71f25d211793
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/command_line/CommandLineUtil.java
@@ -0,0 +1,45 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview.command_line;
+
+import android.os.Build;
+import android.os.StrictMode;
+
+import org.chromium.base.CommandLine;
+import org.chromium.base.annotations.SuppressFBWarnings;
+
+/**
+ * Utility class for WebView's CommandLine - this is compiled into a separate target that can be
+ * reached from WebView's separate minidump-uploading Services.
+ */
+public class CommandLineUtil {
+ private CommandLineUtil() {}
+
+ public static final String WEBVIEW_COMMAND_LINE_FILE = "/data/local/tmp/webview-command-line";
+
+ // same switch as kEnableCrashReporterForTesting in //base/base_switches.h
+ public static final String CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH =
+ "enable-crash-reporter-for-testing";
+
+ public static boolean isBuildDebuggable() {
+ return !Build.TYPE.equals("user");
+ }
+
+ /**
+ * Initialize the CommandLine for WebView - this should be initialized on the same thread where
+ * we subsequently access CommandLine.
+ */
+ @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
+ public static void initCommandLine() {
+ if (CommandLineUtil.isBuildDebuggable()) {
+ // Suppress the StrictMode violation as this codepath is only hit on debuggable builds.
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+ CommandLine.initFromFile(CommandLineUtil.WEBVIEW_COMMAND_LINE_FILE);
+ StrictMode.setThreadPolicy(oldPolicy);
+ } else {
+ CommandLine.init(null);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698