| 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 "base/logging.h" | |
| 8 #include "build/build_config.h" | |
| 9 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.h" | |
| 10 | |
| 11 #if defined(OS_CHROMEOS) | |
| 12 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 13 #include "ash/multi_profile_uma.h" | 8 #include "ash/multi_profile_uma.h" |
| 14 #include "ash/session/session_state_delegate.h" | 9 #include "ash/session/session_state_delegate.h" |
| 15 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 16 #include "ash/shell_delegate.h" | 11 #include "ash/shell_delegate.h" |
| 12 #include "base/logging.h" |
| 13 #include "build/build_config.h" |
| 17 #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_chromeos.h" |
| 15 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.h" |
| 18 #include "components/signin/core/account_id/account_id.h" | 16 #include "components/signin/core/account_id/account_id.h" |
| 19 #include "components/user_manager/user_info.h" | 17 #include "components/user_manager/user_info.h" |
| 20 #endif | |
| 21 | 18 |
| 22 namespace { | 19 namespace { |
| 23 chrome::MultiUserWindowManager* g_instance = NULL; | 20 chrome::MultiUserWindowManager* g_instance = NULL; |
| 24 } // namespace | 21 } // namespace |
| 25 | 22 |
| 26 namespace chrome { | 23 namespace chrome { |
| 27 | 24 |
| 28 // Caching the current multi profile mode to avoid expensive detection | 25 // Caching the current multi profile mode to avoid expensive detection |
| 29 // operations. | 26 // operations. |
| 30 chrome::MultiUserWindowManager::MultiProfileMode | 27 chrome::MultiUserWindowManager::MultiProfileMode |
| 31 chrome::MultiUserWindowManager::multi_user_mode_ = | 28 chrome::MultiUserWindowManager::multi_user_mode_ = |
| 32 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_UNINITIALIZED; | 29 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_UNINITIALIZED; |
| 33 | 30 |
| 34 // static | 31 // static |
| 35 MultiUserWindowManager* MultiUserWindowManager::GetInstance() { | 32 MultiUserWindowManager* MultiUserWindowManager::GetInstance() { |
| 36 return g_instance; | 33 return g_instance; |
| 37 } | 34 } |
| 38 | 35 |
| 39 MultiUserWindowManager* MultiUserWindowManager::CreateInstance() { | 36 MultiUserWindowManager* MultiUserWindowManager::CreateInstance() { |
| 40 DCHECK(!g_instance); | 37 DCHECK(!g_instance); |
| 41 multi_user_mode_ = MULTI_PROFILE_MODE_OFF; | 38 multi_user_mode_ = MULTI_PROFILE_MODE_OFF; |
| 42 #if defined(OS_CHROMEOS) | |
| 43 ash::MultiProfileUMA::SessionMode mode = | 39 ash::MultiProfileUMA::SessionMode mode = |
| 44 ash::MultiProfileUMA::SESSION_SINGLE_USER_MODE; | 40 ash::MultiProfileUMA::SESSION_SINGLE_USER_MODE; |
| 45 if (!g_instance && | 41 if (!g_instance && |
| 46 ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { | 42 ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { |
| 47 MultiUserWindowManagerChromeOS* manager = | 43 MultiUserWindowManagerChromeOS* manager = |
| 48 new MultiUserWindowManagerChromeOS(ash::Shell::GetInstance() | 44 new MultiUserWindowManagerChromeOS(ash::Shell::GetInstance() |
| 49 ->session_state_delegate() | 45 ->session_state_delegate() |
| 50 ->GetUserInfo(0) | 46 ->GetUserInfo(0) |
| 51 ->GetAccountId()); | 47 ->GetAccountId()); |
| 52 g_instance = manager; | 48 g_instance = manager; |
| 53 manager->Init(); | 49 manager->Init(); |
| 54 multi_user_mode_ = MULTI_PROFILE_MODE_SEPARATED; | 50 multi_user_mode_ = MULTI_PROFILE_MODE_SEPARATED; |
| 55 mode = ash::MultiProfileUMA::SESSION_SEPARATE_DESKTOP_MODE; | 51 mode = ash::MultiProfileUMA::SESSION_SEPARATE_DESKTOP_MODE; |
| 56 } else if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { | 52 } else if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) { |
| 57 // The side by side mode is using the Single user window manager since all | 53 // The side by side mode is using the Single user window manager since all |
| 58 // windows are unmanaged side by side. | 54 // windows are unmanaged side by side. |
| 59 multi_user_mode_ = MULTI_PROFILE_MODE_MIXED; | 55 multi_user_mode_ = MULTI_PROFILE_MODE_MIXED; |
| 60 mode = ash::MultiProfileUMA::SESSION_SIDE_BY_SIDE_MODE; | 56 mode = ash::MultiProfileUMA::SESSION_SIDE_BY_SIDE_MODE; |
| 61 } | 57 } |
| 62 ash::MultiProfileUMA::RecordSessionMode(mode); | 58 ash::MultiProfileUMA::RecordSessionMode(mode); |
| 63 #endif | 59 |
| 64 // If there was no instance created yet we create a dummy instance. | 60 // If there was no instance created yet we create a dummy instance. |
| 65 if (!g_instance) | 61 if (!g_instance) |
| 66 g_instance = new MultiUserWindowManagerStub(); | 62 g_instance = new MultiUserWindowManagerStub(); |
| 67 | 63 |
| 68 return g_instance; | 64 return g_instance; |
| 69 } | 65 } |
| 70 | 66 |
| 71 // static | 67 // static |
| 72 MultiUserWindowManager::MultiProfileMode | 68 MultiUserWindowManager::MultiProfileMode |
| 73 MultiUserWindowManager::GetMultiProfileMode() { | 69 MultiUserWindowManager::GetMultiProfileMode() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 98 void MultiUserWindowManager::SetInstanceForTest( | 94 void MultiUserWindowManager::SetInstanceForTest( |
| 99 MultiUserWindowManager* instance, | 95 MultiUserWindowManager* instance, |
| 100 MultiProfileMode mode) { | 96 MultiProfileMode mode) { |
| 101 if (g_instance) | 97 if (g_instance) |
| 102 DeleteInstance(); | 98 DeleteInstance(); |
| 103 g_instance = instance; | 99 g_instance = instance; |
| 104 multi_user_mode_ = mode; | 100 multi_user_mode_ = mode; |
| 105 } | 101 } |
| 106 | 102 |
| 107 } // namespace chrome | 103 } // namespace chrome |
| OLD | NEW |