Commit ac76759c authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

[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 tonikitoo@igalia.com's patch.

Bug: 578890, 849596
Change-Id: Ib05d2057f1193a9e41580d0133e35dff4bc2ea77
Reviewed-on: https://chromium-review.googlesource.com/1167045
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582087}
parent 9d7e826f
...@@ -198,7 +198,8 @@ include_rules = [ ...@@ -198,7 +198,8 @@ include_rules = [
# Ozone does not run in process. If the linux build transitions to Ozone then # Ozone does not run in process. If the linux build transitions to Ozone then
# we likely need to make these restrictions applicable only to ChromeOS files. # we likely need to make these restrictions applicable only to ChromeOS files.
"-ui/events/ozone", "-ui/events/ozone",
"-ui/ozone", "-ui/ozone/",
"+ui/ozone/public/ozone_platform.h",
"+ui/ozone/public/ozone_switches.h", "+ui/ozone/public/ozone_switches.h",
# ui/events/devices is tied with ozone, which is controlled by mus, and # ui/events/devices is tied with ozone, which is controlled by mus, and
# shouldn't be used by Chrome directly. # shouldn't be used by Chrome directly.
......
...@@ -1742,6 +1742,10 @@ jumbo_split_static_library("ui") { ...@@ -1742,6 +1742,10 @@ jumbo_split_static_library("ui") {
"//ui/events", "//ui/events",
] ]
if (use_ozone && !is_chromeos) {
deps += [ "//ui/ozone" ]
}
if (!toolkit_views) { if (!toolkit_views) {
sources += [ "media_router/cloud_services_dialog.cc" ] sources += [ "media_router/cloud_services_dialog.cc" ]
} }
......
...@@ -88,6 +88,10 @@ ...@@ -88,6 +88,10 @@
#include "chrome/browser/feature_engagement/new_tab/new_tab_tracker_factory.h" #include "chrome/browser/feature_engagement/new_tab/new_tab_tracker_factory.h"
#endif #endif
#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif
using content::NavigationEntry; using content::NavigationEntry;
using content::NavigationController; using content::NavigationController;
using content::WebContents; using content::WebContents;
...@@ -844,7 +848,14 @@ void BrowserCommandController::InitCommandState() { ...@@ -844,7 +848,14 @@ void BrowserCommandController::InitCommandState() {
command_updater_.UpdateCommandEnabled(IDC_MINIMIZE_WINDOW, true); command_updater_.UpdateCommandEnabled(IDC_MINIMIZE_WINDOW, true);
command_updater_.UpdateCommandEnabled(IDC_MAXIMIZE_WINDOW, true); command_updater_.UpdateCommandEnabled(IDC_MAXIMIZE_WINDOW, true);
command_updater_.UpdateCommandEnabled(IDC_RESTORE_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 #endif
command_updater_.UpdateCommandEnabled(IDC_OPEN_IN_PWA_WINDOW, true); command_updater_.UpdateCommandEnabled(IDC_OPEN_IN_PWA_WINDOW, true);
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif
#if defined(USE_X11) #if defined(USE_X11)
#include "ui/base/x/x11_util.h" // nogncheck #include "ui/base/x/x11_util.h" // nogncheck
#endif #endif
...@@ -30,10 +34,18 @@ void RegisterBrowserViewLocalPrefs(PrefRegistrySimple* registry) { ...@@ -30,10 +34,18 @@ void RegisterBrowserViewLocalPrefs(PrefRegistrySimple* registry) {
void RegisterBrowserViewProfilePrefs( void RegisterBrowserViewProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { user_prefs::PrefRegistrySyncable* registry) {
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
bool custom_frame_pref_default = false;
#if defined(USE_X11) #if defined(USE_X11)
registry->RegisterBooleanPref(prefs::kUseCustomChromeFrame, custom_frame_pref_default = ui::GetCustomFramePrefDefault();
ui::GetCustomFramePrefDefault()); #elif defined(USE_OZONE)
custom_frame_pref_default = ui::OzonePlatform::GetInstance()
->GetPlatformProperties()
.custom_frame_pref_default;
#endif #endif
registry->RegisterBooleanPref(prefs::kUseCustomChromeFrame,
custom_frame_pref_default);
#endif // OS_LINUX && !OS_CHROMEOS
} }
void MigrateBrowserTabStripPrefs(PrefService* prefs) { void MigrateBrowserTabStripPrefs(PrefService* prefs) {
......
...@@ -32,7 +32,15 @@ namespace { ...@@ -32,7 +32,15 @@ namespace {
class OzonePlatformWayland : public OzonePlatform { class OzonePlatformWayland : public OzonePlatform {
public: public:
OzonePlatformWayland() {} OzonePlatformWayland() {
// Supporting server-side decorations requires a support of xdg-decorations.
// But this protocol has been accepted into the upstream recently, and it
// will take time before it is taken by compositors. For now, always use
// custom frames and disallow switching to server-side frames.
// https://github.com/wayland-project/wayland-protocols/commit/76d1ae8c65739eff3434ef219c58a913ad34e988
properties_.custom_frame_pref_default = true;
properties_.use_system_title_bar = false;
}
~OzonePlatformWayland() override {} ~OzonePlatformWayland() override {}
// OzonePlatform // OzonePlatform
...@@ -110,6 +118,10 @@ class OzonePlatformWayland : public OzonePlatform { ...@@ -110,6 +118,10 @@ class OzonePlatformWayland : public OzonePlatform {
} }
} }
const PlatformProperties& GetPlatformProperties() override {
return properties_;
}
private: private:
std::unique_ptr<WaylandConnection> connection_; std::unique_ptr<WaylandConnection> connection_;
std::unique_ptr<WaylandSurfaceFactory> surface_factory_; std::unique_ptr<WaylandSurfaceFactory> surface_factory_;
...@@ -122,6 +134,8 @@ class OzonePlatformWayland : public OzonePlatform { ...@@ -122,6 +134,8 @@ class OzonePlatformWayland : public OzonePlatform {
XkbEvdevCodes xkb_evdev_code_converter_; XkbEvdevCodes xkb_evdev_code_converter_;
#endif #endif
PlatformProperties properties_;
DISALLOW_COPY_AND_ASSIGN(OzonePlatformWayland); DISALLOW_COPY_AND_ASSIGN(OzonePlatformWayland);
}; };
......
...@@ -20,9 +20,7 @@ bool g_platform_initialized_gpu = false; ...@@ -20,9 +20,7 @@ bool g_platform_initialized_gpu = false;
base::LazyInstance<base::OnceCallback<void(OzonePlatform*)>>::Leaky base::LazyInstance<base::OnceCallback<void(OzonePlatform*)>>::Leaky
instance_callback = LAZY_INSTANCE_INITIALIZER; instance_callback = LAZY_INSTANCE_INITIALIZER;
constexpr OzonePlatform::PlatformProperties kDefaultPlatformProperties = { constexpr OzonePlatform::PlatformProperties kDefaultPlatformProperties;
/*needs_view_owner_request=*/false,
};
base::Lock& GetOzoneInstanceLock() { base::Lock& GetOzoneInstanceLock() {
static base::Lock lock; static base::Lock lock;
......
...@@ -86,7 +86,15 @@ class OZONE_EXPORT OzonePlatform { ...@@ -86,7 +86,15 @@ class OZONE_EXPORT OzonePlatform {
// Fuchsia only: set to true when the platforms requires // Fuchsia only: set to true when the platforms requires
// |view_owner_request| field in PlatformWindowInitProperties when creating // |view_owner_request| field in PlatformWindowInitProperties when creating
// a window. // a window.
bool needs_view_owner_request; bool needs_view_owner_request = false;
// Determine whether we should default to native decorations or the custom
// frame based on the currently-running window manager.
bool custom_frame_pref_default = false;
// Determine whether switching between system and custom frames is
// supported.
bool use_system_title_bar = false;
}; };
// Ensures the OzonePlatform instance without doing any initialization. // Ensures the OzonePlatform instance without doing any initialization.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment