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

Side by Side Diff: ash/wm/ash_focus_rules.cc

Issue 1053013007: Minimized windows should not be activated by another user in multiprofile scenario. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Oshima's comments. Created 5 years, 8 months 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
OLDNEW
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
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;
oshima 2015/04/09 17:50:48 you need {} in this case.
xdai1 2015/04/09 22:45:25 Done.
105 }
106
87 if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window)) 107 if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window))
88 return true; 108 return true;
89 109
90 // Minimized windows are hidden in their minimized state, but they can always 110 // Minimized windows are hidden in their minimized state, but they can always
91 // be activated. 111 // be activated.
92 if (wm::GetWindowState(window)->IsMinimized()) 112 if (wm::GetWindowState(window)->IsMinimized())
93 return true; 113 return true;
94 114
95 return window->TargetVisibility() && 115 return window->TargetVisibility() &&
96 (window->parent()->id() == kShellWindowId_DefaultContainer || 116 (window->parent()->id() == kShellWindowId_DefaultContainer ||
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 205 }
186 return NULL; 206 return NULL;
187 } 207 }
188 208
189 void AshFocusRules::OnAppTerminating() { 209 void AshFocusRules::OnAppTerminating() {
190 is_shutting_down_ = true; 210 is_shutting_down_ = true;
191 } 211 }
192 212
193 } // namespace wm 213 } // namespace wm
194 } // namespace ash 214 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698