OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/webui/chromeos/login/signin_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 void SigninScreenHandler::SendUserList(bool animated) { | 1366 void SigninScreenHandler::SendUserList(bool animated) { |
1367 if (!delegate_) | 1367 if (!delegate_) |
1368 return; | 1368 return; |
1369 | 1369 |
1370 size_t max_non_owner_users = kMaxUsers - 1; | 1370 size_t max_non_owner_users = kMaxUsers - 1; |
1371 size_t non_owner_count = 0; | 1371 size_t non_owner_count = 0; |
1372 | 1372 |
1373 ListValue users_list; | 1373 ListValue users_list; |
1374 const UserList& users = delegate_->GetUsers(); | 1374 const UserList& users = delegate_->GetUsers(); |
1375 | 1375 |
| 1376 // TODO(nkostylev): Move to a separate method in UserManager. |
| 1377 bool is_signin_to_add = BaseLoginDisplayHost::default_host() && |
| 1378 UserManager::Get()->IsUserLoggedIn(); |
| 1379 |
1376 bool single_user = users.size() == 1; | 1380 bool single_user = users.size() == 1; |
1377 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 1381 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
1378 const std::string& email = (*it)->email(); | 1382 const std::string& email = (*it)->email(); |
| 1383 if (is_signin_to_add && (*it)->is_logged_in()) { |
| 1384 // Skip all users that are already signed in. |
| 1385 continue; |
| 1386 } |
| 1387 |
1379 std::string owner; | 1388 std::string owner; |
1380 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 1389 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
1381 bool is_owner = (email == owner); | 1390 bool is_owner = (email == owner); |
1382 | 1391 |
1383 if (non_owner_count < max_non_owner_users || is_owner) { | 1392 if (non_owner_count < max_non_owner_users || is_owner) { |
1384 DictionaryValue* user_dict = new DictionaryValue(); | 1393 DictionaryValue* user_dict = new DictionaryValue(); |
1385 FillUserDictionary(*it, is_owner, user_dict); | 1394 FillUserDictionary(*it, is_owner, user_dict); |
1386 bool is_public_account = | 1395 bool is_public_account = |
1387 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); | 1396 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); |
1388 bool signed_in = *it == UserManager::Get()->GetLoggedInUser(); | 1397 bool signed_in = *it == UserManager::Get()->GetLoggedInUser(); |
1389 // Single user check here is necessary because owner info might not be | 1398 // Single user check here is necessary because owner info might not be |
1390 // available when running into login screen on first boot. | 1399 // available when running into login screen on first boot. |
1391 // See http://crosbug.com/12723 | 1400 // See http://crosbug.com/12723 |
1392 user_dict->SetBoolean(kKeyCanRemove, | 1401 user_dict->SetBoolean(kKeyCanRemove, |
1393 !single_user && | 1402 !single_user && |
1394 !email.empty() && | 1403 !email.empty() && |
1395 !is_owner && | 1404 !is_owner && |
1396 !is_public_account && | 1405 !is_public_account && |
1397 !signed_in); | 1406 !signed_in && |
| 1407 !is_signin_to_add); |
1398 | 1408 |
1399 users_list.Append(user_dict); | 1409 users_list.Append(user_dict); |
1400 if (!is_owner) | 1410 if (!is_owner) |
1401 ++non_owner_count; | 1411 ++non_owner_count; |
1402 } | 1412 } |
1403 } | 1413 } |
1404 | 1414 |
1405 base::FundamentalValue animated_value(animated); | 1415 base::FundamentalValue animated_value(animated); |
1406 base::FundamentalValue guest_value(delegate_->IsShowGuest()); | 1416 base::FundamentalValue guest_value(delegate_->IsShowGuest()); |
1407 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", | 1417 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 if (!cros_settings) | 1758 if (!cros_settings) |
1749 return false; | 1759 return false; |
1750 | 1760 |
1751 // Offline login is allowed only when user pods are hidden. | 1761 // Offline login is allowed only when user pods are hidden. |
1752 bool show_pods; | 1762 bool show_pods; |
1753 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); | 1763 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); |
1754 return !show_pods; | 1764 return !show_pods; |
1755 } | 1765 } |
1756 | 1766 |
1757 } // namespace chromeos | 1767 } // namespace chromeos |
OLD | NEW |