Update V8 to version 4.6.62.
[chromium-blink-merge.git] / components / session_manager / core / session_manager.cc
blobfe4669c5a49677320b5e2fcfe1f20445b579af42
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/session_manager/core/session_manager.h"
7 #include "base/logging.h"
9 #if defined(OS_CHROMEOS)
10 #include "base/command_line.h"
11 #include "base/sys_info.h"
12 #include "chromeos/chromeos_switches.h"
13 #endif
15 namespace session_manager {
17 // static
18 SessionManager* SessionManager::instance = NULL;
20 SessionManager::SessionManager() : session_state_(SESSION_STATE_UNKNOWN) {
21 DCHECK(!SessionManager::Get());
22 SessionManager::SetInstance(this);
25 SessionManager::~SessionManager() {
26 DCHECK(instance == this);
27 SessionManager::SetInstance(NULL);
30 // static
31 SessionManager* SessionManager::Get() {
32 return SessionManager::instance;
35 void SessionManager::SetSessionState(SessionState state) {
36 VLOG(1) << "Changing session state to: " << state;
38 if (session_state_ != state) {
39 // TODO(nkostylev): Notify observers about the state change.
40 // TODO(nkostylev): Add code to process session state change and probably
41 // replace delegate_ if needed.
42 session_state_ = state;
46 void SessionManager::Initialize(SessionManagerDelegate* delegate) {
47 DCHECK(delegate);
48 delegate_.reset(delegate);
49 delegate_->SetSessionManager(this);
52 // static
53 void SessionManager::SetInstance(SessionManager* session_manager) {
54 SessionManager::instance = session_manager;
57 void SessionManager::Start() {
58 delegate_->Start();
61 // static
62 bool SessionManager::HasBrowserRestarted() {
63 #if defined(OS_CHROMEOS)
64 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
65 return base::SysInfo::IsRunningOnChromeOS() &&
66 command_line->HasSwitch(chromeos::switches::kLoginUser);
67 #else
68 return false;
69 #endif
72 SessionManagerDelegate::SessionManagerDelegate() : session_manager_(NULL) {
75 SessionManagerDelegate::~SessionManagerDelegate() {
78 void SessionManagerDelegate::SetSessionManager(
79 session_manager::SessionManager* session_manager) {
80 session_manager_ = session_manager;
83 } // namespace session_manager