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 !ash::switches::UseFullMultiProfileMode()) {
45 g_instance
= new MultiUserWindowManagerChromeOS(
46 ash::Shell::GetInstance()->session_state_delegate()->GetUserID(0));
47 multi_user_mode_
= MULTI_PROFILE_MODE_SEPARATED
;
48 mode
= ash::MultiProfileUMA::SESSION_SEPARATE_DESKTOP_MODE
;
49 } else if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) {
50 // The side by side mode is using the Single user window manager since all
51 // windows are unmanaged side by side.
52 multi_user_mode_
= MULTI_PROFILE_MODE_MIXED
;
53 mode
= ash::MultiProfileUMA::SESSION_SIDE_BY_SIDE_MODE
;
55 ash::MultiProfileUMA::RecordSessionMode(mode
);
57 // If there was no instance created yet we create a dummy instance.
59 g_instance
= new MultiUserWindowManagerStub();
65 MultiUserWindowManager::MultiProfileMode
66 MultiUserWindowManager::GetMultiProfileMode() {
67 return multi_user_mode_
;
71 void MultiUserWindowManager::DeleteInstance() {
75 multi_user_mode_
= MULTI_PROFILE_MODE_UNINITIALIZED
;
78 void MultiUserWindowManager::SetInstanceForTest(
79 MultiUserWindowManager
* instance
,
80 MultiProfileMode mode
) {
83 g_instance
= instance
;
84 multi_user_mode_
= mode
;