| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/ash/session_controller_client.h" | 5 #include "chrome/browser/ui/ash/session_controller_client.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/public/cpp/session_types.h" | 10 #include "ash/public/cpp/session_types.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 void SessionControllerClient::SendUserSession(const User& user) { | 385 void SessionControllerClient::SendUserSession(const User& user) { |
| 386 ash::mojom::UserSessionPtr user_session = UserToUserSession(user); | 386 ash::mojom::UserSessionPtr user_session = UserToUserSession(user); |
| 387 | 387 |
| 388 // Bail if the user has no session. Currently the only code path that hits | 388 // Bail if the user has no session. Currently the only code path that hits |
| 389 // this condition is from OnUserImageChanged when user images are changed | 389 // this condition is from OnUserImageChanged when user images are changed |
| 390 // on the login screen (e.g. policy change that adds a public session user, | 390 // on the login screen (e.g. policy change that adds a public session user, |
| 391 // or tests that create new users on the login screen). | 391 // or tests that create new users on the login screen). |
| 392 if (!user_session) | 392 if (!user_session) |
| 393 return; | 393 return; |
| 394 | 394 |
| 395 // TODO(jamescook): Only send if it changed. This will require an Equals() | 395 if (user_session != last_sent_user_session_) { |
| 396 // method for gfx::ImageSkia to allow mojom::UserSession comparison. | 396 last_sent_user_session_ = user_session->Clone(); |
| 397 // http://crbug.com/714689 | 397 session_controller_->UpdateUserSession(std::move(user_session)); |
| 398 session_controller_->UpdateUserSession(std::move(user_session)); | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 void SessionControllerClient::SendUserSessionOrder() { | 401 void SessionControllerClient::SendUserSessionOrder() { |
| 402 UserManager* const user_manager = UserManager::Get(); | 402 UserManager* const user_manager = UserManager::Get(); |
| 403 | 403 |
| 404 const UserList logged_in_users = user_manager->GetLoggedInUsers(); | 404 const UserList logged_in_users = user_manager->GetLoggedInUsers(); |
| 405 std::vector<uint32_t> user_session_ids; | 405 std::vector<uint32_t> user_session_ids; |
| 406 for (auto* user : user_manager->GetLRULoggedInUsers()) { | 406 for (auto* user : user_manager->GetLRULoggedInUsers()) { |
| 407 const uint32_t user_session_id = GetSessionId(*user); | 407 const uint32_t user_session_id = GetSessionId(*user); |
| 408 DCHECK_NE(0u, user_session_id); | 408 DCHECK_NE(0u, user_session_id); |
| 409 user_session_ids.push_back(user_session_id); | 409 user_session_ids.push_back(user_session_id); |
| 410 } | 410 } |
| 411 | 411 |
| 412 session_controller_->SetUserSessionOrder(user_session_ids); | 412 session_controller_->SetUserSessionOrder(user_session_ids); |
| 413 } | 413 } |
| OLD | NEW |