Add runtime setting to force passive event listeners.

Add the ability to set the default value for the 'passive' field
in AddEventListenerOptions.

The value can take on 4 values; 'false', 'true', 'documentonlytrue',
'forcetrue'. It can be set from the command line or by adjusting
the chrome://flags.

BUG=599611

Review-Url: https://codereview.chromium.org/1965493002
Cr-Commit-Position: refs/heads/master@{#393565}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 0e2e88d3..539da28 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -185,6 +185,16 @@
 };
 #endif
 
+const FeatureEntry::Choice kPassiveListenersChoices[] = {
+    {IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", ""},
+    {IDS_FLAGS_PASSIVE_EVENT_LISTENER_DOCUMENT_TRUE,
+     switches::kPassiveListenersDefault, "documentonlytrue"},
+    {IDS_FLAGS_PASSIVE_EVENT_LISTENER_TRUE, switches::kPassiveListenersDefault,
+     "true"},
+    {IDS_FLAGS_PASSIVE_EVENT_LISTENER_FORCE_ALL_TRUE,
+     switches::kPassiveListenersDefault, "forcealltrue"},
+};
+
 const FeatureEntry::Choice kMarkNonSecureAsChoices[] = {
     {IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", ""},
     {IDS_MARK_NON_SECURE_AS_NEUTRAL, security_state::switches::kMarkNonSecureAs,
@@ -1866,6 +1876,11 @@
      IDS_FLAGS_EXPERIMENTAL_POINTER_EVENT_NAME,
      IDS_FLAGS_EXPERIMENTAL_POINTER_EVENT_DESCRIPTION, kOsAll,
      FEATURE_VALUE_TYPE(features::kPointerEvents)},
+    {"passive-listener-default",  // FLAGS:RECORD_UMA
+     IDS_FLAGS_PASSIVE_EVENT_LISTENER_DEFAULT_NAME,
+     IDS_FLAGS_PASSIVE_EVENT_LISTENER_DEFAULT_DESCRIPTION, kOsAll,
+     MULTI_VALUE_TYPE(kPassiveListenersChoices)},
+
     // NOTE: Adding new command-line switches requires adding corresponding
     // entries to enum "LoginCustomFlags" in histograms.xml. See note in
     // histograms.xml and don't forget to run AboutFlagsHistogramTest unit test.