[AW][Dev-UI] generate AwSwitches from aw_switches.cc
No change to logic. This generates AwSwitches.java from aw_switches.cc
using java_cpp_strings.
Fixed: 956803
Test: autoninja -C out/Default system_webview_google_apk
Test: run_webview_instrumentation_test_apk -f=SafeBrowsingTest.*
Change-Id: I1933e812e5206eb8ae087d30e1abf61d2695991a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343951
Commit-Queue: Nate Fischer <[email protected]>
Reviewed-by: Richard Coles <[email protected]>
Cr-Commit-Position: refs/heads/master@{#796505}
diff --git a/android_webview/BUILD.gn b/android_webview/BUILD.gn
index 29738095..552cc92 100644
--- a/android_webview/BUILD.gn
+++ b/android_webview/BUILD.gn
@@ -647,11 +647,17 @@
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
}
+java_cpp_strings("common_java_switches_srcjar") {
+ # External code should depend on "common_java" instead.
+ visibility = [ ":*" ]
+ sources = [ "common/aw_switches.cc" ]
+ template = "java/src/org/chromium/android_webview/common/AwSwitches.java.tmpl"
+}
+
android_library("common_java") {
sources = [
"java/src/org/chromium/android_webview/common/AwFeatures.java",
"java/src/org/chromium/android_webview/common/AwResource.java",
- "java/src/org/chromium/android_webview/common/AwSwitches.java",
"java/src/org/chromium/android_webview/common/CommandLineUtil.java",
"java/src/org/chromium/android_webview/common/DeveloperModeUtils.java",
"java/src/org/chromium/android_webview/common/Flag.java",
@@ -664,6 +670,7 @@
"//components/metrics:metrics_java",
"//third_party/android_deps:androidx_annotation_annotation_java",
]
+ srcjar_deps = [ ":common_java_switches_srcjar" ]
}
android_aidl("common_aidl") {
diff --git a/android_webview/common/aw_switches.cc b/android_webview/common/aw_switches.cc
index 13180fcd..8372ebc3 100644
--- a/android_webview/common/aw_switches.cc
+++ b/android_webview/common/aw_switches.cc
@@ -11,10 +11,42 @@
const char kWebViewSandboxedRenderer[] = "webview-sandboxed-renderer";
// used to disable safebrowsing functionality in webview
-const char kWebViewDisableSafeBrowsingSupport[] =
+const char kWebViewDisableSafebrowsingSupport[] =
"webview-disable-safebrowsing-support";
// Used to enable vulkan draw mode instead of interop draw mode for webview.
const char kWebViewEnableVulkan[] = "webview-enable-vulkan";
+// Enables SafeBrowsing and causes WebView to treat all resources as malicious.
+// Use care: this will block all resources from loading.
+const char kWebViewSafebrowsingBlockAllResources[] =
+ "webview-safebrowsing-block-all-resources";
+
+// Highlight the contents (including web contents) of all WebViews with a yellow
+// tint. This is useful for identifying WebViews in an Android application.
+const char kHighlightAllWebViews[] = "highlight-all-webviews";
+
+// WebView will log additional debugging information to logcat, such as
+// variations and commandline state.
+const char kWebViewVerboseLogging[] = "webview-verbose-logging";
+
+// The length of time in seconds that an app's copy of the variations seed
+// should be considered fresh. If an app's seed is older than this, a new seed
+// will be requested from WebView's IVariationsSeedServer.
+const char kFinchSeedExpirationAge[] = "finch-seed-expiration-age";
+
+// Forces WebView's service to always schedule a new variations seed download
+// job, even if one is already pending.
+const char kFinchSeedIgnorePendingDownload[] =
+ "finch-seed-ignore-pending-download";
+
+// The minimum amount of time in seconds that WebView's service will wait
+// between two variations seed downloads from the variations server.
+const char kFinchSeedMinDownloadPeriod[] = "finch-seed-min-download-period";
+
+// The minimum amount of time in seconds that the embedded WebView
+// implementation will wait between two requests to WebView's service for a new
+// variations seed.
+const char kFinchSeedMinUpdatePeriod[] = "finch-seed-min-update-period";
+
} // namespace switches
diff --git a/android_webview/common/aw_switches.h b/android_webview/common/aw_switches.h
index 7f1196f7..c883e89 100644
--- a/android_webview/common/aw_switches.h
+++ b/android_webview/common/aw_switches.h
@@ -9,12 +9,15 @@
extern const char kWebViewLogJsConsoleMessages[];
extern const char kWebViewSandboxedRenderer[];
-extern const char kWebViewDisableSafeBrowsingSupport[];
+extern const char kWebViewDisableSafebrowsingSupport[];
extern const char kWebViewEnableVulkan[];
-
-// Please note that if you are adding a flag that is intended for a renderer,
-// you also need to add it into
-// AwContentBrowserClient::AppendExtraCommandLineSwitches.
+extern const char kWebViewSafebrowsingBlockAllResources[];
+extern const char kHighlightAllWebViews[];
+extern const char kWebViewVerboseLogging[];
+extern const char kFinchSeedExpirationAge[];
+extern const char kFinchSeedIgnorePendingDownload[];
+extern const char kFinchSeedMinDownloadPeriod[];
+extern const char kFinchSeedMinUpdatePeriod[];
} // namespace switches
diff --git a/android_webview/java/src/org/chromium/android_webview/common/AwSwitches.java b/android_webview/java/src/org/chromium/android_webview/common/AwSwitches.java
deleted file mode 100644
index 2ba2b11..0000000
--- a/android_webview/java/src/org/chromium/android_webview/common/AwSwitches.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2015 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.common;
-
-/**
- * Contains command line switches that are specific to Android WebView.
- */
-public final class AwSwitches {
- // Native switch kEnableCrashReporterForTesting in //base/base_switches.h
- public static final String CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH =
- "enable-crash-reporter-for-testing";
-
- // Highlight the contents (including web contents) of all WebViews with a yellow tint. This is
- // useful for identifying WebViews in an Android application.
- public static final String HIGHLIGHT_ALL_WEBVIEWS = "highlight-all-webviews";
-
- // WebView will log additional debugging information to logcat, such as variations and
- // commandline state.
- public static final String WEBVIEW_VERBOSE_LOGGING = "webview-verbose-logging";
-
- // Allow mirroring JS console messages to system logs. This is the default behavior on
- // debuggable devices (userdebug or eng), so there is no reason for a user to specify this
- // explicitly. Native switch kWebViewLogJsConsoleMessages.
- public static final String WEBVIEW_LOG_JS_CONSOLE_MESSAGES = "webview-log-js-console-messages";
-
- // Indicate that renderers are running in a sandbox. Enables
- // kInProcessGPU and sets kRendererProcessLimit to 1.
- // Native switch kWebViewSandboxedRenderer.
- public static final String WEBVIEW_SANDBOXED_RENDERER = "webview-sandboxed-renderer";
-
- // Disables safebrowsing functionality in webview.
- // Native switch kWebViewDisableSafeBrowsingSupport.
- public static final String WEBVIEW_DISABLE_SAFEBROWSING_SUPPORT =
- "webview-disable-safebrowsing-support";
-
- // Enables SafeBrowsing and causes WebView to treat all resources as malicious. Use care: this
- // will block all resources from loading.
- // No native switch.
- public static final String WEBVIEW_SAFEBROWSING_BLOCK_ALL_RESOURCES =
- "webview-safebrowsing-block-all-resources";
-
- // The length of time in seconds that an app's copy of the variations seed should be considered
- // fresh. If an app's seed is older than this, a new seed will be requested from WebView's
- // IVariationsSeedServer.
- // No native switch.
- public static final String FINCH_SEED_EXPIRATION_AGE = "finch-seed-expiration-age";
-
- // Forces WebView's service to always schedule a new variations seed download job, even if one
- // is already pending.
- // No native switch.
- public static final String FINCH_SEED_IGNORE_PENDING_DOWNLOAD =
- "finch-seed-ignore-pending-download";
-
- // The minimum amount of time in seconds that WebView's service will wait between two
- // variations seed downloads from the variations server.
- // No native switch.
- public static final String FINCH_SEED_MIN_DOWNLOAD_PERIOD = "finch-seed-min-download-period";
-
- // The minimum amount of time in seconds that the embedded WebView implementation will wait
- // between two requests to WebView's service for a new variations seed.
- // No native switch.
- public static final String FINCH_SEED_MIN_UPDATE_PERIOD = "finch-seed-min-update-period";
-
- // Do not instantiate this class.
- private AwSwitches() {}
-}
diff --git a/android_webview/java/src/org/chromium/android_webview/common/AwSwitches.java.tmpl b/android_webview/java/src/org/chromium/android_webview/common/AwSwitches.java.tmpl
new file mode 100644
index 0000000..699c1291
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/common/AwSwitches.java.tmpl
@@ -0,0 +1,20 @@
+// Copyright 2020 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.common;
+
+/**
+ * Contains command line switches that are specific to Android WebView.
+ */
+public final class AwSwitches {{
+
+{NATIVE_STRINGS}
+
+ // Native switch kEnableCrashReporterForTesting in //base/base_switches.h
+ public static final String CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH =
+ "enable-crash-reporter-for-testing";
+
+ // Do not instantiate this class.
+ private AwSwitches() {{}}
+}}
diff --git a/android_webview/java/src/org/chromium/android_webview/common/ProductionSupportedFlagList.java b/android_webview/java/src/org/chromium/android_webview/common/ProductionSupportedFlagList.java
index 597b41ca..e576617 100644
--- a/android_webview/java/src/org/chromium/android_webview/common/ProductionSupportedFlagList.java
+++ b/android_webview/java/src/org/chromium/android_webview/common/ProductionSupportedFlagList.java
@@ -51,7 +51,7 @@
"Forces WebView's metrics reporting to be enabled. This overrides user "
+ "settings and capacity sampling, but does not override the app's "
+ "choice to opt-out."),
- Flag.commandLine("webview-log-js-console-messages",
+ Flag.commandLine(AwSwitches.WEBVIEW_LOG_JS_CONSOLE_MESSAGES,
"Mirrors JavaScript console messages to system logs."),
Flag.commandLine(AwSwitches.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH,
"Used for turning on Breakpad crash reporting in a debug environment where "