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): Show optional intro dialog about multi-profiles feature |
| 1377 // based on user preferences. http://crbug.com/230862 |
| 1378 |
| 1379 // TODO(nkostylev): Move to a separate method in UserManager. |
| 1380 // http://crbug.com/230852 |
| 1381 bool is_signin_to_add = BaseLoginDisplayHost::default_host() && |
| 1382 UserManager::Get()->IsUserLoggedIn(); |
| 1383 |
1376 bool single_user = users.size() == 1; | 1384 bool single_user = users.size() == 1; |
1377 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 1385 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
1378 const std::string& email = (*it)->email(); | 1386 const std::string& email = (*it)->email(); |
| 1387 if (is_signin_to_add && (*it)->is_logged_in()) { |
| 1388 // Skip all users that are already signed in. |
| 1389 continue; |
| 1390 } |
| 1391 |
1379 std::string owner; | 1392 std::string owner; |
1380 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 1393 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
1381 bool is_owner = (email == owner); | 1394 bool is_owner = (email == owner); |
1382 | 1395 |
1383 if (non_owner_count < max_non_owner_users || is_owner) { | 1396 if (non_owner_count < max_non_owner_users || is_owner) { |
1384 DictionaryValue* user_dict = new DictionaryValue(); | 1397 DictionaryValue* user_dict = new DictionaryValue(); |
1385 FillUserDictionary(*it, is_owner, user_dict); | 1398 FillUserDictionary(*it, is_owner, user_dict); |
1386 bool is_public_account = | 1399 bool is_public_account = |
1387 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); | 1400 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); |
1388 bool signed_in = *it == UserManager::Get()->GetLoggedInUser(); | 1401 bool signed_in = *it == UserManager::Get()->GetLoggedInUser(); |
1389 // Single user check here is necessary because owner info might not be | 1402 // Single user check here is necessary because owner info might not be |
1390 // available when running into login screen on first boot. | 1403 // available when running into login screen on first boot. |
1391 // See http://crosbug.com/12723 | 1404 // See http://crosbug.com/12723 |
1392 user_dict->SetBoolean(kKeyCanRemove, | 1405 user_dict->SetBoolean(kKeyCanRemove, |
1393 !single_user && | 1406 !single_user && |
1394 !email.empty() && | 1407 !email.empty() && |
1395 !is_owner && | 1408 !is_owner && |
1396 !is_public_account && | 1409 !is_public_account && |
1397 !signed_in); | 1410 !signed_in && |
| 1411 !is_signin_to_add); |
1398 | 1412 |
1399 users_list.Append(user_dict); | 1413 users_list.Append(user_dict); |
1400 if (!is_owner) | 1414 if (!is_owner) |
1401 ++non_owner_count; | 1415 ++non_owner_count; |
1402 } | 1416 } |
1403 } | 1417 } |
1404 | 1418 |
1405 base::FundamentalValue animated_value(animated); | 1419 base::FundamentalValue animated_value(animated); |
1406 base::FundamentalValue guest_value(delegate_->IsShowGuest()); | 1420 base::FundamentalValue guest_value(delegate_->IsShowGuest()); |
1407 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", | 1421 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 if (!cros_settings) | 1762 if (!cros_settings) |
1749 return false; | 1763 return false; |
1750 | 1764 |
1751 // Offline login is allowed only when user pods are hidden. | 1765 // Offline login is allowed only when user pods are hidden. |
1752 bool show_pods; | 1766 bool show_pods; |
1753 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); | 1767 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); |
1754 return !show_pods; | 1768 return !show_pods; |
1755 } | 1769 } |
1756 | 1770 |
1757 } // namespace chromeos | 1771 } // namespace chromeos |
OLD | NEW |