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" |
| 9 #include "ash/shell_delegate.h" |
8 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
9 #include "ash/wm/mru_window_tracker.h" | 11 #include "ash/wm/mru_window_tracker.h" |
10 #include "ash/wm/window_state.h" | 12 #include "ash/wm/window_state.h" |
11 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
12 | 14 |
13 namespace ash { | 15 namespace ash { |
14 namespace wm { | 16 namespace wm { |
15 namespace { | 17 namespace { |
16 | 18 |
17 // These are the list of container ids of containers which may contain windows | 19 // These are the list of container ids of containers which may contain windows |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 79 |
78 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) { | 80 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) { |
79 if (window->id() == kWindowContainerIds[i]) | 81 if (window->id() == kWindowContainerIds[i]) |
80 return true; | 82 return true; |
81 } | 83 } |
82 return false; | 84 return false; |
83 } | 85 } |
84 | 86 |
85 bool AshFocusRules::IsWindowConsideredVisibleForActivation( | 87 bool AshFocusRules::IsWindowConsideredVisibleForActivation( |
86 aura::Window* window) const { | 88 aura::Window* window) const { |
| 89 // If the |window| doesn't belong to the current active user and also doesn't |
| 90 // show for the current active user, then it should not be activated. |
| 91 SessionStateDelegate* delegate = |
| 92 Shell::GetInstance()->session_state_delegate(); |
| 93 if (delegate->NumberOfLoggedInUsers() > 1) { |
| 94 content::BrowserContext* active_browser_context = |
| 95 Shell::GetInstance()->delegate()->GetActiveBrowserContext(); |
| 96 content::BrowserContext* owner_browser_context = |
| 97 delegate->GetBrowserContextForWindow(window); |
| 98 content::BrowserContext* shown_browser_context = |
| 99 delegate->GetUserPresentingBrowserContextForWindow(window); |
| 100 |
| 101 if (owner_browser_context && active_browser_context && |
| 102 owner_browser_context != active_browser_context && |
| 103 shown_browser_context != active_browser_context) { |
| 104 return false; |
| 105 } |
| 106 } |
| 107 |
87 if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window)) | 108 if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window)) |
88 return true; | 109 return true; |
89 | 110 |
90 // Minimized windows are hidden in their minimized state, but they can always | 111 // Minimized windows are hidden in their minimized state, but they can always |
91 // be activated. | 112 // be activated. |
92 if (wm::GetWindowState(window)->IsMinimized()) | 113 if (wm::GetWindowState(window)->IsMinimized()) |
93 return true; | 114 return true; |
94 | 115 |
95 return window->TargetVisibility() && | 116 return window->TargetVisibility() && |
96 (window->parent()->id() == kShellWindowId_DefaultContainer || | 117 (window->parent()->id() == kShellWindowId_DefaultContainer || |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 206 } |
186 return NULL; | 207 return NULL; |
187 } | 208 } |
188 | 209 |
189 void AshFocusRules::OnAppTerminating() { | 210 void AshFocusRules::OnAppTerminating() { |
190 is_shutting_down_ = true; | 211 is_shutting_down_ = true; |
191 } | 212 } |
192 | 213 |
193 } // namespace wm | 214 } // namespace wm |
194 } // namespace ash | 215 } // namespace ash |
OLD | NEW |