| Index: chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
|
| diff --git a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
|
| index 5038c15ee2d7e8662ad46f5b51cf017612bf5050..025640f360b473ab453a092306bd18b6b27d0e50 100644
|
| --- a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
|
| +++ b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
|
| @@ -87,6 +87,18 @@ blink::WebScreenOrientationLockType BlinkOrientationLockFromMojom(
|
| }
|
| }
|
|
|
| +int GetWindowTaskId(aura::Window* window) {
|
| + const std::string window_app_id = exo::ShellSurface::GetApplicationId(window);
|
| + if (window_app_id.empty())
|
| + return -1;
|
| +
|
| + int task_id = -1;
|
| + if (sscanf(window_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1)
|
| + return -1;
|
| +
|
| + return task_id;
|
| +}
|
| +
|
| } // namespace
|
|
|
| class ArcAppWindowLauncherController::AppWindow : public ui::BaseWindow {
|
| @@ -292,6 +304,14 @@ void ArcAppWindowLauncherController::OnWindowInitialized(aura::Window* window) {
|
| void ArcAppWindowLauncherController::OnWindowVisibilityChanged(
|
| aura::Window* window,
|
| bool visible) {
|
| + // Attach window to multi-user manager now to let it manage visibility state
|
| + // of the Arc window correctly.
|
| + if (GetWindowTaskId(window) > 0) {
|
| + chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner(
|
| + window,
|
| + user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId());
|
| + }
|
| +
|
| // The application id property should be set at this time. It is important to
|
| // have window->IsVisible set to true before attaching to a controller because
|
| // the window is registered in multi-user manager and this manager may
|
| @@ -337,15 +357,8 @@ void ArcAppWindowLauncherController::AttachControllerToWindowsIfNeeded() {
|
|
|
| void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded(
|
| aura::Window* window) {
|
| - const std::string window_app_id = exo::ShellSurface::GetApplicationId(window);
|
| - if (window_app_id.empty())
|
| - return;
|
| -
|
| - int task_id = -1;
|
| - if (sscanf(window_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1)
|
| - return;
|
| -
|
| - if (!task_id)
|
| + const int task_id = GetWindowTaskId(window);
|
| + if (task_id <= 0)
|
| return;
|
|
|
| // We need to add the observer after exo started observing shell
|
| @@ -375,9 +388,6 @@ void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded(
|
| DCHECK(app_window->controller());
|
| ash::WmWindowAura::Get(window)->SetIntProperty(
|
| ash::WmWindowProperty::SHELF_ID, app_window->shelf_id());
|
| - chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner(
|
| - window,
|
| - user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId());
|
| if (ash::WmShell::Get()
|
| ->maximize_mode_controller()
|
| ->IsMaximizeModeWindowManagerEnabled()) {
|
|
|