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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
7 #include "base/logging.h"
8 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.h"
10 #if defined(OS_CHROMEOS)
11 #include "ash/ash_switches.h"
12 #include "ash/multi_profile_uma.h"
13 #include "ash/session_state_delegate.h"
14 #include "ash/shell.h"
15 #include "ash/shell_delegate.h"
16 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
20 chrome::MultiUserWindowManager
* g_instance
= NULL
;
25 // Caching the current multi profile mode to avoid expensive detection
27 chrome::MultiUserWindowManager::MultiProfileMode
28 chrome::MultiUserWindowManager::multi_user_mode_
=
29 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_UNINITIALIZED
;
32 MultiUserWindowManager
* MultiUserWindowManager::GetInstance() {
36 MultiUserWindowManager
* MultiUserWindowManager::CreateInstance() {
38 multi_user_mode_
= MULTI_PROFILE_MODE_OFF
;
39 #if defined(OS_CHROMEOS)
40 ash::MultiProfileUMA::SessionMode mode
=
41 ash::MultiProfileUMA::SESSION_SINGLE_USER_MODE
;
43 ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) {
44 g_instance
= new MultiUserWindowManagerChromeOS(
45 ash::Shell::GetInstance()->session_state_delegate()->GetUserID(0));
46 multi_user_mode_
= MULTI_PROFILE_MODE_SEPARATED
;
47 mode
= ash::MultiProfileUMA::SESSION_SEPARATE_DESKTOP_MODE
;
48 } else if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) {
49 // The side by side mode is using the Single user window manager since all
50 // windows are unmanaged side by side.
51 multi_user_mode_
= MULTI_PROFILE_MODE_MIXED
;
52 mode
= ash::MultiProfileUMA::SESSION_SIDE_BY_SIDE_MODE
;
54 ash::MultiProfileUMA::RecordSessionMode(mode
);
56 // If there was no instance created yet we create a dummy instance.
58 g_instance
= new MultiUserWindowManagerStub();
64 MultiUserWindowManager::MultiProfileMode
65 MultiUserWindowManager::GetMultiProfileMode() {
66 return multi_user_mode_
;
70 void MultiUserWindowManager::DeleteInstance() {
74 multi_user_mode_
= MULTI_PROFILE_MODE_UNINITIALIZED
;
77 void MultiUserWindowManager::SetInstanceForTest(
78 MultiUserWindowManager
* instance
,
79 MultiProfileMode mode
) {
82 g_instance
= instance
;
83 multi_user_mode_
= mode
;