Added --enable-ui-devtools to chrome://flags.

BUG=678038

Review-Url: https://codereview.chromium.org/2928973003
Cr-Commit-Position: refs/heads/master@{#478258}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 64b0bb2..3e72025c 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -115,6 +115,7 @@
 #if defined(OS_CHROMEOS)
 #include "chromeos/chromeos_switches.h"
 #include "components/arc/arc_features.h"
+#include "components/ui_devtools/switches.h"
 #include "third_party/cros_system_api/switches/chrome_switches.h"
 #endif  // OS_CHROMEOS
 
@@ -2734,6 +2735,13 @@
          // when the flag is manually enabled in a local build.
          "AutofillCreditCardDropdownVariations")},
 #endif  // OS_ANDROID
+
+#if defined(OS_CHROMEOS)
+    {ui::devtools::kEnableUiDevTools, flag_descriptions::kUiDevToolsName,
+     flag_descriptions::kUiDevToolsDescription, kOsCrOS,
+     SINGLE_VALUE_TYPE(ui::devtools::kEnableUiDevTools)},
+#endif  // defined(OS_CHROMEOS)
+
     {"enable-autofill-credit-card-last-used-date-display",
      flag_descriptions::kEnableAutofillCreditCardLastUsedDateDisplayName,
      flag_descriptions::kEnableAutofillCreditCardLastUsedDateDisplayDescription,
@@ -3115,6 +3123,12 @@
       channel != version_info::Channel::UNKNOWN) {
     return true;
   }
+
+  // enable-ui-devtools is only available on for non Stable channels.
+  if (!strcmp(ui::devtools::kEnableUiDevTools, entry.internal_name) &&
+      channel == version_info::Channel::STABLE) {
+    return true;
+  }
 #endif  // defined(OS_CHROMEOS)
 
   // data-reduction-proxy-lo-fi and enable-data-reduction-proxy-lite-page
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index a9789a6..b396780d 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -3203,6 +3203,11 @@
     "Disable new window behavior for the accessibility keyboard "
     "in non-sticky mode (do not change work area in non-sticky mode).";
 
+const char kUiDevToolsName[] = "Enable native UI inspection";
+const char kUiDevToolsDescription[] =
+    "Enables inspection of native UI elements. For local inspection use "
+    "chrome://inspect#other";
+
 #endif  // defined(OS_CHROMEOS)
 
 }  // namespace flag_descriptions
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 8e14959356..87430a03 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -1348,6 +1348,9 @@
 extern const char kTouchscreenCalibrationName[];
 extern const char kTouchscreenCalibrationDescription[];
 
+extern const char kUiDevToolsName[];
+extern const char kUiDevToolsDescription[];
+
 extern const char kUseMusName[];
 extern const char kUseMusDescription[];
 extern const char kEnableMashDescription[];
diff --git a/components/ui_devtools/devtools_server.cc b/components/ui_devtools/devtools_server.cc
index 2bab50aa..fd0e35b 100644
--- a/components/ui_devtools/devtools_server.cc
+++ b/components/ui_devtools/devtools_server.cc
@@ -34,6 +34,7 @@
 
 int GetUiDevToolsPort() {
   DCHECK(IsUiDevToolsEnabled());
+  // This value is duplicated in the chrome://flags description.
   constexpr int kDefaultPort = 9223;
   int port;
   if (!base::StringToInt(
diff --git a/components/ui_devtools/switches.h b/components/ui_devtools/switches.h
index 8dcb6980..d0bb577 100644
--- a/components/ui_devtools/switches.h
+++ b/components/ui_devtools/switches.h
@@ -5,10 +5,12 @@
 #ifndef COMPONENTS_UI_DEVTOOLS_SWITCHES_H_
 #define COMPONENTS_UI_DEVTOOLS_SWITCHES_H_
 
+#include "components/ui_devtools/devtools_export.h"
+
 namespace ui {
 namespace devtools {
 
-extern const char kEnableUiDevTools[];
+extern UI_DEVTOOLS_EXPORT const char kEnableUiDevTools[];
 
 }  // namespace devtools
 }  // namespace ui
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 4d914829..f17facaf 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -22789,6 +22789,7 @@
   <int value="1062357243" label="remember-cert-error-decisions"/>
   <int value="1064288458" label="OfflineRecentPages:enabled"/>
   <int value="1067618884" label="enable-experimental-input-view-features"/>
+  <int value="1067990299" label="enable-ui-devtools"/>
   <int value="1070164693" label="MidiManagerDynamicInstantiation:disabled"/>
   <int value="1070300488" label="disable-webgl"/>
   <int value="1070449228" label="ContextualSuggestionsCarousel:enabled"/>