Commit 5984ed45 authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

ash: Remove default session state hack

The hack is needed because session state was sent to ash
via mojo asynchrounously and this is no longer the case.

Bug: 958214
Change-Id: I61ace0a6293dff480a0fceae66ac8344c22e17fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1603484Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658291}
parent 210b441b
......@@ -31,7 +31,6 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "chromeos/constants/chromeos_switches.h"
#include "components/account_id/account_id.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
......@@ -45,32 +44,9 @@ using session_manager::SessionState;
namespace ash {
namespace {
// Get the default session state. Default session state is ACTIVE when the
// process starts with a user session, i.e. the process has kLoginUser command
// line switch. This is needed because ash focus rules depends on whether
// session is blocked to pick an activatable window and chrome needs to create a
// focused browser window when starting with a user session (both in production
// and in tests). Using ACTIVE as default in this situation allows chrome to run
// without having to wait for session state to reach to ash. For other cases
// (oobe/login), there is only one login window. The login window always gets
// focus so default session state does not matter. Use UNKNOWN and wait for
// chrome to update ash for such cases.
SessionState GetDefaultSessionState() {
const bool start_with_user =
base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kLoginUser);
return start_with_user ? SessionState::ACTIVE : SessionState::UNKNOWN;
}
} // namespace
SessionControllerImpl::SessionControllerImpl(
service_manager::Connector* connector)
: state_(GetDefaultSessionState()),
connector_(connector),
weak_ptr_factory_(this) {}
: connector_(connector) {}
SessionControllerImpl::~SessionControllerImpl() {
// Abort pending start lock request.
......
......@@ -270,7 +270,7 @@ class ASH_EXPORT SessionControllerImpl : public SessionController {
bool is_running_in_app_mode_ = false;
bool is_demo_session_ = false;
AddUserSessionPolicy add_user_session_policy_ = AddUserSessionPolicy::ALLOWED;
session_manager::SessionState state_;
session_manager::SessionState state_ = session_manager::SessionState::UNKNOWN;
// Cached user session info sorted by the order from SetUserSessionOrder.
// Currently the session manager code (chrome) sets a LRU order with the
......@@ -324,7 +324,7 @@ class ASH_EXPORT SessionControllerImpl : public SessionController {
std::map<AccountId, std::unique_ptr<PrefService>> per_user_prefs_;
PrefService* last_active_user_prefs_ = nullptr;
base::WeakPtrFactory<SessionControllerImpl> weak_ptr_factory_;
base::WeakPtrFactory<SessionControllerImpl> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(SessionControllerImpl);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment