| 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" | 
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  202   // will add the children but not the owner to the transient children map. |  202   // will add the children but not the owner to the transient children map. | 
|  203   AddTransientOwnerRecursive(window, window); |  203   AddTransientOwnerRecursive(window, window); | 
|  204  |  204  | 
|  205   if (!IsWindowOnDesktopOfUser(window, current_user_id_)) |  205   if (!IsWindowOnDesktopOfUser(window, current_user_id_)) | 
|  206     SetWindowVisibility(window, false); |  206     SetWindowVisibility(window, false); | 
|  207 } |  207 } | 
|  208  |  208  | 
|  209 const std::string& MultiUserWindowManagerChromeOS::GetWindowOwner( |  209 const std::string& MultiUserWindowManagerChromeOS::GetWindowOwner( | 
|  210     aura::Window* window) { |  210     aura::Window* window) { | 
|  211   WindowToEntryMap::iterator it = window_to_entry_.find(window); |  211   WindowToEntryMap::iterator it = window_to_entry_.find(window); | 
|  212   return it != window_to_entry_.end() ? it->second->owner() : EmptyString(); |  212   return it != window_to_entry_.end() ? it->second->owner() | 
 |  213                                       : base::EmptyString(); | 
|  213 } |  214 } | 
|  214  |  215  | 
|  215 void MultiUserWindowManagerChromeOS::ShowWindowForUser( |  216 void MultiUserWindowManagerChromeOS::ShowWindowForUser( | 
|  216     aura::Window* window, |  217     aura::Window* window, | 
|  217     const std::string& user_id) { |  218     const std::string& user_id) { | 
|  218   // If there is either no owner, or the owner is the current user, no action |  219   // If there is either no owner, or the owner is the current user, no action | 
|  219   // is required. |  220   // is required. | 
|  220   const std::string& owner = GetWindowOwner(window); |  221   const std::string& owner = GetWindowOwner(window); | 
|  221   if (owner.empty() || |  222   if (owner.empty() || | 
|  222       (owner == user_id && IsWindowOnDesktopOfUser(window, user_id))) |  223       (owner == user_id && IsWindowOnDesktopOfUser(window, user_id))) | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  257   const std::string& presenting_user = GetUserPresentingWindow(window); |  258   const std::string& presenting_user = GetUserPresentingWindow(window); | 
|  258   return presenting_user.empty() || presenting_user == user_id; |  259   return presenting_user.empty() || presenting_user == user_id; | 
|  259 } |  260 } | 
|  260  |  261  | 
|  261 const std::string& MultiUserWindowManagerChromeOS::GetUserPresentingWindow( |  262 const std::string& MultiUserWindowManagerChromeOS::GetUserPresentingWindow( | 
|  262     aura::Window* window) { |  263     aura::Window* window) { | 
|  263   WindowToEntryMap::iterator it = window_to_entry_.find(window); |  264   WindowToEntryMap::iterator it = window_to_entry_.find(window); | 
|  264   // If the window is not owned by anyone it is shown on all desktops and we |  265   // If the window is not owned by anyone it is shown on all desktops and we | 
|  265   // return the empty string. |  266   // return the empty string. | 
|  266   if (it == window_to_entry_.end()) |  267   if (it == window_to_entry_.end()) | 
|  267     return EmptyString(); |  268     return base::EmptyString(); | 
|  268   // Otherwise we ask the object for its desktop. |  269   // Otherwise we ask the object for its desktop. | 
|  269   return it->second->show_for_user(); |  270   return it->second->show_for_user(); | 
|  270 } |  271 } | 
|  271  |  272  | 
|  272 void MultiUserWindowManagerChromeOS::AddUser(Profile* profile) { |  273 void MultiUserWindowManagerChromeOS::AddUser(Profile* profile) { | 
|  273   const std::string& user_id = multi_user_util::GetUserIDFromProfile(profile); |  274   const std::string& user_id = multi_user_util::GetUserIDFromProfile(profile); | 
|  274   if (user_id_to_app_observer_.find(user_id) != user_id_to_app_observer_.end()) |  275   if (user_id_to_app_observer_.find(user_id) != user_id_to_app_observer_.end()) | 
|  275     return; |  276     return; | 
|  276  |  277  | 
|  277   user_id_to_app_observer_[user_id] = new AppObserver(user_id); |  278   user_id_to_app_observer_[user_id] = new AppObserver(user_id); | 
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  584     // 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 | 
|  585     // are suppressing any window entry changes while this is going on. |  586     // are suppressing any window entry changes while this is going on. | 
|  586     // Instead of calling SetWindowVisible, only show gets called here since all |  587     // Instead of calling SetWindowVisible, only show gets called here since all | 
|  587     // dependents have been shown previously already. |  588     // dependents have been shown previously already. | 
|  588     base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); |  589     base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); | 
|  589     window->Show(); |  590     window->Show(); | 
|  590   } |  591   } | 
|  591 } |  592 } | 
|  592  |  593  | 
|  593 }  // namespace chrome |  594 }  // namespace chrome | 
| OLD | NEW |