| 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/browser_process_platform_part.h" | 13 #include "chrome/browser/browser_process_platform_part.h" |
| 14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 15 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 16 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 16 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 17 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 17 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 18 #include "chrome/browser/signin/screenlock_bridge.h" | 18 #include "chrome/browser/signin/signin_screen_bridge.h" |
| 19 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 19 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
| 20 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 20 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "components/user_manager/user_manager.h" | 22 #include "components/user_manager/user_manager.h" |
| 23 #include "components/user_manager/user_type.h" | 23 #include "components/user_manager/user_type.h" |
| 24 #include "ui/wm/core/user_activity_detector.h" | 24 #include "ui/wm/core/user_activity_detector.h" |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 if (activity_detector->HasObserver(this)) | 114 if (activity_detector->HasObserver(this)) |
| 115 activity_detector->RemoveObserver(this); | 115 activity_detector->RemoveObserver(this); |
| 116 #endif | 116 #endif |
| 117 } | 117 } |
| 118 | 118 |
| 119 // static | 119 // static |
| 120 void UserSelectionScreen::FillUserDictionary( | 120 void UserSelectionScreen::FillUserDictionary( |
| 121 user_manager::User* user, | 121 user_manager::User* user, |
| 122 bool is_owner, | 122 bool is_owner, |
| 123 bool is_signin_to_add, | 123 bool is_signin_to_add, |
| 124 ScreenlockBridge::LockHandler::AuthType auth_type, | 124 SigninScreenBridge::LockHandler::AuthType auth_type, |
| 125 const std::vector<std::string>* public_session_recommended_locales, | 125 const std::vector<std::string>* public_session_recommended_locales, |
| 126 base::DictionaryValue* user_dict) { | 126 base::DictionaryValue* user_dict) { |
| 127 const std::string& user_id = user->email(); | 127 const std::string& user_id = user->email(); |
| 128 const bool is_public_session = | 128 const bool is_public_session = |
| 129 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; | 129 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; |
| 130 const bool is_supervised_user = | 130 const bool is_supervised_user = |
| 131 user->GetType() == user_manager::USER_TYPE_SUPERVISED; | 131 user->GetType() == user_manager::USER_TYPE_SUPERVISED; |
| 132 | 132 |
| 133 user_dict->SetString(kKeyUsername, user_id); | 133 user_dict->SetString(kKeyUsername, user_id); |
| 134 user_dict->SetString(kKeyEmailAddress, user->display_email()); | 134 user_dict->SetString(kKeyEmailAddress, user->display_email()); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 for (user_manager::UserList::const_iterator it = users.begin(); | 277 for (user_manager::UserList::const_iterator it = users.begin(); |
| 278 it != users.end(); | 278 it != users.end(); |
| 279 ++it) { | 279 ++it) { |
| 280 const std::string& user_id = (*it)->email(); | 280 const std::string& user_id = (*it)->email(); |
| 281 bool is_owner = (user_id == owner); | 281 bool is_owner = (user_id == owner); |
| 282 bool is_public_account = | 282 bool is_public_account = |
| 283 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 283 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
| 284 | 284 |
| 285 if ((is_public_account && !is_signin_to_add) || is_owner || | 285 if ((is_public_account && !is_signin_to_add) || is_owner || |
| 286 (!is_public_account && non_owner_count < max_non_owner_users)) { | 286 (!is_public_account && non_owner_count < max_non_owner_users)) { |
| 287 | |
| 288 if (!is_owner) | 287 if (!is_owner) |
| 289 ++non_owner_count; | 288 ++non_owner_count; |
| 290 if (is_owner && users_to_send.size() > kMaxUsers) { | 289 if (is_owner && users_to_send.size() > kMaxUsers) { |
| 291 // Owner is always in the list. | 290 // Owner is always in the list. |
| 292 users_to_send.insert(users_to_send.begin() + (kMaxUsers - 1), *it); | 291 users_to_send.insert(users_to_send.begin() + (kMaxUsers - 1), *it); |
| 293 while (users_to_send.size() > kMaxUsers) | 292 while (users_to_send.size() > kMaxUsers) |
| 294 users_to_send.erase(users_to_send.begin() + kMaxUsers); | 293 users_to_send.erase(users_to_send.begin() + kMaxUsers); |
| 295 } else if (users_to_send.size() < kMaxUsers) { | 294 } else if (users_to_send.size() < kMaxUsers) { |
| 296 users_to_send.push_back(*it); | 295 users_to_send.push_back(*it); |
| 297 } | 296 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 322 user_auth_type_map_.clear(); | 321 user_auth_type_map_.clear(); |
| 323 | 322 |
| 324 const std::vector<std::string> kEmptyRecommendedLocales; | 323 const std::vector<std::string> kEmptyRecommendedLocales; |
| 325 for (user_manager::UserList::const_iterator it = users_to_send.begin(); | 324 for (user_manager::UserList::const_iterator it = users_to_send.begin(); |
| 326 it != users_to_send.end(); | 325 it != users_to_send.end(); |
| 327 ++it) { | 326 ++it) { |
| 328 const std::string& user_id = (*it)->email(); | 327 const std::string& user_id = (*it)->email(); |
| 329 bool is_owner = (user_id == owner); | 328 bool is_owner = (user_id == owner); |
| 330 const bool is_public_account = | 329 const bool is_public_account = |
| 331 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); | 330 ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT); |
| 332 const ScreenlockBridge::LockHandler::AuthType initial_auth_type = | 331 const SigninScreenBridge::LockHandler::AuthType initial_auth_type = |
| 333 is_public_account | 332 is_public_account |
| 334 ? ScreenlockBridge::LockHandler::EXPAND_THEN_USER_CLICK | 333 ? SigninScreenBridge::LockHandler::EXPAND_THEN_USER_CLICK |
| 335 : (ShouldForceOnlineSignIn(*it) | 334 : (ShouldForceOnlineSignIn(*it) |
| 336 ? ScreenlockBridge::LockHandler::ONLINE_SIGN_IN | 335 ? SigninScreenBridge::LockHandler::ONLINE_SIGN_IN |
| 337 : ScreenlockBridge::LockHandler::OFFLINE_PASSWORD); | 336 : SigninScreenBridge::LockHandler::OFFLINE_PASSWORD); |
| 338 user_auth_type_map_[user_id] = initial_auth_type; | 337 user_auth_type_map_[user_id] = initial_auth_type; |
| 339 | 338 |
| 340 base::DictionaryValue* user_dict = new base::DictionaryValue(); | 339 base::DictionaryValue* user_dict = new base::DictionaryValue(); |
| 341 const std::vector<std::string>* public_session_recommended_locales = | 340 const std::vector<std::string>* public_session_recommended_locales = |
| 342 public_session_recommended_locales_.find(user_id) == | 341 public_session_recommended_locales_.find(user_id) == |
| 343 public_session_recommended_locales_.end() ? | 342 public_session_recommended_locales_.end() ? |
| 344 &kEmptyRecommendedLocales : | 343 &kEmptyRecommendedLocales : |
| 345 &public_session_recommended_locales_[user_id]; | 344 &public_session_recommended_locales_[user_id]; |
| 346 FillUserDictionary(*it, | 345 FillUserDictionary(*it, |
| 347 is_owner, | 346 is_owner, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 362 | 361 |
| 363 handler_->LoadUsers(users_list, show_guest_); | 362 handler_->LoadUsers(users_list, show_guest_); |
| 364 } | 363 } |
| 365 | 364 |
| 366 void UserSelectionScreen::HandleGetUsers() { | 365 void UserSelectionScreen::HandleGetUsers() { |
| 367 SendUserList(); | 366 SendUserList(); |
| 368 } | 367 } |
| 369 | 368 |
| 370 void UserSelectionScreen::SetAuthType( | 369 void UserSelectionScreen::SetAuthType( |
| 371 const std::string& username, | 370 const std::string& username, |
| 372 ScreenlockBridge::LockHandler::AuthType auth_type) { | 371 SigninScreenBridge::LockHandler::AuthType auth_type) { |
| 373 DCHECK(GetAuthType(username) != | 372 DCHECK(GetAuthType(username) != |
| 374 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD || | 373 SigninScreenBridge::LockHandler::FORCE_OFFLINE_PASSWORD || |
| 375 auth_type == ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD); | 374 auth_type == SigninScreenBridge::LockHandler::FORCE_OFFLINE_PASSWORD); |
| 376 user_auth_type_map_[username] = auth_type; | 375 user_auth_type_map_[username] = auth_type; |
| 377 } | 376 } |
| 378 | 377 |
| 379 ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType( | 378 SigninScreenBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType( |
| 380 const std::string& username) const { | 379 const std::string& username) const { |
| 381 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) | 380 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) |
| 382 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 381 return SigninScreenBridge::LockHandler::OFFLINE_PASSWORD; |
| 383 return user_auth_type_map_.find(username)->second; | 382 return user_auth_type_map_.find(username)->second; |
| 384 } | 383 } |
| 385 | 384 |
| 386 } // namespace chromeos | 385 } // namespace chromeos |
| OLD | NEW |