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