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