Chromium Code Reviews| Index: components/session_manager/core/session_manager.cc |
| diff --git a/components/session_manager/core/session_manager.cc b/components/session_manager/core/session_manager.cc |
| index 3fff7484f57fdd17974f0f059866dda1be90a128..f7ee8dc7b813353ab426e5272d8198836748abda 100644 |
| --- a/components/session_manager/core/session_manager.cc |
| +++ b/components/session_manager/core/session_manager.cc |
| @@ -6,12 +6,29 @@ |
| #include "base/logging.h" |
| +#if defined(OS_CHROMEOS) |
| +#include "base/command_line.h" |
| +#include "base/sys_info.h" |
| +#include "chromeos/chromeos_switches.h" |
| +#endif |
| + |
| namespace session_manager { |
| +// static |
| +SessionManager* SessionManager::instance = NULL; |
| + |
| SessionManager::SessionManager() : session_state_(SESSION_STATE_UNKNOWN) { |
| + DCHECK(!SessionManager::Get()); |
| + SessionManager::SetInstance(this); |
| } |
| SessionManager::~SessionManager() { |
| + SessionManager::SetInstance(NULL); |
|
jochen (gone - plz use gerrit)
2014/07/29 08:48:40
DCHECK() that the instance == this?
Nikita (slow)
2014/07/29 09:27:28
Done.
|
| +} |
| + |
| +// static |
| +SessionManager* SessionManager::Get() { |
| + return SessionManager::instance; |
| } |
| void SessionManager::SetSessionState(SessionState state) { |
| @@ -31,10 +48,26 @@ void SessionManager::Initialize(SessionManagerDelegate* delegate) { |
| delegate_->SetSessionManager(this); |
| } |
| +// static |
| +void SessionManager::SetInstance(SessionManager* session_manager) { |
| + SessionManager::instance = session_manager; |
| +} |
| + |
| void SessionManager::Start() { |
| delegate_->Start(); |
| } |
| +// static |
| +bool SessionManager::HasBrowserRestarted() { |
| +#if defined(OS_CHROMEOS) |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + return base::SysInfo::IsRunningOnChromeOS() && |
| + command_line->HasSwitch(chromeos::switches::kLoginUser); |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| SessionManagerDelegate::SessionManagerDelegate() : session_manager_(NULL) { |
| } |