Index: ash/common/session/session_controller.cc |
diff --git a/ash/common/session/session_controller.cc b/ash/common/session/session_controller.cc |
index 12a9cec3b659a199a4d56921e3e032266f8adaa2..917ee17aca83651207e755ba9afb038a82fc2b6d 100644 |
--- a/ash/common/session/session_controller.cc |
+++ b/ash/common/session/session_controller.cc |
@@ -10,12 +10,26 @@ |
#include "ash/common/session/session_state_observer.h" |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
+#include "base/command_line.h" |
+#include "chromeos/chromeos_switches.h" |
#include "components/signin/core/account_id/account_id.h" |
#include "services/service_manager/public/cpp/connector.h" |
namespace ash { |
-SessionController::SessionController() {} |
+namespace { |
+ |
+session_manager::SessionState GetDefaultSessionState() { |
James Cook
2017/03/19 19:02:51
This function needs comments explaining why the de
xiyuan
2017/03/20 17:12:56
Done.
|
+ const bool start_with_user = |
+ base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ chromeos::switches::kLoginUser); |
+ return start_with_user ? session_manager::SessionState::ACTIVE |
+ : session_manager::SessionState::UNKNOWN; |
+} |
+ |
+} // namespace |
+ |
+SessionController::SessionController() : state_(GetDefaultSessionState()) {} |
SessionController::~SessionController() {} |
@@ -40,7 +54,7 @@ bool SessionController::IsActiveUserSessionStarted() const { |
} |
bool SessionController::CanLockScreen() const { |
- return can_lock_; |
+ return IsActiveUserSessionStarted() && can_lock_; |
} |
bool SessionController::IsScreenLocked() const { |
@@ -55,6 +69,10 @@ bool SessionController::IsUserSessionBlocked() const { |
return state_ != session_manager::SessionState::ACTIVE; |
} |
+bool SessionController::IsInSecondaryLoginScreen() const { |
+ return state_ == session_manager::SessionState::LOGIN_SECONDARY; |
+} |
+ |
session_manager::SessionState SessionController::GetSessionState() const { |
return state_; |
} |
@@ -64,6 +82,14 @@ const std::vector<mojom::UserSessionPtr>& SessionController::GetUserSessions() |
return user_sessions_; |
} |
+const mojom::UserSession* SessionController::GetUserSession( |
+ UserIndex index) const { |
+ if (index < 0 || index >= static_cast<UserIndex>(user_sessions_.size())) |
+ return nullptr; |
+ |
+ return user_sessions_[index].get(); |
+} |
+ |
void SessionController::LockScreen() { |
if (client_) |
client_->RequestLockScreen(); |
@@ -172,6 +198,19 @@ void SessionController::SetUserSessionOrder( |
} |
} |
+void SessionController::ClearUserSessionsForTest() { |
+ user_sessions_.clear(); |
+} |
+ |
+void SessionController::FlushMojoForTest() { |
+ client_.FlushForTesting(); |
+} |
+ |
+void SessionController::LockScreenAndFlushForTest() { |
+ LockScreen(); |
+ FlushMojoForTest(); |
+} |
+ |
void SessionController::SetSessionState(session_manager::SessionState state) { |
if (state_ == state) |
return; |