| Index: chrome/browser/ui/ash/session_controller_client.cc
|
| diff --git a/chrome/browser/ui/ash/session_controller_client.cc b/chrome/browser/ui/ash/session_controller_client.cc
|
| index 905fb906afdde41c96d460e67ec2af1c98604a01..6d15a762aa9f7a48b0bfe57ccdcb3f0207930ba6 100644
|
| --- a/chrome/browser/ui/ash/session_controller_client.cc
|
| +++ b/chrome/browser/ui/ash/session_controller_client.cc
|
| @@ -38,6 +38,7 @@
|
|
|
| using session_manager::Session;
|
| using session_manager::SessionManager;
|
| +using session_manager::SessionState;
|
| using user_manager::UserManager;
|
| using user_manager::User;
|
| using user_manager::UserList;
|
| @@ -188,12 +189,18 @@ void SessionControllerClient::CycleActiveUser(
|
| void SessionControllerClient::ActiveUserChanged(const User* active_user) {
|
| SendSessionInfoIfChanged();
|
|
|
| - // UserAddedToSession is not called for the primary user session so send its
|
| - // meta data here once.
|
| + // UserAddedToSession is not called for the primary user session so its meta
|
| + // data here needs to be sent to ash before setting user session order.
|
| + // However, ActiveUserChanged happens at different timing for primary user
|
| + // and secondary users. For primary user, it happens before user profile load.
|
| + // For secondary users, it happens after user profile load. This caused
|
| + // confusing down the path. Bail out here to defer the primary user session
|
| + // metadata sent until it becomes active so that ash side could expect a
|
| + // consistent state.
|
| + // TODO(xiyuan): Get rid of this after http://crbug.com/657149 refactoring.
|
| if (!primary_user_session_sent_ &&
|
| UserManager::Get()->GetPrimaryUser() == active_user) {
|
| - primary_user_session_sent_ = true;
|
| - SendUserSession(*active_user);
|
| + return;
|
| }
|
|
|
| SendUserSessionOrder();
|
| @@ -315,6 +322,17 @@ void SessionControllerClient::FlushForTesting() {
|
| }
|
|
|
| void SessionControllerClient::OnSessionStateChanged() {
|
| + // Sent the primary user metadata and user session order that are deferred
|
| + // from ActiveUserChanged before update session state.
|
| + if (!primary_user_session_sent_ &&
|
| + SessionManager::Get()->session_state() == SessionState::ACTIVE) {
|
| + DCHECK_EQ(UserManager::Get()->GetPrimaryUser(),
|
| + UserManager::Get()->GetActiveUser());
|
| + primary_user_session_sent_ = true;
|
| + SendUserSession(*UserManager::Get()->GetPrimaryUser());
|
| + SendUserSessionOrder();
|
| + }
|
| +
|
| SendSessionInfoIfChanged();
|
| }
|
|
|
|
|