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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" 5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
6 6
7 #include "apps/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/multi_profile_uma.h" 10 #include "ash/multi_profile_uma.h"
11 #include "ash/session_state_delegate.h" 11 #include "ash/session_state_delegate.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/shell_delegate.h" 13 #include "ash/shell_delegate.h"
14 #include "ash/shell_window_ids.h"
14 #include "ash/wm/mru_window_tracker.h" 15 #include "ash/wm/mru_window_tracker.h"
15 #include "ash/wm/window_positioner.h" 16 #include "ash/wm/window_positioner.h"
16 #include "ash/wm/window_state.h" 17 #include "ash/wm/window_state.h"
17 #include "base/auto_reset.h" 18 #include "base/auto_reset.h"
18 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
19 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
20 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/chromeos/login/user_manager.h" 23 #include "chrome/browser/chromeos/login/user_manager.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 return; 461 return;
461 SetWindowOwner(browser->window()->GetNativeWindow(), 462 SetWindowOwner(browser->window()->GetNativeWindow(),
462 multi_user_util::GetUserIDFromProfile(browser->profile())); 463 multi_user_util::GetUserIDFromProfile(browser->profile()));
463 } 464 }
464 465
465 void MultiUserWindowManagerChromeOS::SetWindowVisibility( 466 void MultiUserWindowManagerChromeOS::SetWindowVisibility(
466 aura::Window* window, bool visible) { 467 aura::Window* window, bool visible) {
467 if (window->IsVisible() == visible) 468 if (window->IsVisible() == visible)
468 return; 469 return;
469 470
471 // Hiding a system modal dialog should not be allowed. Instead we switch to
472 // the user which is showing the system modal window.
473 // Note that in some cases (e.g. unit test) windows might not have a root
474 // window.
475 if (!visible && window->GetRootWindow()) {
476 // Get the system modal container for the window's root window.
477 aura::Window* system_modal_container =
478 window->GetRootWindow()->GetChildById(
479 ash::internal::kShellWindowId_SystemModalContainer);
480 if (window->parent() == system_modal_container) {
481 // The window is system modal and we need to find the parent which owns
482 // it so that we can switch to the desktop accordingly.
483 std::string user_id = GetUserPresentingWindow(window);
484 if (user_id.empty()) {
485 aura::Window* owning_window = GetOwningWindowInTransientChain(window);
486 DCHECK(owning_window);
487 user_id = GetUserPresentingWindow(owning_window);
488 DCHECK(!user_id.empty());
489 }
490 ash::Shell::GetInstance()->session_state_delegate()->SwitchActiveUser(
491 user_id);
492 return;
493 }
494 }
495
470 // To avoid that these commands are recorded as any other commands, we are 496 // To avoid that these commands are recorded as any other commands, we are
471 // suppressing any window entry changes while this is going on. 497 // suppressing any window entry changes while this is going on.
472 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); 498 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true);
473 499
474 if (visible) { 500 if (visible) {
475 ShowWithTransientChildrenRecursive(window); 501 ShowWithTransientChildrenRecursive(window);
476 } else { 502 } else {
477 if (window->HasFocus()) 503 if (window->HasFocus())
478 window->Blur(); 504 window->Blur();
479 window->Hide(); 505 window->Hide();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // To prevent these commands from being recorded as any other commands, we 584 // To prevent these commands from being recorded as any other commands, we
559 // are suppressing any window entry changes while this is going on. 585 // are suppressing any window entry changes while this is going on.
560 // Instead of calling SetWindowVisible, only show gets called here since all 586 // Instead of calling SetWindowVisible, only show gets called here since all
561 // dependents have been shown previously already. 587 // dependents have been shown previously already.
562 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); 588 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true);
563 window->Show(); 589 window->Show();
564 } 590 }
565 } 591 }
566 592
567 } // namespace chrome 593 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698