summaryrefslogtreecommitdiffstats
path: root/components/session_manager/core
diff options
context:
space:
mode:
authornkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-29 13:05:23 +0000
committernkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-29 13:05:23 +0000
commit1ac1c464ee4518257ab971d2bc139e3423111289 (patch)
tree8ccd97de7c97979d6353436e03710b8cefe91863 /components/session_manager/core
parent91e69224557b8a6883918122b9b71de3eb6482d1 (diff)
downloadchromium_src-1ac1c464ee4518257ab971d2bc139e3423111289.zip
chromium_src-1ac1c464ee4518257ab971d2bc139e3423111289.tar.gz
chromium_src-1ac1c464ee4518257ab971d2bc139e3423111289.tar.bz2
user_manager component: Add UserManagerBase class.
UserManagerBase contains common methods extracted from UserManagerImpl. UserManagerImpl was renamed to ChromeUserManager and inherits UserManagerBase. Misc refactoring: * Move HasBrowserStarted() to SessionManager * Add generic getter SessionManager::Get() which makes it possible for concrete clients don't depend on instance ownership like g_browser_process->platform_part()->SessionManager(). * Moved CRLSet code out of UserManager::UserLoggedIn(), to UserSessionManager. BUG=387614 Review URL: https://codereview.chromium.org/417623002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286187 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/session_manager/core')
-rw-r--r--components/session_manager/core/session_manager.cc34
-rw-r--r--components/session_manager/core/session_manager.h18
2 files changed, 52 insertions, 0 deletions
diff --git a/components/session_manager/core/session_manager.cc b/components/session_manager/core/session_manager.cc
index 3fff748..f86de43 100644
--- a/components/session_manager/core/session_manager.cc
+++ b/components/session_manager/core/session_manager.cc
@@ -6,12 +6,30 @@
#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() {
+ DCHECK(instance == this);
+ SessionManager::SetInstance(NULL);
+}
+
+// static
+SessionManager* SessionManager::Get() {
+ return SessionManager::instance;
}
void SessionManager::SetSessionState(SessionState state) {
@@ -31,10 +49,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) {
}
diff --git a/components/session_manager/core/session_manager.h b/components/session_manager/core/session_manager.h
index e728e7f..d2e9704 100644
--- a/components/session_manager/core/session_manager.h
+++ b/components/session_manager/core/session_manager.h
@@ -45,6 +45,10 @@ class SESSION_EXPORT SessionManager {
SessionManager();
virtual ~SessionManager();
+ // Returns current SessionManager instance and NULL if it hasn't been
+ // initialized yet.
+ static SessionManager* Get();
+
SessionState session_state() const { return session_state_; }
virtual void SetSessionState(SessionState state);
@@ -52,11 +56,25 @@ class SESSION_EXPORT SessionManager {
// current session type / state.
void Start();
+ // Returns true when the browser has crashed and restarted during the current
+ // user's session.
+ static bool HasBrowserRestarted();
+
protected:
// Initializes SessionManager with delegate.
void Initialize(SessionManagerDelegate* delegate);
+ // Sets SessionManager instance.
+ static void SetInstance(SessionManager* session_manager);
+
private:
+ // Pointer to the existing SessionManager instance (if any).
+ // Set in ctor, reset in dtor. Not owned since specific implementation of
+ // SessionManager should decide on its own appropriate owner of SessionManager
+ // instance. For src/chrome implementation such place is
+ // g_browser_process->platform_part().
+ static SessionManager* instance;
+
SessionState session_state_;
scoped_ptr<SessionManagerDelegate> delegate_;