[remoting host][linux] Use XVFB when dependencies are not satisfied

The CRD debian package now has the following dependencies:

  xserver-xorg-video-dummy (>= 1:0.4.0), xserver-xorg-input-void

These are not satisfiable in Debian stable (Debian 11 "bullseye"), as
only xserver-xorg-video-dummy 1:0.3.8-1 is available, and
xserver-xorg-input-void has bee removed.

This CL works around this issue by making these two dependencies
"Recommended", and updating the host daemon script so that it falls back
to XVFB if the dependencies are not satisfied.

Bug: 1366595
Change-Id: I0a8d6361e05bf7587ef713c0c780d346194694c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3912622
Reviewed-by: Lambros Lambrou <[email protected]>
Commit-Queue: Yuwei Huang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1050413}
diff --git a/remoting/host/me2me_desktop_environment.cc b/remoting/host/me2me_desktop_environment.cc
index 45c4bd32..bbb4552 100644
--- a/remoting/host/me2me_desktop_environment.cc
+++ b/remoting/host/me2me_desktop_environment.cc
@@ -7,6 +7,7 @@
 #include <memory>
 #include <utility>
 
+#include "base/environment.h"
 #include "base/logging.h"
 #include "base/memory/ptr_util.h"
 #include "base/task/single_thread_task_runner.h"
@@ -38,6 +39,16 @@
 
 namespace remoting {
 
+namespace {
+
+#if BUILDFLAG(IS_LINUX)
+
+constexpr char kUseXvfbEnvVar[] = "CHROME_REMOTE_DESKTOP_USE_XVFB";
+
+#endif  // BUILDFLAG(IS_LINUX)
+
+}  // namespace
+
 Me2MeDesktopEnvironment::~Me2MeDesktopEnvironment() {
   DCHECK(caller_task_runner()->BelongsToCurrentThread());
 }
@@ -104,12 +115,19 @@
   }
 
 #if BUILDFLAG(IS_LINUX)
-  capabilities += " ";
-  capabilities += protocol::kMultiStreamCapability;
+  // Multi-stream and client-controlled layout are only supported with
+  // Xorg+Dummy.
+  // TODO(crbug.com/1366595): Either just remove this check if the dependency
+  // issue is resolved in Debian stable, or make it smarter, such as checking if
+  // the randr output has DUMMY*.
+  if (!base::Environment::Create()->HasVar(kUseXvfbEnvVar)) {
+    capabilities += " ";
+    capabilities += protocol::kMultiStreamCapability;
 #if defined(REMOTING_USE_X11)
-  capabilities += " ";
-  capabilities += protocol::kClientControlledLayoutCapability;
+    capabilities += " ";
+    capabilities += protocol::kClientControlledLayoutCapability;
 #endif  // defined(REMOTING_USE_X11)
+  }
 #endif  // BUILDFLAG(IS_LINUX)
 
   return capabilities;