Add runtime flag to gate WebXR plane detection

Bump expiry_milestone for flags owned by xr-dev@.

Bug: 954532,929789
Change-Id: I1b7cb111c71976fee413033a4eb1d7ea1881232f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1582614
Reviewed-by: Kinuko Yasuda <[email protected]>
Reviewed-by: Bill Orr <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Commit-Queue: Piotr Bialecki <[email protected]>
Cr-Commit-Position: refs/heads/master@{#654490}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 498c812..36b01609 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -1813,6 +1813,9 @@
     {"webxr-hit-test", flag_descriptions::kWebXrHitTestName,
      flag_descriptions::kWebXrHitTestDescription, kOsAll,
      FEATURE_VALUE_TYPE(features::kWebXrHitTest)},
+    {"webxr-plane-detection", flag_descriptions::kWebXrPlaneDetectionName,
+     flag_descriptions::kWebXrPlaneDetectionDescription, kOsAll,
+     FEATURE_VALUE_TYPE(features::kWebXrPlaneDetection)},
 #if BUILDFLAG(ENABLE_VR)
     {"webxr-orientation-sensor-device",
      flag_descriptions::kWebXrOrientationSensorDeviceName,
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index f952b3340..a9b56f4 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -1921,7 +1921,7 @@
   {
     "name": "enable-webvr",
     "owners": [ "//third_party/blink/renderer/modules/vr/OWNERS", "[email protected]" ],
-    "expiry_milestone": 76
+    "expiry_milestone": 79
   },
   {
     "name": "enable-zero-copy",
@@ -2341,7 +2341,7 @@
   {
     "name": "oculus-vr",
     "owners": [ "//device/vr/OWNERS", "[email protected]" ],
-    "expiry_milestone": 76
+    "expiry_milestone": 79
   },
   {
     "name": "offline-indicator-always-http-probe",
@@ -2601,7 +2601,7 @@
   {
     "name": "openvr",
     "owners": [ "//device/vr/OWNERS", "[email protected]" ],
-    "expiry_milestone": 76
+    "expiry_milestone": 79
   },
   {
     "name": "out-of-blink-cors",
@@ -3085,22 +3085,27 @@
   {
     "name": "webxr-hit-test",
     "owners": [ "//third_party/blink/renderer/modules/xr/OWNERS", "[email protected]" ],
-    "expiry_milestone": 76
+    "expiry_milestone": 79
   },
   {
     "name": "webxr-orientation-sensor-device",
     "owners": [ "//device/vr/OWNERS", "[email protected]" ],
-    "expiry_milestone": 76
+    "expiry_milestone": 79
+  },
+  {
+    "name": "webxr-plane-detection",
+    "owners": [ "//third_party/blink/renderer/modules/xr/OWNERS", "[email protected]" ],
+    "expiry_milestone": 79
   },
   {
     "name": "windows-mixed-reality",
     "owners": [ "//device/vr/OWNERS", "[email protected]" ],
-    "expiry_milestone": 76
+    "expiry_milestone": 79
   },
   {
     "name": "xr-sandbox",
     "owners": [ "//chrome/services/isolated_xr_device/OWNERS", "[email protected]" ],
-    "expiry_milestone": 76
+    "expiry_milestone": 79
   },
   {
     "name": "enable-streamlined-usb-printer-setup",
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 2f1bf23..8a3d2513 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -2156,6 +2156,10 @@
 const char kWebXrHitTestDescription[] =
     "Enables access to raycasting against estimated XR scene geometry.";
 
+const char kWebXrPlaneDetectionName[] = "WebXR Plane Detection";
+const char kWebXrPlaneDetectionDescription[] =
+    "Enables access to planes detected in the user's environment.";
+
 const char kZeroCopyName[] = "Zero-copy rasterizer";
 const char kZeroCopyDescription[] =
     "Raster threads write directly to GPU memory associated with tiles.";
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 4d78110..e0d098c4 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -1285,6 +1285,9 @@
 extern const char kWebXrHitTestName[];
 extern const char kWebXrHitTestDescription[];
 
+extern const char kWebXrPlaneDetectionName[];
+extern const char kWebXrPlaneDetectionDescription[];
+
 extern const char kZeroCopyName[];
 extern const char kZeroCopyDescription[];
 
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc
index 65307db..969374a 100644
--- a/content/child/runtime_features.cc
+++ b/content/child/runtime_features.cc
@@ -189,6 +189,9 @@
   if (base::FeatureList::IsEnabled(features::kWebXrHitTest))
     WebRuntimeFeatures::EnableWebXRHitTest(true);
 
+  if (base::FeatureList::IsEnabled(features::kWebXrPlaneDetection))
+    WebRuntimeFeatures::EnableWebXRPlaneDetection(true);
+
   if (command_line.HasSwitch(switches::kDisablePresentationAPI))
     WebRuntimeFeatures::EnablePresentationAPI(false);
 
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc
index c095ee5..4a1fdcc5 100644
--- a/content/public/common/content_features.cc
+++ b/content/public/common/content_features.cc
@@ -308,7 +308,7 @@
                                   base::FEATURE_ENABLED_BY_DEFAULT};
 
 // History navigation in response to horizontal overscroll (aka gesture-nav).
-const base::Feature kOverscrollHistoryNavigation{
+const base::Feature kOverscrollHistoryNavigation {
   "OverscrollHistoryNavigation",
 #if defined(OS_ANDROID)
       base::FEATURE_DISABLED_BY_DEFAULT
@@ -677,6 +677,10 @@
 const base::Feature kWebXrHitTest{"WebXRHitTest",
                                   base::FEATURE_DISABLED_BY_DEFAULT};
 
+// Enables access to planes detected in the user's environment.
+const base::Feature kWebXrPlaneDetection{"WebXRPlaneDetection",
+                                         base::FEATURE_DISABLED_BY_DEFAULT};
+
 // Wipe corrupt v2 IndexedDB databases.
 const base::Feature kWipeCorruptV2IDBDatabases{
     "WipeCorruptV2IDBDatabases", base::FEATURE_ENABLED_BY_DEFAULT};
diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h
index 4601383..7a9d778 100644
--- a/content/public/common/content_features.h
+++ b/content/public/common/content_features.h
@@ -146,6 +146,7 @@
 CONTENT_EXPORT extern const base::Feature kWebUsb;
 CONTENT_EXPORT extern const base::Feature kWebXr;
 CONTENT_EXPORT extern const base::Feature kWebXrHitTest;
+CONTENT_EXPORT extern const base::Feature kWebXrPlaneDetection;
 CONTENT_EXPORT extern const base::Feature kWipeCorruptV2IDBDatabases;
 CONTENT_EXPORT extern const base::Feature kScriptStreamingOnPreload;
 
diff --git a/third_party/blink/public/platform/web_runtime_features.h b/third_party/blink/public/platform/web_runtime_features.h
index dd4a7aa..f3ab4f02 100644
--- a/third_party/blink/public/platform/web_runtime_features.h
+++ b/third_party/blink/public/platform/web_runtime_features.h
@@ -197,6 +197,7 @@
   BLINK_PLATFORM_EXPORT static void EnableWebVR(bool);
   BLINK_PLATFORM_EXPORT static void EnableWebXR(bool);
   BLINK_PLATFORM_EXPORT static void EnableWebXRHitTest(bool);
+  BLINK_PLATFORM_EXPORT static void EnableWebXRPlaneDetection(bool);
   BLINK_PLATFORM_EXPORT static void EnableXSLT(bool);
   BLINK_PLATFORM_EXPORT static void ForceOverlayFullscreenVideo(bool);
   BLINK_PLATFORM_EXPORT static void EnableTimerThrottlingForBackgroundTabs(
diff --git a/third_party/blink/renderer/platform/exported/web_runtime_features.cc b/third_party/blink/renderer/platform/exported/web_runtime_features.cc
index e7ad1eb..f302926 100644
--- a/third_party/blink/renderer/platform/exported/web_runtime_features.cc
+++ b/third_party/blink/renderer/platform/exported/web_runtime_features.cc
@@ -483,6 +483,10 @@
   RuntimeEnabledFeatures::SetWebXRHitTestEnabled(enable);
 }
 
+void WebRuntimeFeatures::EnableWebXRPlaneDetection(bool enable) {
+  RuntimeEnabledFeatures::SetWebXRPlaneDetectionEnabled(enable);
+}
+
 void WebRuntimeFeatures::EnablePresentationAPI(bool enable) {
   RuntimeEnabledFeatures::SetPresentationEnabled(enable);
 }
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 315120b..5444739 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -33463,6 +33463,7 @@
   <int value="-286603268" label="hide-android-files-in-files-app"/>
   <int value="-284547865" label="UnifiedConsent:enabled"/>
   <int value="-283388027" label="ManualFallbacksFilling:disabled"/>
+  <int value="-283024110" label="WebXRPlaneDetection:disabled"/>
   <int value="-281844827" label="AutofillCreditCardAblationExperiment:enabled"/>
   <int value="-279920685" label="affiliation-based-matching:enabled"/>
   <int value="-279493876" label="WebVRExperimentalRendering:enabled"/>
@@ -33583,6 +33584,7 @@
   <int value="-88273414" label="ContentSuggestionsShowSummary:enabled"/>
   <int value="-86788587" label="allow-autofill-sync-credential"/>
   <int value="-86243376" label="LayoutNG:enabled"/>
+  <int value="-82530769" label="WebXRPlaneDetection:enabled"/>
   <int value="-80501013" label="AutofillOffNoServerData:enabled"/>
   <int value="-80353187" label="disable-display-color-calibration"/>
   <int value="-79327236" label="ModeSpecificPowerButton:enabled"/>