Crostini: Add flag to turn on the Qt IM module and plumb to garcon

Similar to the VK flag, this depends on the main (GTK) Crostini IME
flag to be enabled, as that is required to set up exo appropriately.

Also update description of #crostini-ime-support flag to mention it
is only for GTK3(/Electron) apps.

Bug: b/232048947
Change-Id: Ib9a34c9b026dcad3223fe6823fc241fff47a8735
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4546452
Commit-Queue: Timothy Loh <timloh@chromium.org>
Reviewed-by: Sophia Lin <sophialin@google.com>
Cr-Commit-Position: refs/heads/main@{#1147059}
diff --git a/ash/constants/ash_features.cc b/ash/constants/ash_features.cc
index 29617de2..fea228c 100644
--- a/ash/constants/ash_features.cc
+++ b/ash/constants/ash_features.cc
@@ -411,6 +411,11 @@
              "CrostiniImeSupport",
              base::FEATURE_ENABLED_BY_DEFAULT);
 
+// Enables or disables Crostini Qt application IME support.
+BASE_FEATURE(kCrostiniQtImeSupport,
+             "CrostiniQtImeSupport",
+             base::FEATURE_DISABLED_BY_DEFAULT);
+
 // Enables or disables Crostini Virtual Keyboard support.
 BASE_FEATURE(kCrostiniVirtualKeyboardSupport,
              "CrostiniVirtualKeyboardSupport",
diff --git a/ash/constants/ash_features.h b/ash/constants/ash_features.h
index 45bb7ce..42827bf 100644
--- a/ash/constants/ash_features.h
+++ b/ash/constants/ash_features.h
@@ -118,6 +118,7 @@
 COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kCrostiniResetLxdDb);
 COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kCrostiniMultiContainer);
 COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kCrostiniImeSupport);
+COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kCrostiniQtImeSupport);
 COMPONENT_EXPORT(ASH_CONSTANTS)
 BASE_DECLARE_FEATURE(kCrostiniVirtualKeyboardSupport);
 COMPONENT_EXPORT(ASH_CONSTANTS) BASE_DECLARE_FEATURE(kBruschetta);
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index a6b28c8..90873d87 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -4657,6 +4657,9 @@
     {"crostini-ime-support", flag_descriptions::kCrostiniImeSupportName,
      flag_descriptions::kCrostiniImeSupportDescription, kOsCrOS,
      FEATURE_VALUE_TYPE(ash::features::kCrostiniImeSupport)},
+    {"crostini-qt-ime-support", flag_descriptions::kCrostiniQtImeSupportName,
+     flag_descriptions::kCrostiniQtImeSupportDescription, kOsCrOS,
+     FEATURE_VALUE_TYPE(ash::features::kCrostiniQtImeSupport)},
     {"crostini-virtual-keyboard-support",
      flag_descriptions::kCrostiniVirtualKeyboardSupportName,
      flag_descriptions::kCrostiniVirtualKeyboardSupportDescription, kOsCrOS,
diff --git a/chrome/browser/ash/crostini/crostini_util.cc b/chrome/browser/ash/crostini/crostini_util.cc
index 664e7b6a..8c9b62e4 100644
--- a/chrome/browser/ash/crostini/crostini_util.cc
+++ b/chrome/browser/ash/crostini/crostini_util.cc
@@ -351,6 +351,10 @@
   if (base::FeatureList::IsEnabled(ash::features::kCrostiniImeSupport)) {
     result.push_back(
         vm_tools::cicerone::ContainerFeature::ENABLE_GTK3_IME_SUPPORT);
+    if (base::FeatureList::IsEnabled(ash::features::kCrostiniQtImeSupport)) {
+      result.push_back(
+          vm_tools::cicerone::ContainerFeature::ENABLE_QT_IME_SUPPORT);
+    }
     if (base::FeatureList::IsEnabled(
             ash::features::kCrostiniVirtualKeyboardSupport)) {
       result.push_back(vm_tools::cicerone::ContainerFeature::
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index 71d85c6..eed48bbe 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -1311,6 +1311,11 @@
     "expiry_milestone": 130
   },
   {
+    "name": "crostini-qt-ime-support",
+    "owners": [ "timloh", "sophialin@google.com" ],
+    "expiry_milestone": 124
+  },
+  {
     "name": "crostini-reset-lxd-db",
     "owners": [ "davidmunro@google.com", "nverne", "sidereal" ],
     "expiry_milestone": 120
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index c3363a4..972bc34 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -5415,7 +5415,14 @@
 
 const char kCrostiniImeSupportName[] = "Crostini IME support";
 const char kCrostiniImeSupportDescription[] =
-    "Experimental support for IMEs (excluding VK) on Crostini.";
+    "Support for IMEs (excluding VK) in Crostini for applications built with "
+    "GTK3 or Electron.";
+
+const char kCrostiniQtImeSupportName[] =
+    "Crostini IME support for Qt applications";
+const char kCrostiniQtImeSupportDescription[] =
+    "Experimental support for IMEs (excluding VK) in Crostini for applications "
+    "built with Qt. Requires #crostini-ime-support to be enabled.";
 
 const char kCrostiniVirtualKeyboardSupportName[] =
     "Crostini Virtual Keyboard Support";
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index f7b15dc1..84719d3 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -3106,6 +3106,9 @@
 extern const char kCrostiniImeSupportName[];
 extern const char kCrostiniImeSupportDescription[];
 
+extern const char kCrostiniQtImeSupportName[];
+extern const char kCrostiniQtImeSupportDescription[];
+
 extern const char kCrostiniVirtualKeyboardSupportName[];
 extern const char kCrostiniVirtualKeyboardSupportDescription[];
 
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 52feb16..62d92157 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -61492,6 +61492,7 @@
   <int value="-648925189" label="ExploreSites:enabled"/>
   <int value="-648593261" label="Memories:enabled"/>
   <int value="-648383814" label="WebViewXRequestedWithHeaderControl:disabled"/>
+  <int value="-647223968" label="CrostiniQtImeSupport:enabled"/>
   <int value="-645772961" label="EnableFakeKeyboardHeuristic:enabled"/>
   <int value="-645455405" label="MacViewsNativeDialogs:enabled"/>
   <int value="-644550997"
@@ -66532,6 +66533,7 @@
   <int value="2035351945" label="lacros-selection-policy-ignore"/>
   <int value="2035415906" label="Win11StyleMenus:enabled"/>
   <int value="2035524582" label="WebViewRecordAppDataDirectorySize:disabled"/>
+  <int value="2037407406" label="CrostiniQtImeSupport:disabled"/>
   <int value="2037562553" label="OmniboxBubbleUrlSuggestions:disabled"/>
   <int value="2037623368" label="attribution-reporting-debug-mode"/>
   <int value="2037756154" label="enable-impl-side-painting"/>