summaryrefslogtreecommitdiffstats
path: root/components/session_manager/core
diff options
context:
space:
mode:
authornkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-02 05:44:13 +0000
committernkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-02 05:44:13 +0000
commitbabc14800b314b6ec87e1f1dad635291ebe04dd6 (patch)
tree719249b6addeea72b424d49e55dbe9181fbdeedc /components/session_manager/core
parent487c445477ef9bf0ec133f0cf6ae7a4f501e01fc (diff)
downloadchromium_src-babc14800b314b6ec87e1f1dad635291ebe04dd6.zip
chromium_src-babc14800b314b6ec87e1f1dad635291ebe04dd6.tar.gz
chromium_src-babc14800b314b6ec87e1f1dad635291ebe04dd6.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 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=286187 Review URL: https://codereview.chromium.org/417623002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287153 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_;