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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/ash_focus_rules.cc
diff --git a/ash/wm/ash_focus_rules.cc b/ash/wm/ash_focus_rules.cc
index 66fe0b22b1af60d8899462307f8b8c7d51f10508..d8ecd17f992bce90ff4d05fa8ef906e0fe0f248a 100644
--- a/ash/wm/ash_focus_rules.cc
+++ b/ash/wm/ash_focus_rules.cc
@@ -4,10 +4,13 @@
#include "ash/wm/ash_focus_rules.h"
+#include "ash/session/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/window_state.h"
+#include "components/user_manager/user.h"
+#include "components/user_manager/user_manager.h"
#include "ui/aura/window.h"
namespace ash {
@@ -84,6 +87,25 @@ bool AshFocusRules::SupportsChildActivation(aura::Window* window) const {
bool AshFocusRules::IsWindowConsideredVisibleForActivation(
aura::Window* window) const {
+ // If the |window| doesn't belong to the current active user and also doesn't
+ // show for the current active user, then it should not be activated.
+ SessionStateDelegate* delegate =
+ Shell::GetInstance()->session_state_delegate();
+ if (delegate->NumberOfLoggedInUsers() > 1) {
+ const user_manager::UserManager* user_manager =
+ user_manager::UserManager::Get();
+ const user_manager::User* active_user =
+ 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.
+
+ content::BrowserContext* browser_context =
+ delegate->GetBrowserContextForWindow(window);
+ if ((browser_context &&
+ delegate->GetUserInfo(browser_context) != active_user) &&
+ (active_user &&
+ delegate->GetUserPresentingWindow(window) != active_user->GetUserID()))
+ return false;
+ }
+
if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window))
return true;

Powered by Google App Engine
This is Rietveld 408576698