| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/login/screens/user_selection_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 while (users_to_send.size() > kMaxUsers) | 215 while (users_to_send.size() > kMaxUsers) |
| 216 users_to_send.erase(users_to_send.begin() + kMaxUsers); | 216 users_to_send.erase(users_to_send.begin() + kMaxUsers); |
| 217 } else if (users_to_send.size() < kMaxUsers) { | 217 } else if (users_to_send.size() < kMaxUsers) { |
| 218 users_to_send.push_back(*it); | 218 users_to_send.push_back(*it); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 return users_to_send; | 222 return users_to_send; |
| 223 } | 223 } |
| 224 | 224 |
| 225 void UserSelectionScreen::SendUserList(bool animated) { | 225 void UserSelectionScreen::SendUserList() { |
| 226 base::ListValue users_list; | 226 base::ListValue users_list; |
| 227 const UserList& users = GetUsers(); | 227 const UserList& users = GetUsers(); |
| 228 | 228 |
| 229 // TODO(nkostylev): Move to a separate method in UserManager. | 229 // TODO(nkostylev): Move to a separate method in UserManager. |
| 230 // http://crbug.com/230852 | 230 // http://crbug.com/230852 |
| 231 bool single_user = users.size() == 1; | 231 bool single_user = users.size() == 1; |
| 232 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && | 232 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && |
| 233 UserManager::Get()->IsUserLoggedIn(); | 233 UserManager::Get()->IsUserLoggedIn(); |
| 234 std::string owner; | 234 std::string owner; |
| 235 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 235 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 264 // Single user check here is necessary because owner info might not be | 264 // Single user check here is necessary because owner info might not be |
| 265 // available when running into login screen on first boot. | 265 // available when running into login screen on first boot. |
| 266 // See http://crosbug.com/12723 | 266 // See http://crosbug.com/12723 |
| 267 bool can_remove_user = | 267 bool can_remove_user = |
| 268 ((!single_user || is_enterprise_managed) && !user_id.empty() && | 268 ((!single_user || is_enterprise_managed) && !user_id.empty() && |
| 269 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); | 269 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); |
| 270 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); | 270 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); |
| 271 users_list.Append(user_dict); | 271 users_list.Append(user_dict); |
| 272 } | 272 } |
| 273 | 273 |
| 274 handler_->LoadUsers(users_list, animated, show_guest_); | 274 handler_->LoadUsers(users_list, show_guest_); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void UserSelectionScreen::HandleGetUsers() { | 277 void UserSelectionScreen::HandleGetUsers() { |
| 278 SendUserList(false); | 278 SendUserList(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void UserSelectionScreen::SetAuthType( | 281 void UserSelectionScreen::SetAuthType( |
| 282 const std::string& username, | 282 const std::string& username, |
| 283 ScreenlockBridge::LockHandler::AuthType auth_type) { | 283 ScreenlockBridge::LockHandler::AuthType auth_type) { |
| 284 user_auth_type_map_[username] = auth_type; | 284 user_auth_type_map_[username] = auth_type; |
| 285 } | 285 } |
| 286 | 286 |
| 287 ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType( | 287 ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType( |
| 288 const std::string& username) const { | 288 const std::string& username) const { |
| 289 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) | 289 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) |
| 290 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 290 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; |
| 291 return user_auth_type_map_.find(username)->second; | 291 return user_auth_type_map_.find(username)->second; |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace chromeos | 294 } // namespace chromeos |
| OLD | NEW |