Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/ash_focus_rules.h" | 5 #include "ash/wm/ash_focus_rules.h" |
| 6 | 6 |
| 7 #include "ash/session/session_state_delegate.h" | |
| 7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 9 #include "ash/wm/mru_window_tracker.h" | 10 #include "ash/wm/mru_window_tracker.h" |
| 10 #include "ash/wm/window_state.h" | 11 #include "ash/wm/window_state.h" |
| 12 #include "components/user_manager/user.h" | |
| 13 #include "components/user_manager/user_manager.h" | |
| 11 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 12 | 15 |
| 13 namespace ash { | 16 namespace ash { |
| 14 namespace wm { | 17 namespace wm { |
| 15 namespace { | 18 namespace { |
| 16 | 19 |
| 17 // These are the list of container ids of containers which may contain windows | 20 // These are the list of container ids of containers which may contain windows |
| 18 // that need to be activated in the order that they should be activated. | 21 // that need to be activated in the order that they should be activated. |
| 19 const int kWindowContainerIds[] = { | 22 const int kWindowContainerIds[] = { |
| 20 kShellWindowId_OverlayContainer, | 23 kShellWindowId_OverlayContainer, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 80 |
| 78 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) { | 81 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) { |
| 79 if (window->id() == kWindowContainerIds[i]) | 82 if (window->id() == kWindowContainerIds[i]) |
| 80 return true; | 83 return true; |
| 81 } | 84 } |
| 82 return false; | 85 return false; |
| 83 } | 86 } |
| 84 | 87 |
| 85 bool AshFocusRules::IsWindowConsideredVisibleForActivation( | 88 bool AshFocusRules::IsWindowConsideredVisibleForActivation( |
| 86 aura::Window* window) const { | 89 aura::Window* window) const { |
| 90 // If the |window| doesn't belong to the current active user and also doesn't | |
| 91 // show for the current active user, then it should not be activated. | |
| 92 SessionStateDelegate* delegate = | |
| 93 Shell::GetInstance()->session_state_delegate(); | |
| 94 if (delegate->NumberOfLoggedInUsers() > 1) { | |
| 95 const user_manager::UserManager* user_manager = | |
| 96 user_manager::UserManager::Get(); | |
| 97 const user_manager::User* active_user = | |
| 98 user_manager ? user_manager->GetActiveUser() : NULL; | |
|
oshima
2015/04/07 19:53:44
Can you use GetActiveBrowserContext and GetUserIn
xdai1
2015/04/09 17:22:40
Done.
| |
| 99 | |
| 100 content::BrowserContext* browser_context = | |
| 101 delegate->GetBrowserContextForWindow(window); | |
| 102 if ((browser_context && | |
| 103 delegate->GetUserInfo(browser_context) != active_user) && | |
| 104 (active_user && | |
| 105 delegate->GetUserPresentingWindow(window) != active_user->GetUserID())) | |
| 106 return false; | |
| 107 } | |
| 108 | |
| 87 if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window)) | 109 if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window)) |
| 88 return true; | 110 return true; |
| 89 | 111 |
| 90 // Minimized windows are hidden in their minimized state, but they can always | 112 // Minimized windows are hidden in their minimized state, but they can always |
| 91 // be activated. | 113 // be activated. |
| 92 if (wm::GetWindowState(window)->IsMinimized()) | 114 if (wm::GetWindowState(window)->IsMinimized()) |
| 93 return true; | 115 return true; |
| 94 | 116 |
| 95 return window->TargetVisibility() && | 117 return window->TargetVisibility() && |
| 96 (window->parent()->id() == kShellWindowId_DefaultContainer || | 118 (window->parent()->id() == kShellWindowId_DefaultContainer || |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 } | 207 } |
| 186 return NULL; | 208 return NULL; |
| 187 } | 209 } |
| 188 | 210 |
| 189 void AshFocusRules::OnAppTerminating() { | 211 void AshFocusRules::OnAppTerminating() { |
| 190 is_shutting_down_ = true; | 212 is_shutting_down_ = true; |
| 191 } | 213 } |
| 192 | 214 |
| 193 } // namespace wm | 215 } // namespace wm |
| 194 } // namespace ash | 216 } // namespace ash |
| OLD | NEW |