Commit a4d9c53e authored by khmel's avatar khmel Committed by Commit bot

arc: Prevent showing Arc app window for secondary user profile.

Arc has a limitation to be visible for primary profile only. However,
there are situations when Arc task can be started while the secondary
profile is shown. Before this led to case when Arc window was shown,
which is unexpected. This CL fixes this issue and prevents showing Arc
window for non-primary profiles.

Test=Manually on the device. Start Arc app in deferred mode and switch
     to the secondary profile fast. Arc app is started but window is not
     shown. Switch back to primary profile and window is automatically
     restored there.
BUG=b/31500778
BUG=647379

Review-Url: https://codereview.chromium.org/2345043002
Cr-Commit-Position: refs/heads/master@{#419497}
parent 37151e94
......@@ -131,7 +131,7 @@ void ArcAppDeferredLauncherController::OnAppReadyChanged(
Close(app_id);
arc::LaunchApp(owner_->GetProfile(), app_id);
arc::LaunchApp(observed_profile_, app_id);
}
void ArcAppDeferredLauncherController::OnAppRemoved(const std::string& app_id) {
......
......@@ -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()) {
......
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