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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 NOTREACHED(); | 50 NOTREACHED(); |
51 return 0u; | 51 return 0u; |
52 } | 52 } |
53 | 53 |
54 ash::mojom::UserSessionPtr UserToUserSession(const User& user) { | 54 ash::mojom::UserSessionPtr UserToUserSession(const User& user) { |
55 ash::mojom::UserSessionPtr session = ash::mojom::UserSession::New(); | 55 ash::mojom::UserSessionPtr session = ash::mojom::UserSession::New(); |
56 session->session_id = GetSessionId(&user); | 56 session->session_id = GetSessionId(&user); |
57 session->type = user.GetType(); | 57 session->type = user.GetType(); |
58 // TODO(xiyuan): Add type map for AccountId. | 58 session->account_id = user.GetAccountId(); |
59 session->serialized_account_id = user.GetAccountId().Serialize(); | |
60 session->display_name = base::UTF16ToUTF8(user.display_name()); | 59 session->display_name = base::UTF16ToUTF8(user.display_name()); |
61 session->display_email = user.display_email(); | 60 session->display_email = user.display_email(); |
62 | 61 |
63 // TODO(xiyuan): Observe user image change and update. | 62 // TODO(xiyuan): Observe user image change and update. |
64 // Tracked in http://crbug.com/670422 | 63 // Tracked in http://crbug.com/670422 |
65 // TODO(xiyuan): Support multiple scale factor. | 64 // TODO(xiyuan): Support multiple scale factor. |
66 session->avatar = *user.GetImage().bitmap(); | 65 session->avatar = *user.GetImage().bitmap(); |
67 if (session->avatar.isNull()) { | 66 if (session->avatar.isNull()) { |
68 session->avatar = *ResourceBundle::GetSharedInstance() | 67 session->avatar = *ResourceBundle::GetSharedInstance() |
69 .GetImageSkiaNamed(IDR_PROFILE_PICTURE_LOADING) | 68 .GetImageSkiaNamed(IDR_PROFILE_PICTURE_LOADING) |
(...skipping 27 matching lines...) Expand all Loading... |
97 g_instance = nullptr; | 96 g_instance = nullptr; |
98 | 97 |
99 session_manager::SessionManager::Get()->RemoveObserver(this); | 98 session_manager::SessionManager::Get()->RemoveObserver(this); |
100 UserManager::Get()->RemoveSessionStateObserver(this); | 99 UserManager::Get()->RemoveSessionStateObserver(this); |
101 } | 100 } |
102 | 101 |
103 void SessionControllerClient::RequestLockScreen() { | 102 void SessionControllerClient::RequestLockScreen() { |
104 DoLockScreen(); | 103 DoLockScreen(); |
105 } | 104 } |
106 | 105 |
107 void SessionControllerClient::SwitchActiveUser( | 106 void SessionControllerClient::SwitchActiveUser(const AccountId& account_id) { |
108 const std::string& serialized_account_id) { | |
109 // TODO(xiyuan): Add type map for AccountId. | |
110 AccountId account_id(EmptyAccountId()); | |
111 if (!AccountId::Deserialize(serialized_account_id, &account_id)) { | |
112 LOG(ERROR) << "Bad account id for SwitchActiveUser."; | |
113 return; | |
114 } | |
115 | |
116 DoSwitchActiveUser(account_id); | 107 DoSwitchActiveUser(account_id); |
117 } | 108 } |
118 | 109 |
119 void SessionControllerClient::CycleActiveUser(bool next_user) { | 110 void SessionControllerClient::CycleActiveUser(bool next_user) { |
120 DoCycleActiveUser(next_user); | 111 DoCycleActiveUser(next_user); |
121 } | 112 } |
122 | 113 |
123 void SessionControllerClient::ActiveUserChanged(const User* active_user) { | 114 void SessionControllerClient::ActiveUserChanged(const User* active_user) { |
124 SendSessionInfoIfChanged(); | 115 SendSessionInfoIfChanged(); |
125 | 116 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 void SessionControllerClient::SendUserSessionOrder() { | 264 void SessionControllerClient::SendUserSessionOrder() { |
274 UserManager* const user_manager = UserManager::Get(); | 265 UserManager* const user_manager = UserManager::Get(); |
275 | 266 |
276 const UserList logged_in_users = user_manager->GetLoggedInUsers(); | 267 const UserList logged_in_users = user_manager->GetLoggedInUsers(); |
277 std::vector<uint32_t> user_session_ids; | 268 std::vector<uint32_t> user_session_ids; |
278 for (auto* user : user_manager->GetLRULoggedInUsers()) | 269 for (auto* user : user_manager->GetLRULoggedInUsers()) |
279 user_session_ids.push_back(GetSessionId(user)); | 270 user_session_ids.push_back(GetSessionId(user)); |
280 | 271 |
281 session_controller_->SetUserSessionOrder(user_session_ids); | 272 session_controller_->SetUserSessionOrder(user_session_ids); |
282 } | 273 } |
OLD | NEW |