Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4789)

Unified Diff: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc

Issue 74363004: Switching to the correct desktop when a system modal dialog gets shown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing unit test Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
index 2b8890cfb3e4d949d9f530fdcb5560fa28987660..824ddf7539024c52588c85ee935c6a1315f9da47 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
+++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc
@@ -11,6 +11,7 @@
#include "ash/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
+#include "ash/shell_window_ids.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/window_positioner.h"
#include "ash/wm/window_state.h"
@@ -467,6 +468,31 @@ void MultiUserWindowManagerChromeOS::SetWindowVisibility(
if (window->IsVisible() == visible)
return;
+ // Hiding a system modal dialog should not be allowed. Instead we switch to
+ // the user which is showing the system modal window.
+ // Note that in some cases (e.g. unit test) windows might not have a root
+ // window.
+ if (!visible && window->GetRootWindow()) {
+ // Get the system modal container for the window's root window.
+ aura::Window* system_modal_container =
+ window->GetRootWindow()->GetChildById(
+ ash::internal::kShellWindowId_SystemModalContainer);
+ if (window->parent() == system_modal_container) {
+ // The window is system modal and we need to find the parent which owns
+ // it so that we can switch to the desktop accordingly.
+ std::string user_id = GetUserPresentingWindow(window);
+ if (user_id.empty()) {
+ aura::Window* owning_window = GetOwningWindowInTransientChain(window);
+ DCHECK(owning_window);
+ user_id = GetUserPresentingWindow(owning_window);
+ DCHECK(!user_id.empty());
+ }
+ ash::Shell::GetInstance()->session_state_delegate()->SwitchActiveUser(
+ user_id);
+ return;
+ }
+ }
+
// To avoid that these commands are recorded as any other commands, we are
// suppressing any window entry changes while this is going on.
base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true);

Powered by Google App Engine
This is Rietveld 408576698