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-16 18:20:44 +0000
committernkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 18:20:44 +0000
commitb88d2c6ea6193c41e1befeb7c4964ad2dbd794e6 (patch)
tree73f60798a961a0c98faed6ab7e771a39f7376822 /components/session_manager/core
parente9931bb5f68d403d1ee4947629165895b183324b (diff)
downloadchromium_src-b88d2c6ea6193c41e1befeb7c4964ad2dbd794e6.zip
chromium_src-b88d2c6ea6193c41e1befeb7c4964ad2dbd794e6.tar.gz
chromium_src-b88d2c6ea6193c41e1befeb7c4964ad2dbd794e6.tar.bz2
[cros] Define session_manager component with SessionManager base class
SessionManager is responsible for performing Chrome OS-specific steps to re-launch user session (after crash/stub or in tests) or pre-session UI such as out-of-box or login. ChromeSessionManager is chrome/browser implementation of SessionManager. SessionManager is initialized with specific delegate that is reponsible for initial behavior. These delegates are introduced, see ChromeSessionManager::CreateSessionManager(): * LoginOobeSessionManagerDelegate - launches either out-of-box or login UI, actual branching still happens in ShowLoginWizard() * RestoreAfterCrashSessionManagerDelegate - responsible for re-launching Chrome into existing user session, happens after browser process crash or in "stub user" session. * StubLoginSessionManagerDelegate - starts "stub user" session, when executed on non-CrOS machine w/o parameters or in tests. Extends RestoreAfterCrashSessionManagerDelegate. * KioskAutoLauncherSessionManagerDelegate - automatically starts kiosk app session. Code move in ChromeBrowserMainPartsChromeos: * OptionallyRunChromeOSLoginManager() -> ChromeSessionManager::CreateSessionManager() * RunAutoLaunchKioskApp() -> KioskAutoLauncherSessionManagerDelegate * Session restore code in PostProfileInit() -> RestoreAfterCrashSessionManagerDelegate * Blocks in OptionallyRunChromeOSLoginManager -> to delegates. BUG=387610 Review URL: https://codereview.chromium.org/363613004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/session_manager/core')
-rw-r--r--components/session_manager/core/session_manager.cc49
-rw-r--r--components/session_manager/core/session_manager.h86
2 files changed, 135 insertions, 0 deletions
diff --git a/components/session_manager/core/session_manager.cc b/components/session_manager/core/session_manager.cc
new file mode 100644
index 0000000..3fff748
--- /dev/null
+++ b/components/session_manager/core/session_manager.cc
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/session_manager/core/session_manager.h"
+
+#include "base/logging.h"
+
+namespace session_manager {
+
+SessionManager::SessionManager() : session_state_(SESSION_STATE_UNKNOWN) {
+}
+
+SessionManager::~SessionManager() {
+}
+
+void SessionManager::SetSessionState(SessionState state) {
+ VLOG(1) << "Changing session state to: " << state;
+
+ if (session_state_ != state) {
+ // TODO(nkostylev): Notify observers about the state change.
+ // TODO(nkostylev): Add code to process session state change and probably
+ // replace delegate_ if needed.
+ session_state_ = state;
+ }
+}
+
+void SessionManager::Initialize(SessionManagerDelegate* delegate) {
+ DCHECK(delegate);
+ delegate_.reset(delegate);
+ delegate_->SetSessionManager(this);
+}
+
+void SessionManager::Start() {
+ delegate_->Start();
+}
+
+SessionManagerDelegate::SessionManagerDelegate() : session_manager_(NULL) {
+}
+
+SessionManagerDelegate::~SessionManagerDelegate() {
+}
+
+void SessionManagerDelegate::SetSessionManager(
+ session_manager::SessionManager* session_manager) {
+ session_manager_ = session_manager;
+}
+
+} // namespace session_manager
diff --git a/components/session_manager/core/session_manager.h b/components/session_manager/core/session_manager.h
new file mode 100644
index 0000000..e728e7f
--- /dev/null
+++ b/components/session_manager/core/session_manager.h
@@ -0,0 +1,86 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_
+#define COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "components/session_manager/session_manager_export.h"
+
+namespace session_manager {
+
+class SessionManagerDelegate;
+
+// TODO(nkostylev): Get rid/consolidate with:
+// ash::SessionStateDelegate::SessionState and chromeos::LoggedInState.
+enum SESSION_EXPORT SessionState {
+ // Default value, when session state hasn't been initialized yet.
+ SESSION_STATE_UNKNOWN = 0,
+
+ // Running out of box UI.
+ SESSION_STATE_OOBE,
+
+ // Running login UI (primary user) but user sign in hasn't completed yet.
+ SESSION_STATE_LOGIN_PRIMARY,
+
+ // Running login UI (primary or secondary user), user sign in has been
+ // completed but login UI hasn't been hidden yet. This means that either
+ // some session initialization is happening or user has to go through some
+ // UI flow on the same login UI like select avatar, agree to terms of
+ // service etc.
+ SESSION_STATE_LOGGED_IN_NOT_ACTIVE,
+
+ // A user(s) has logged in *and* login UI is hidden i.e. user session is
+ // not blocked.
+ SESSION_STATE_ACTIVE,
+
+ // Same as SESSION_STATE_LOGIN_PRIMARY but for multi-profiles sign in i.e.
+ // when there's at least one user already active in the session.
+ SESSION_STATE_LOGIN_SECONDARY,
+};
+
+class SESSION_EXPORT SessionManager {
+ public:
+ SessionManager();
+ virtual ~SessionManager();
+
+ SessionState session_state() const { return session_state_; }
+ virtual void SetSessionState(SessionState state);
+
+ // Let session delegate executed on its plan of actions depending on the
+ // current session type / state.
+ void Start();
+
+ protected:
+ // Initializes SessionManager with delegate.
+ void Initialize(SessionManagerDelegate* delegate);
+
+ private:
+ SessionState session_state_;
+ scoped_ptr<SessionManagerDelegate> delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(SessionManager);
+};
+
+class SESSION_EXPORT SessionManagerDelegate {
+ public:
+ SessionManagerDelegate();
+ virtual ~SessionManagerDelegate();
+
+ virtual void SetSessionManager(
+ session_manager::SessionManager* session_manager);
+
+ // Executes specific actions defined by this delegate.
+ virtual void Start() = 0;
+
+ protected:
+ session_manager::SessionManager* session_manager_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SessionManagerDelegate);
+};
+
+} // namespace session_manager
+
+#endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_