| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 while (users_to_send.size() > kMaxUsers) | 216 while (users_to_send.size() > kMaxUsers) |
| 217 users_to_send.erase(users_to_send.begin() + kMaxUsers); | 217 users_to_send.erase(users_to_send.begin() + kMaxUsers); |
| 218 } else if (users_to_send.size() < kMaxUsers) { | 218 } else if (users_to_send.size() < kMaxUsers) { |
| 219 users_to_send.push_back(*it); | 219 users_to_send.push_back(*it); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 return users_to_send; | 223 return users_to_send; |
| 224 } | 224 } |
| 225 | 225 |
| 226 void UserSelectionScreen::SendUserList(bool animated) { | 226 void UserSelectionScreen::SendUserList() { |
| 227 base::ListValue users_list; | 227 base::ListValue users_list; |
| 228 const UserList& users = GetUsers(); | 228 const UserList& users = GetUsers(); |
| 229 | 229 |
| 230 // TODO(nkostylev): Move to a separate method in UserManager. | 230 // TODO(nkostylev): Move to a separate method in UserManager. |
| 231 // http://crbug.com/230852 | 231 // http://crbug.com/230852 |
| 232 bool single_user = users.size() == 1; | 232 bool single_user = users.size() == 1; |
| 233 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && | 233 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && |
| 234 UserManager::Get()->IsUserLoggedIn(); | 234 UserManager::Get()->IsUserLoggedIn(); |
| 235 std::string owner; | 235 std::string owner; |
| 236 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 236 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
| 237 | 237 |
| 238 policy::BrowserPolicyConnectorChromeOS* connector = | 238 policy::BrowserPolicyConnectorChromeOS* connector = |
| 239 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 239 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 240 bool is_enterprise_managed = connector->IsEnterpriseManaged(); | 240 bool is_enterprise_managed = connector->IsEnterpriseManaged(); |
| 241 | 241 |
| 242 const UserList users_to_send = PrepareUserListForSending(users, | 242 const UserList users_to_send = PrepareUserListForSending(users, |
| 243 owner, | 243 owner, |
| 244 is_signin_to_add); | 244 is_signin_to_add); |
| 245 | 245 |
| 246 user_auth_type_map_.clear(); | 246 user_auth_type_map_.clear(); |
| 247 | 247 |
| 248 for (UserList::const_iterator it = users_to_send.begin(); | 248 for (UserList::const_iterator it = users_to_send.begin(); |
| 249 it != users_to_send.end(); | 249 it != users_to_send.end(); |
| 250 ++it) { | 250 ++it) { |
| 251 const std::string& user_id = (*it)->email(); | 251 const std::string& user_id = (*it)->email(); |
| 252 bool is_owner = (user_id == owner); | 252 bool is_owner = (user_id == owner); |
| 253 bool is_public_account = | 253 const bool is_public_account = |
| 254 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 254 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
| 255 ScreenlockBridge::LockHandler::AuthType initial_auth_type = | 255 const ScreenlockBridge::LockHandler::AuthType initial_auth_type = |
| 256 ShouldForceOnlineSignIn(*it) | 256 is_public_account |
| 257 ? ScreenlockBridge::LockHandler::ONLINE_SIGN_IN | 257 ? ScreenlockBridge::LockHandler::EXPAND_THEN_USER_CLICK |
| 258 : ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 258 : (ShouldForceOnlineSignIn(*it) |
| 259 ? ScreenlockBridge::LockHandler::ONLINE_SIGN_IN |
| 260 : ScreenlockBridge::LockHandler::OFFLINE_PASSWORD); |
| 259 user_auth_type_map_[user_id] = initial_auth_type; | 261 user_auth_type_map_[user_id] = initial_auth_type; |
| 260 | 262 |
| 261 base::DictionaryValue* user_dict = new base::DictionaryValue(); | 263 base::DictionaryValue* user_dict = new base::DictionaryValue(); |
| 262 FillUserDictionary( | 264 FillUserDictionary( |
| 263 *it, is_owner, is_signin_to_add, initial_auth_type, user_dict); | 265 *it, is_owner, is_signin_to_add, initial_auth_type, user_dict); |
| 264 bool signed_in = (*it)->is_logged_in(); | 266 bool signed_in = (*it)->is_logged_in(); |
| 265 // Single user check here is necessary because owner info might not be | 267 // Single user check here is necessary because owner info might not be |
| 266 // available when running into login screen on first boot. | 268 // available when running into login screen on first boot. |
| 267 // See http://crosbug.com/12723 | 269 // See http://crosbug.com/12723 |
| 268 bool can_remove_user = | 270 bool can_remove_user = |
| 269 ((!single_user || is_enterprise_managed) && !user_id.empty() && | 271 ((!single_user || is_enterprise_managed) && !user_id.empty() && |
| 270 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); | 272 !is_owner && !is_public_account && !signed_in && !is_signin_to_add); |
| 271 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); | 273 user_dict->SetBoolean(kKeyCanRemove, can_remove_user); |
| 272 users_list.Append(user_dict); | 274 users_list.Append(user_dict); |
| 273 } | 275 } |
| 274 | 276 |
| 275 handler_->LoadUsers(users_list, animated, show_guest_); | 277 handler_->LoadUsers(users_list, show_guest_); |
| 276 } | 278 } |
| 277 | 279 |
| 278 void UserSelectionScreen::HandleGetUsers() { | 280 void UserSelectionScreen::HandleGetUsers() { |
| 279 SendUserList(false); | 281 SendUserList(); |
| 280 } | 282 } |
| 281 | 283 |
| 282 void UserSelectionScreen::SetAuthType( | 284 void UserSelectionScreen::SetAuthType( |
| 283 const std::string& username, | 285 const std::string& username, |
| 284 ScreenlockBridge::LockHandler::AuthType auth_type) { | 286 ScreenlockBridge::LockHandler::AuthType auth_type) { |
| 285 user_auth_type_map_[username] = auth_type; | 287 user_auth_type_map_[username] = auth_type; |
| 286 } | 288 } |
| 287 | 289 |
| 288 ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType( | 290 ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType( |
| 289 const std::string& username) const { | 291 const std::string& username) const { |
| 290 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) | 292 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) |
| 291 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 293 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; |
| 292 return user_auth_type_map_.find(username)->second; | 294 return user_auth_type_map_.find(username)->second; |
| 293 } | 295 } |
| 294 | 296 |
| 295 } // namespace chromeos | 297 } // namespace chromeos |
| OLD | NEW |