| 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_window_manager.h" | 5 #include "chrome/browser/ui/ash/multi_user_window_manager.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/session_state_delegate.h" | 11 #include "ash/session_state_delegate.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/shell_delegate.h" | 13 #include "ash/shell_delegate.h" |
| 13 #include "ash/wm/mru_window_tracker.h" | 14 #include "ash/wm/mru_window_tracker.h" |
| 14 #include "ash/wm/window_positioner.h" | 15 #include "ash/wm/window_positioner.h" |
| 15 #include "ash/wm/window_state.h" | 16 #include "ash/wm/window_state.h" |
| 16 #include "base/auto_reset.h" | 17 #include "base/auto_reset.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 89 |
| 89 DISALLOW_COPY_AND_ASSIGN(AppObserver); | 90 DISALLOW_COPY_AND_ASSIGN(AppObserver); |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 // static | 93 // static |
| 93 MultiUserWindowManager* MultiUserWindowManager::GetInstance() { | 94 MultiUserWindowManager* MultiUserWindowManager::GetInstance() { |
| 94 return g_instance; | 95 return g_instance; |
| 95 } | 96 } |
| 96 | 97 |
| 97 MultiUserWindowManager* MultiUserWindowManager::CreateInstance() { | 98 MultiUserWindowManager* MultiUserWindowManager::CreateInstance() { |
| 99 ash::MultiProfileUMA::SessionMode mode = |
| 100 ash::MultiProfileUMA::SESSION_SINGLE_USER_MODE; |
| 98 if (!g_instance && | 101 if (!g_instance && |
| 99 ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled() && | 102 ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled() && |
| 100 !ash::switches::UseFullMultiProfileMode()) { | 103 !ash::switches::UseFullMultiProfileMode()) { |
| 101 g_instance = CreateInstanceInternal( | 104 g_instance = CreateInstanceInternal( |
| 102 ash::Shell::GetInstance()->session_state_delegate()->GetUserID(0)); | 105 ash::Shell::GetInstance()->session_state_delegate()->GetUserID(0)); |
| 103 multi_user_mode_ = MULTI_PROFILE_MODE_SEPARATED; | 106 multi_user_mode_ = MULTI_PROFILE_MODE_SEPARATED; |
| 107 mode = ash::MultiProfileUMA::SESSION_SEPARATE_DESKTOP_MODE; |
| 104 } else if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { | 108 } else if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { |
| 105 multi_user_mode_ = MULTI_PROFILE_MODE_MIXED; | 109 multi_user_mode_ = MULTI_PROFILE_MODE_MIXED; |
| 110 mode = ash::MultiProfileUMA::SESSION_SIDE_BY_SIDE_MODE; |
| 106 } else { | 111 } else { |
| 107 multi_user_mode_ = MULTI_PROFILE_MODE_OFF; | 112 multi_user_mode_ = MULTI_PROFILE_MODE_OFF; |
| 108 } | 113 } |
| 114 ash::MultiProfileUMA::RecordSessionMode(mode); |
| 109 return g_instance; | 115 return g_instance; |
| 110 } | 116 } |
| 111 | 117 |
| 112 // static | 118 // static |
| 113 MultiUserWindowManager::MultiProfileMode | 119 MultiUserWindowManager::MultiProfileMode |
| 114 MultiUserWindowManager::GetMultiProfileMode() { | 120 MultiUserWindowManager::GetMultiProfileMode() { |
| 115 return multi_user_mode_; | 121 return multi_user_mode_; |
| 116 } | 122 } |
| 117 | 123 |
| 118 // static | 124 // static |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // is required. | 198 // is required. |
| 193 const std::string& owner = GetWindowOwner(window); | 199 const std::string& owner = GetWindowOwner(window); |
| 194 if (owner.empty() || | 200 if (owner.empty() || |
| 195 (owner == user_id && IsWindowOnDesktopOfUser(window, user_id))) | 201 (owner == user_id && IsWindowOnDesktopOfUser(window, user_id))) |
| 196 return; | 202 return; |
| 197 | 203 |
| 198 // Check that we are not trying to transfer ownership of a minimized window. | 204 // Check that we are not trying to transfer ownership of a minimized window. |
| 199 if (user_id != owner && ash::wm::GetWindowState(window)->IsMinimized()) | 205 if (user_id != owner && ash::wm::GetWindowState(window)->IsMinimized()) |
| 200 return; | 206 return; |
| 201 | 207 |
| 208 ash::MultiProfileUMA::RecordTeleportAction( |
| 209 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_MINIMIZE); |
| 210 |
| 202 WindowToEntryMap::iterator it = window_to_entry_.find(window); | 211 WindowToEntryMap::iterator it = window_to_entry_.find(window); |
| 203 it->second->set_show_for_user(user_id); | 212 it->second->set_show_for_user(user_id); |
| 204 | 213 |
| 205 // Show the window if the added user is the current one. | 214 // Show the window if the added user is the current one. |
| 206 if (user_id == current_user_id_) | 215 if (user_id == current_user_id_) |
| 207 SetWindowVisibility(window, true); | 216 SetWindowVisibility(window, true); |
| 208 else | 217 else |
| 209 SetWindowVisibility(window, false); | 218 SetWindowVisibility(window, false); |
| 210 } | 219 } |
| 211 | 220 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 // To prevent these commands from being recorded as any other commands, we | 577 // To prevent these commands from being recorded as any other commands, we |
| 569 // are suppressing any window entry changes while this is going on. | 578 // are suppressing any window entry changes while this is going on. |
| 570 // Instead of calling SetWindowVisible, only show gets called here since all | 579 // Instead of calling SetWindowVisible, only show gets called here since all |
| 571 // dependents have been shown previously already. | 580 // dependents have been shown previously already. |
| 572 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); | 581 base::AutoReset<bool> suppressor(&suppress_visibility_changes_, true); |
| 573 window->Show(); | 582 window->Show(); |
| 574 } | 583 } |
| 575 } | 584 } |
| 576 | 585 |
| 577 } // namespace chrome | 586 } // namespace chrome |
| OLD | NEW |