Commit 3c715241 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

fix crostini app icon weirdness in SingleProcessMash

This CL made a short-term fix for crostini app icons when
SingleProcessMash is enabled. The observed problems are:
- the terminal app icon has the spinner (rotating cycle) on launch,
  but the spinner doesn't disappear when the terminal is ready
- other app icons (like gedit) create two app icons, one is the
  expected one and the other is the blank icon

The terminal app is a chrome app (hosted by browser), however
CrostiniAppWindowShelfController observes aura::Env in ash::Shell,
thus it will fail to obtain Browser object. It needs to aura::Env
in the browser.

The blank icon is created by ash::ShelfWindowWatcher; to prevent
this, kShelfItemTypeKey property needs to be set as
ArcAppWindowLauncherController does.

This is kinda hacky and does not work with multi-process Mash.
We will eventually need a major refactoring around the shelf and
the launcher.

Bug: 905802
Test: manually
Change-Id: If941bcc100160d3b5ff6e590032153000efc674a
Reviewed-on: https://chromium-review.googlesource.com/c/1371144
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615983}
parent 9069c243
......@@ -69,17 +69,28 @@ CrostiniAppWindowShelfController::CrostiniAppWindowShelfController(
// https://crbug.com/887156
if (!features::IsMultiProcessMash())
ash::Shell::Get()->aura_env()->AddObserver(this);
// When window service is enabled, aura::Env::GetInstance() is a different
// instance from ash::Shell::Get()->aura_env(), and it needs to be observed
// for the Crostini terminal, which is a Chrome app window. Note that it still
// needs to observe ash::Shell::Get()->aura_env() too for other crostini apps,
// which are hosted by exo.
// TODO(mukai): clean this up. https://crbug.com/887156
if (features::IsUsingWindowService())
aura::Env::GetInstance()->AddObserver(this);
}
CrostiniAppWindowShelfController::~CrostiniAppWindowShelfController() {
for (auto* window : observed_windows_)
window->RemoveObserver(this);
if (features::IsUsingWindowService())
aura::Env::GetInstance()->RemoveObserver(this);
if (!features::IsMultiProcessMash())
ash::Shell::Get()->aura_env()->RemoveObserver(this);
}
void CrostiniAppWindowShelfController::AddToShelf(aura::Window* window,
AppWindowBase* app_window) {
window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_APP);
ash::ShelfID shelf_id = app_window->shelf_id();
AppWindowLauncherItemController* item_controller =
owner()->shelf_model()->GetAppWindowLauncherItemController(shelf_id);
......
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