This source file includes following definitions.
- GetInstance
- CreateInstance
- GetMultiProfileMode
- ShouldShowAvatar
- DeleteInstance
- SetInstanceForTest
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
#include "base/logging.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_stub.h"
#if defined(OS_CHROMEOS)
#include "ash/ash_switches.h"
#include "ash/multi_profile_uma.h"
#include "ash/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
#endif
namespace {
chrome::MultiUserWindowManager* g_instance = NULL;
}
namespace chrome {
chrome::MultiUserWindowManager::MultiProfileMode
chrome::MultiUserWindowManager::multi_user_mode_ =
chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_UNINITIALIZED;
MultiUserWindowManager* MultiUserWindowManager::GetInstance() {
return g_instance;
}
MultiUserWindowManager* MultiUserWindowManager::CreateInstance() {
DCHECK(!g_instance);
multi_user_mode_ = MULTI_PROFILE_MODE_OFF;
#if defined(OS_CHROMEOS)
ash::MultiProfileUMA::SessionMode mode =
ash::MultiProfileUMA::SESSION_SINGLE_USER_MODE;
if (!g_instance &&
ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) {
g_instance = new MultiUserWindowManagerChromeOS(
ash::Shell::GetInstance()->session_state_delegate()->GetUserID(0));
multi_user_mode_ = MULTI_PROFILE_MODE_SEPARATED;
mode = ash::MultiProfileUMA::SESSION_SEPARATE_DESKTOP_MODE;
} else if (ash::Shell::GetInstance()->delegate()->IsMultiProfilesEnabled()) {
multi_user_mode_ = MULTI_PROFILE_MODE_MIXED;
mode = ash::MultiProfileUMA::SESSION_SIDE_BY_SIDE_MODE;
}
ash::MultiProfileUMA::RecordSessionMode(mode);
#endif
if (!g_instance)
g_instance = new MultiUserWindowManagerStub();
return g_instance;
}
MultiUserWindowManager::MultiProfileMode
MultiUserWindowManager::GetMultiProfileMode() {
return multi_user_mode_;
}
bool MultiUserWindowManager::ShouldShowAvatar(aura::Window* window) {
if (GetMultiProfileMode() == MULTI_PROFILE_MODE_SEPARATED) {
MultiUserWindowManager* instance = GetInstance();
return !instance->IsWindowOnDesktopOfUser(window,
instance->GetWindowOwner(window));
}
return false;
}
void MultiUserWindowManager::DeleteInstance() {
DCHECK(g_instance);
delete g_instance;
g_instance = NULL;
multi_user_mode_ = MULTI_PROFILE_MODE_UNINITIALIZED;
}
void MultiUserWindowManager::SetInstanceForTest(
MultiUserWindowManager* instance,
MultiProfileMode mode) {
if (g_instance)
DeleteInstance();
g_instance = instance;
multi_user_mode_ = mode;
}
}