[vr] Add runtime flag to enable tabs view

Bug: 840931
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr
Change-Id: I7e1b336aeed1648fcbe01ae479f486e0b8ba5ac4
Reviewed-on: https://chromium-review.googlesource.com/1053065
Commit-Queue: Tibor Goldschwendt <[email protected]>
Reviewed-by: Michael Thiessen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#557530}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 2375e9f..3ca1f318 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -2237,6 +2237,9 @@
     {"vr-browsing-in-custom-tab", flag_descriptions::kVrBrowsingInCustomTabName,
      flag_descriptions::kVrBrowsingInCustomTabDescription, kOsAndroid,
      FEATURE_VALUE_TYPE(chrome::android::kVrBrowsingInCustomTab)},
+    {"vr-browsing-tabs-view", flag_descriptions::kVrBrowsingTabsViewName,
+     flag_descriptions::kVrBrowsingTabsViewDescription, kOsAndroid,
+     FEATURE_VALUE_TYPE(chrome::android::kVrBrowsingTabsView)},
     {"vr-icon-in-daydream-home", flag_descriptions::kVrIconInDaydreamHomeName,
      flag_descriptions::kVrIconInDaydreamHomeDescription, kOsAndroid,
      FEATURE_VALUE_TYPE(chrome::android::kVrIconInDaydreamHome)},
diff --git a/chrome/browser/android/chrome_feature_list.cc b/chrome/browser/android/chrome_feature_list.cc
index a14b35a..232e9fb 100644
--- a/chrome/browser/android/chrome_feature_list.cc
+++ b/chrome/browser/android/chrome_feature_list.cc
@@ -386,6 +386,9 @@
 const base::Feature kVrBrowsingNativeAndroidUi{
     "VrBrowsingNativeAndroidUi", base::FEATURE_ENABLED_BY_DEFAULT};
 
+const base::Feature kVrBrowsingTabsView{"VrBrowsingTabsView",
+                                        base::FEATURE_DISABLED_BY_DEFAULT};
+
 const base::Feature kVrIconInDaydreamHome{"VrIconInDaydreamHome",
                                           base::FEATURE_ENABLED_BY_DEFAULT};
 
diff --git a/chrome/browser/android/chrome_feature_list.h b/chrome/browser/android/chrome_feature_list.h
index b24bba6e..978d2d8ed 100644
--- a/chrome/browser/android/chrome_feature_list.h
+++ b/chrome/browser/android/chrome_feature_list.h
@@ -83,6 +83,7 @@
 extern const base::Feature kVrBrowsingFeedback;
 extern const base::Feature kVrBrowsingInCustomTab;
 extern const base::Feature kVrBrowsingNativeAndroidUi;
+extern const base::Feature kVrBrowsingTabsView;
 extern const base::Feature kVrIconInDaydreamHome;
 extern const base::Feature kWebVrAutopresentFromIntent;
 extern const base::Feature kWebVrCardboardSupport;
diff --git a/chrome/browser/android/vr/vr_shell.cc b/chrome/browser/android/vr/vr_shell.cc
index 0d6629d..399313b 100644
--- a/chrome/browser/android/vr/vr_shell.cc
+++ b/chrome/browser/android/vr/vr_shell.cc
@@ -18,6 +18,7 @@
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/trace_event/trace_event.h"
 #include "base/values.h"
+#include "chrome/browser/android/chrome_feature_list.h"
 #include "chrome/browser/android/tab_android.h"
 #include "chrome/browser/android/vr/android_ui_gesture_target.h"
 #include "chrome/browser/android/vr/autocomplete_controller.h"
@@ -1350,6 +1351,8 @@
       base::FeatureList::IsEnabled(features::kVrBrowsingExperimentalRendering);
   ui_initial_state.assets_supported = AssetsLoader::AssetsSupported();
   ui_initial_state.is_standalone_vr_device = is_standalone_vr_device;
+  ui_initial_state.create_tabs_view =
+      base::FeatureList::IsEnabled(chrome::android::kVrBrowsingTabsView);
 
   return reinterpret_cast<intptr_t>(new VrShell(
       env, obj, ui_initial_state,
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 38f1910..f363ba3 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -2386,6 +2386,10 @@
 const char kVrBrowsingNativeAndroidUiDescription[] =
     "Enable Android UI elements in VR.";
 
+const char kVrBrowsingTabsViewName[] = "VR browsing tabs view";
+const char kVrBrowsingTabsViewDescription[] =
+    "Enable tab overview (tab switcher) in VR.";
+
 const char kThirdPartyDoodlesName[] =
     "Enable Doodles for third-party search engines";
 const char kThirdPartyDoodlesDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index c6461aee5..e6234ed 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -1448,6 +1448,9 @@
 extern const char kVrBrowsingNativeAndroidUiName[];
 extern const char kVrBrowsingNativeAndroidUiDescription[];
 
+extern const char kVrBrowsingTabsViewName[];
+extern const char kVrBrowsingTabsViewDescription[];
+
 extern const char kThirdPartyDoodlesName[];
 extern const char kThirdPartyDoodlesDescription[];
 
diff --git a/chrome/browser/vr/testapp/vr_test_context.cc b/chrome/browser/vr/testapp/vr_test_context.cc
index 5c9f0f02..412e677e 100644
--- a/chrome/browser/vr/testapp/vr_test_context.cc
+++ b/chrome/browser/vr/testapp/vr_test_context.cc
@@ -109,6 +109,7 @@
   keyboard_delegate_ = std::make_unique<TestKeyboardDelegate>();
 
   UiInitialState ui_initial_state;
+  ui_initial_state.create_tabs_view = true;
   ui_ = std::make_unique<Ui>(this, nullptr, keyboard_delegate_.get(),
                              text_input_delegate_.get(), nullptr,
                              ui_initial_state);
diff --git a/chrome/browser/vr/ui.h b/chrome/browser/vr/ui.h
index 0c6cdfc..7aef648 100644
--- a/chrome/browser/vr/ui.h
+++ b/chrome/browser/vr/ui.h
@@ -51,7 +51,6 @@
   bool supports_selection = true;
   bool needs_keyboard_update = false;
   bool is_standalone_vr_device = false;
-  // TODO(crbug.com/838937): Enable tabs.
   bool create_tabs_view = false;
 };