| 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.h" | 5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 6 | 6 |
| 7 #include "ash/common/multi_profile_uma.h" | 7 #include "ash/common/multi_profile_uma.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | |
| 9 #include "ash/common/shell_delegate.h" | 8 #include "ash/common/shell_delegate.h" |
| 10 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 12 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 13 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 12 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
| 14 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.h" | 13 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.h" |
| 15 #include "components/signin/core/account_id/account_id.h" | 14 #include "components/signin/core/account_id/account_id.h" |
| 16 #include "components/user_manager/user_info.h" | 15 #include "components/user_manager/user_info.h" |
| 16 #include "components/user_manager/user_manager.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 chrome::MultiUserWindowManager* g_instance = NULL; | 19 chrome::MultiUserWindowManager* g_instance = NULL; |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 namespace chrome { | 22 namespace chrome { |
| 23 | 23 |
| 24 // Caching the current multi profile mode to avoid expensive detection | 24 // Caching the current multi profile mode to avoid expensive detection |
| 25 // operations. | 25 // operations. |
| 26 chrome::MultiUserWindowManager::MultiProfileMode | 26 chrome::MultiUserWindowManager::MultiProfileMode |
| 27 chrome::MultiUserWindowManager::multi_user_mode_ = | 27 chrome::MultiUserWindowManager::multi_user_mode_ = |
| 28 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_UNINITIALIZED; | 28 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_UNINITIALIZED; |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 MultiUserWindowManager* MultiUserWindowManager::GetInstance() { | 31 MultiUserWindowManager* MultiUserWindowManager::GetInstance() { |
| 32 return g_instance; | 32 return g_instance; |
| 33 } | 33 } |
| 34 | 34 |
| 35 MultiUserWindowManager* MultiUserWindowManager::CreateInstance() { | 35 MultiUserWindowManager* MultiUserWindowManager::CreateInstance() { |
| 36 DCHECK(!g_instance); | 36 DCHECK(!g_instance); |
| 37 multi_user_mode_ = MULTI_PROFILE_MODE_OFF; | 37 multi_user_mode_ = MULTI_PROFILE_MODE_OFF; |
| 38 ash::MultiProfileUMA::SessionMode mode = | 38 ash::MultiProfileUMA::SessionMode mode = |
| 39 ash::MultiProfileUMA::SESSION_SINGLE_USER_MODE; | 39 ash::MultiProfileUMA::SESSION_SINGLE_USER_MODE; |
| 40 if (ash::WmShell::Get()->delegate()->IsMultiProfilesEnabled()) { | 40 if (ash::WmShell::Get()->delegate()->IsMultiProfilesEnabled()) { |
| 41 if (!g_instance) { | 41 if (!g_instance) { |
| 42 MultiUserWindowManagerChromeOS* manager = | 42 MultiUserWindowManagerChromeOS* manager = |
| 43 new MultiUserWindowManagerChromeOS(ash::WmShell::Get() | 43 new MultiUserWindowManagerChromeOS(user_manager::UserManager::Get() |
| 44 ->GetSessionStateDelegate() | 44 ->GetActiveUser() |
| 45 ->GetUserInfo(0) | |
| 46 ->GetAccountId()); | 45 ->GetAccountId()); |
| 47 g_instance = manager; | 46 g_instance = manager; |
| 48 manager->Init(); | 47 manager->Init(); |
| 49 multi_user_mode_ = MULTI_PROFILE_MODE_SEPARATED; | 48 multi_user_mode_ = MULTI_PROFILE_MODE_SEPARATED; |
| 50 mode = ash::MultiProfileUMA::SESSION_SEPARATE_DESKTOP_MODE; | 49 mode = ash::MultiProfileUMA::SESSION_SEPARATE_DESKTOP_MODE; |
| 51 } else { | 50 } else { |
| 52 // The side by side mode is using the Single user window manager since all | 51 // The side by side mode is using the Single user window manager since all |
| 53 // windows are unmanaged side by side. | 52 // windows are unmanaged side by side. |
| 54 multi_user_mode_ = MULTI_PROFILE_MODE_MIXED; | 53 multi_user_mode_ = MULTI_PROFILE_MODE_MIXED; |
| 55 mode = ash::MultiProfileUMA::SESSION_SIDE_BY_SIDE_MODE; | 54 mode = ash::MultiProfileUMA::SESSION_SIDE_BY_SIDE_MODE; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 void MultiUserWindowManager::SetInstanceForTest( | 93 void MultiUserWindowManager::SetInstanceForTest( |
| 95 MultiUserWindowManager* instance, | 94 MultiUserWindowManager* instance, |
| 96 MultiProfileMode mode) { | 95 MultiProfileMode mode) { |
| 97 if (g_instance) | 96 if (g_instance) |
| 98 DeleteInstance(); | 97 DeleteInstance(); |
| 99 g_instance = instance; | 98 g_instance = instance; |
| 100 multi_user_mode_ = mode; | 99 multi_user_mode_ = mode; |
| 101 } | 100 } |
| 102 | 101 |
| 103 } // namespace chrome | 102 } // namespace chrome |
| OLD | NEW |