[ozone/wayland] Fix crash when right-clicking on the window decoration area.

On chrome/x11, right-clicking on the window decoration bar toggles a
context menu whose one of the menu items allows switching between
builtin and system/native window decorations.

Today, chrome/ozone/wayland crashes when building the menu because it tried to
read a preference only registered in use_x11: kUseCustomChromeFrame.

So this CL does two things:

- registers the preference [1] based on PlatformProperties in case of USE_OZONE.

- checks whether using system title bar[2] is supported by underlying ozone platform.
By default, ozone platforms have this feature disabled.

[1] kUseCustomChromeFrame
[2] IDC_USE_SYSTEM_TITLE_BAR

Based on [email protected]'s patch.

Bug: 578890, 849596
Change-Id: Ib05d2057f1193a9e41580d0133e35dff4bc2ea77
Reviewed-on: https://chromium-review.googlesource.com/1167045
Commit-Queue: Maksim Sisov <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Cr-Commit-Position: refs/heads/master@{#582087}
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc
index 9b551948..af26865 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -88,6 +88,10 @@
 #include "chrome/browser/feature_engagement/new_tab/new_tab_tracker_factory.h"
 #endif
 
+#if defined(USE_OZONE)
+#include "ui/ozone/public/ozone_platform.h"
+#endif
+
 using content::NavigationEntry;
 using content::NavigationController;
 using content::WebContents;
@@ -844,7 +848,14 @@
   command_updater_.UpdateCommandEnabled(IDC_MINIMIZE_WINDOW, true);
   command_updater_.UpdateCommandEnabled(IDC_MAXIMIZE_WINDOW, true);
   command_updater_.UpdateCommandEnabled(IDC_RESTORE_WINDOW, true);
-  command_updater_.UpdateCommandEnabled(IDC_USE_SYSTEM_TITLE_BAR, true);
+  bool use_system_title_bar = true;
+#if defined(USE_OZONE)
+  use_system_title_bar = ui::OzonePlatform::GetInstance()
+                             ->GetPlatformProperties()
+                             .use_system_title_bar;
+#endif
+  command_updater_.UpdateCommandEnabled(IDC_USE_SYSTEM_TITLE_BAR,
+                                        use_system_title_bar);
 #endif
   command_updater_.UpdateCommandEnabled(IDC_OPEN_IN_PWA_WINDOW, true);