Commit 8d9df63b authored by Fergus Dall's avatar Fergus Dall Committed by Commit Bot

Associate crostini windows and shelf icons with primary profile only

Currently, starting up crostini apps while switching profiles causes
two issues. First, windows other then the terminal are owned by
whichever profile is active when they become visible, not the profile
that owns crostini. Second, if a window becomes visible while it's
owning profile is inactive, then its icon will still be added to the
shelf. On switching to the correct profile, the icon is added
again. If the app is then closed, only one of these shelf entries is
removed, causing crash if the other is used.

As we don't currently support using crostini from non-primary
profiles, this CL fixes the first issue by associating all crostini
app windows with the primary profile, and prevents app icons from
being added to the shelf unless the primary profile is active.

Bug: 846213, 896996, 909590
Change-Id: Ibc888d22eb9567d822ce3e7d1af3603afb02a98e
Reviewed-on: https://chromium-review.googlesource.com/c/1491873Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Fergus Dall <sidereal@google.com>
Cr-Commit-Position: refs/heads/master@{#636675}
parent d6011e17
...@@ -226,12 +226,12 @@ void CrostiniAppWindowShelfController::OnWindowVisibilityChanging( ...@@ -226,12 +226,12 @@ void CrostiniAppWindowShelfController::OnWindowVisibilityChanging(
owner()->GetShelfSpinnerController()->CloseCrostiniSpinners(); owner()->GetShelfSpinnerController()->CloseCrostiniSpinners();
} }
RegisterAppWindow(window, shelf_app_id);
// Prevent Crostini window from showing up after user switch. // Prevent Crostini window from showing up after user switch.
MultiUserWindowManagerClient::GetInstance()->SetWindowOwner( MultiUserWindowManagerClient::GetInstance()->SetWindowOwner(
window, window,
user_manager::UserManager::Get()->GetActiveUser()->GetAccountId()); user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId());
RegisterAppWindow(window, shelf_app_id);
// Move the Crostini app window to the right display if necessary. // Move the Crostini app window to the right display if necessary.
int64_t display_id = crostini_app_display_.GetDisplayIdForAppId(shelf_app_id); int64_t display_id = crostini_app_display_.GetDisplayIdForAppId(shelf_app_id);
...@@ -257,7 +257,16 @@ void CrostiniAppWindowShelfController::RegisterAppWindow( ...@@ -257,7 +257,16 @@ void CrostiniAppWindowShelfController::RegisterAppWindow(
aura_window_to_app_window_[window] = aura_window_to_app_window_[window] =
std::make_unique<AppWindowBase>(shelf_id, widget); std::make_unique<AppWindowBase>(shelf_id, widget);
AppWindowBase* app_window = aura_window_to_app_window_[window].get(); AppWindowBase* app_window = aura_window_to_app_window_[window].get();
AddToShelf(window, app_window);
const AccountId& current_user =
user_manager::UserManager::Get()->GetActiveUser()->GetAccountId();
const AccountId& window_owner =
MultiUserWindowManagerClient::GetInstance()->GetWindowOwner(window);
// Only add an app to the shelf if it's associated with the currently active
// user (which should always be the primary user at this time).
if (current_user == window_owner) {
AddToShelf(window, app_window);
}
} }
void CrostiniAppWindowShelfController::OnWindowDestroying( void CrostiniAppWindowShelfController::OnWindowDestroying(
......
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