Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/root_window_controller.h" | |
| 11 #include "ash/session_state_delegate.h" | 12 #include "ash/session_state_delegate.h" |
| 12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 13 #include "ash/shell_delegate.h" | 14 #include "ash/shell_delegate.h" |
| 15 #include "ash/shell_window_ids.h" | |
| 14 #include "ash/wm/mru_window_tracker.h" | 16 #include "ash/wm/mru_window_tracker.h" |
| 15 #include "ash/wm/window_positioner.h" | 17 #include "ash/wm/window_positioner.h" |
| 16 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
| 17 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
| 18 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
| 19 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 20 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/chromeos/login/user_manager.h" | 24 #include "chrome/browser/chromeos/login/user_manager.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 return; | 462 return; |
| 461 SetWindowOwner(browser->window()->GetNativeWindow(), | 463 SetWindowOwner(browser->window()->GetNativeWindow(), |
| 462 multi_user_util::GetUserIDFromProfile(browser->profile())); | 464 multi_user_util::GetUserIDFromProfile(browser->profile())); |
| 463 } | 465 } |
| 464 | 466 |
| 465 void MultiUserWindowManagerChromeOS::SetWindowVisibility( | 467 void MultiUserWindowManagerChromeOS::SetWindowVisibility( |
| 466 aura::Window* window, bool visible) { | 468 aura::Window* window, bool visible) { |
| 467 if (window->IsVisible() == visible) | 469 if (window->IsVisible() == visible) |
| 468 return; | 470 return; |
| 469 | 471 |
| 472 // Hiding a system modal dialog should not be allowed. Instead we switch to | |
| 473 // the user which is showing the system modal window. | |
| 474 if (!visible) { | |
| 475 // Get the system modal container for the window's root window. | |
| 476 ash::internal::RootWindowController* controller = | |
|
sky
2013/11/16 00:34:55
Classes in internal namespaces shouldn't be used o
Mr4D (OOO till 08-26)
2013/11/16 00:54:27
Done.
| |
| 477 ash::internal::GetRootWindowController(window->GetRootWindow()); | |
| 478 aura::Window* system_modal_container = | |
| 479 controller->GetContainer( | |
| 480 ash::internal::kShellWindowId_SystemModalContainer); | |
| 481 if (window->parent() == system_modal_container) { | |
| 482 // The window is system modal and we need to find the parent which owns | |
| 483 // it so that we can switch to the desktop accordingly. | |
| 484 std::string user_id = GetUserPresentingWindow(window); | |
| 485 if (user_id.empty()) { | |
| 486 aura::Window* owning_window = GetOwningWindowInTransientChain(window); | |
| 487 if (owning_window) | |
|
sky
2013/11/16 00:34:55
Should this be a DCHECK? Otherwise you know 490 is
Mr4D (OOO till 08-26)
2013/11/16 00:54:27
Done.
| |
| 488 user_id = GetUserPresentingWindow(owning_window); | |
| 489 } | |
| 490 DCHECK(!user_id.empty()); | |
| 491 ash::Shell::GetInstance()->session_state_delegate()->SwitchActiveUser( | |
| 492 user_id); | |
| 493 return; | |
| 494 } | |
| 495 } | |
| 496 | |
| 470 // To avoid that these commands are recorded as any other commands, we are | 497 // To avoid that these commands are recorded as any other commands, we are |
| 471 // suppressing any window entry changes while this is going on. | 498 // suppressing any window entry changes while this is going on. |
| 472 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); | 499 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); |
| 473 | 500 |
| 474 if (visible) { | 501 if (visible) { |
| 475 ShowWithTransientChildrenRecursive(window); | 502 ShowWithTransientChildrenRecursive(window); |
| 476 } else { | 503 } else { |
| 477 if (window->HasFocus()) | 504 if (window->HasFocus()) |
| 478 window->Blur(); | 505 window->Blur(); |
| 479 window->Hide(); | 506 window->Hide(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 // To prevent these commands from being recorded as any other commands, we | 585 // To prevent these commands from being recorded as any other commands, we |
| 559 // are suppressing any window entry changes while this is going on. | 586 // are suppressing any window entry changes while this is going on. |
| 560 // Instead of calling SetWindowVisible, only show gets called here since all | 587 // Instead of calling SetWindowVisible, only show gets called here since all |
| 561 // dependents have been shown previously already. | 588 // dependents have been shown previously already. |
| 562 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); | 589 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); |
| 563 window->Show(); | 590 window->Show(); |
| 564 } | 591 } |
| 565 } | 592 } |
| 566 | 593 |
| 567 } // namespace chrome | 594 } // namespace chrome |
| OLD | NEW |