Commit fd46f03c authored by Nicholas Hollingum's avatar Nicholas Hollingum Committed by Commit Bot

Wiring up the shell surface and crostini

For more information on the crostini force-close UI, see
crbug.com/964162.

To provide a force-close UI to crostini windows which don't respond.
We use a window property, set by the shell surface, and look for that
property during crostini window registration.

See crrev.com/c/1776140 for the changes that allow us to know when a
shell surface is attempting to close.

This CL shows how we will wire those up. The actual UI work will be
done in a separate CL.

Bug: 914322, 964162
Change-Id: Ieafd9bbaf8fe49e3411f4f76dabe52b63d7e784b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1775884
Commit-Queue: Nic Hollingum <hollingum@google.com>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694991}
parent ca327247
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_features.h"
#include "components/arc/arc_util.h" #include "components/arc/arc_util.h"
#include "components/exo/shell_surface_util.h" #include "components/exo/shell_surface_util.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
...@@ -208,6 +209,10 @@ void CrostiniAppWindowShelfController::OnWindowVisibilityChanging( ...@@ -208,6 +209,10 @@ void CrostiniAppWindowShelfController::OnWindowVisibilityChanging(
if (shelf_app_id.empty()) if (shelf_app_id.empty())
return; return;
// At this point, all remaining windows are Crostini windows. Firstly, we add
// support for forcibly closing it.
RegisterCrostiniWindowForForceClose(window);
// Failed to uniquely identify the Crostini app that this window is for. // Failed to uniquely identify the Crostini app that this window is for.
// The spinners on the shelf have internal app IDs which are valid // The spinners on the shelf have internal app IDs which are valid
// extensions IDs. If the ID here starts with "crostini:" then it implies // extensions IDs. If the ID here starts with "crostini:" then it implies
...@@ -321,6 +326,16 @@ void CrostiniAppWindowShelfController::UnregisterAppWindow( ...@@ -321,6 +326,16 @@ void CrostiniAppWindowShelfController::UnregisterAppWindow(
app_window->SetController(nullptr); app_window->SetController(nullptr);
} }
void CrostiniAppWindowShelfController::RegisterCrostiniWindowForForceClose(
aura::Window* window) {
if (!base::FeatureList::IsEnabled(features::kCrostiniForceClose))
return;
exo::ShellSurfaceBase* surface = exo::GetShellSurfaceBaseForWindow(window);
if (!surface)
return;
// TODO(hollingum): force close stuff goes here.
}
void CrostiniAppWindowShelfController::OnItemDelegateDiscarded( void CrostiniAppWindowShelfController::OnItemDelegateDiscarded(
ash::ShelfItemDelegate* delegate) { ash::ShelfItemDelegate* delegate) {
for (auto& it : aura_window_to_app_window_) { for (auto& it : aura_window_to_app_window_) {
......
...@@ -61,6 +61,7 @@ class CrostiniAppWindowShelfController : public AppWindowLauncherController, ...@@ -61,6 +61,7 @@ class CrostiniAppWindowShelfController : public AppWindowLauncherController,
void RegisterAppWindow(aura::Window* window, const std::string& shelf_app_id); void RegisterAppWindow(aura::Window* window, const std::string& shelf_app_id);
void UnregisterAppWindow(AppWindowBase* app_window); void UnregisterAppWindow(AppWindowBase* app_window);
void AddToShelf(aura::Window* window, AppWindowBase* app_window); void AddToShelf(aura::Window* window, AppWindowBase* app_window);
void RegisterCrostiniWindowForForceClose(aura::Window* window);
// Returns ID of the shelf item that is removed, or a null id. // Returns ID of the shelf item that is removed, or a null id.
ash::ShelfID RemoveFromShelf(aura::Window* window, AppWindowBase* app_window); ash::ShelfID RemoveFromShelf(aura::Window* window, AppWindowBase* app_window);
......
...@@ -202,6 +202,10 @@ const base::Feature kCrostiniAnsibleInfrastructure{ ...@@ -202,6 +202,10 @@ const base::Feature kCrostiniAnsibleInfrastructure{
const base::Feature kCrostiniAnsibleSoftwareManagement{ const base::Feature kCrostiniAnsibleSoftwareManagement{
"CrostiniAnsibleSoftwareManagement", base::FEATURE_DISABLED_BY_DEFAULT}; "CrostiniAnsibleSoftwareManagement", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables custom UI for forcibly closing unresponsive windows.
const base::Feature kCrostiniForceClose{"CrostiniForceClose",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables or disables the UI overhaul for Cups Printers in settings page. // Enables or disables the UI overhaul for Cups Printers in settings page.
const base::Feature kCupsPrintersUiOverhaul{"CupsPrintersUiOverhaul", const base::Feature kCupsPrintersUiOverhaul{"CupsPrintersUiOverhaul",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
......
...@@ -127,6 +127,8 @@ extern const base::Feature kCrostiniAnsibleInfrastructure; ...@@ -127,6 +127,8 @@ extern const base::Feature kCrostiniAnsibleInfrastructure;
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kCrostiniAnsibleSoftwareManagement; extern const base::Feature kCrostiniAnsibleSoftwareManagement;
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kCrostiniForceClose;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kCupsPrintersUiOverhaul; extern const base::Feature kCupsPrintersUiOverhaul;
COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kPluginVm; COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kPluginVm;
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "components/exo/shell_surface_util.h" #include "components/exo/shell_surface_util.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "components/exo/shell_surface_base.h"
#include "components/exo/surface.h" #include "components/exo/surface.h"
#include "components/exo/wm_helper.h" #include "components/exo/wm_helper.h"
#include "ui/aura/client/capture_client.h" #include "ui/aura/client/capture_client.h"
...@@ -63,6 +64,16 @@ Surface* GetShellMainSurface(const aura::Window* window) { ...@@ -63,6 +64,16 @@ Surface* GetShellMainSurface(const aura::Window* window) {
return window->GetProperty(kMainSurfaceKey); return window->GetProperty(kMainSurfaceKey);
} }
ShellSurfaceBase* GetShellSurfaceBaseForWindow(aura::Window* window) {
// Only windows with a surface can have a shell surface.
if (!GetShellMainSurface(window))
return nullptr;
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
if (!widget)
return nullptr;
return static_cast<ShellSurfaceBase*>(widget->widget_delegate());
}
Surface* GetTargetSurfaceForLocatedEvent(ui::LocatedEvent* event) { Surface* GetTargetSurfaceForLocatedEvent(ui::LocatedEvent* event) {
aura::Window* window = aura::Window* window =
WMHelper::GetInstance()->GetCaptureClient()->GetCaptureWindow(); WMHelper::GetInstance()->GetCaptureClient()->GetCaptureWindow();
......
...@@ -20,6 +20,7 @@ class LocatedEvent; ...@@ -20,6 +20,7 @@ class LocatedEvent;
namespace exo { namespace exo {
class Surface; class Surface;
class ShellSurfaceBase;
// Sets the application ID for the window. The application ID identifies the // Sets the application ID for the window. The application ID identifies the
// general class of applications to which the window belongs. // general class of applications to which the window belongs.
...@@ -40,6 +41,10 @@ void SetShellMainSurface(aura::Window* window, Surface* surface); ...@@ -40,6 +41,10 @@ void SetShellMainSurface(aura::Window* window, Surface* surface);
// |window| must not be nullptr. // |window| must not be nullptr.
Surface* GetShellMainSurface(const aura::Window* window); Surface* GetShellMainSurface(const aura::Window* window);
// Returns the ShellSurfaceBase for the given |window|, or nullptr if no such
// surface exists.
ShellSurfaceBase* GetShellSurfaceBaseForWindow(aura::Window* window);
// Returns the target surface for the located event |event|. If an // Returns the target surface for the located event |event|. If an
// event handling is grabbed by an window, it'll first examine that // event handling is grabbed by an window, it'll first examine that
// window, then traverse to its transient parent if the parent also // window, then traverse to its transient parent if the parent also
......
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