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/chromeos/login/user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/user_manager_impl.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
828 local_state->GetDictionary(kUserDisplayEmail); | 828 local_state->GetDictionary(kUserDisplayEmail); |
829 | 829 |
830 // Load regular users and locally managed users. | 830 // Load regular users and locally managed users. |
831 std::vector<std::string> regular_users; | 831 std::vector<std::string> regular_users; |
832 std::set<std::string> regular_users_set; | 832 std::set<std::string> regular_users_set; |
833 ParseUserList(*prefs_regular_users, std::set<std::string>(), "", | 833 ParseUserList(*prefs_regular_users, std::set<std::string>(), "", |
834 ®ular_users, ®ular_users_set); | 834 ®ular_users, ®ular_users_set); |
835 for (std::vector<std::string>::const_iterator it = regular_users.begin(); | 835 for (std::vector<std::string>::const_iterator it = regular_users.begin(); |
836 it != regular_users.end(); ++it) { | 836 it != regular_users.end(); ++it) { |
837 User* user = NULL; | 837 User* user = NULL; |
838 if (gaia::ExtractDomainName(*it) == | 838 const std::string domain = gaia::ExtractDomainName(*it); |
839 UserManager::kLocallyManagedUserDomain) { | 839 if (domain == UserManager::kLocallyManagedUserDomain) { |
840 user = User::CreateLocallyManagedUser(*it); | 840 user = User::CreateLocallyManagedUser(*it); |
841 } else { | 841 } else { |
842 user = User::CreateRegularUser(*it); | 842 user = User::CreateRegularUser(*it); |
843 user->set_oauth_token_status(LoadUserOAuthStatus(*it)); | 843 user->set_oauth_token_status(LoadUserOAuthStatus(*it)); |
844 } | 844 } |
845 users_.push_back(user); | 845 users_.push_back(user); |
846 | 846 |
847 string16 display_name; | 847 string16 display_name; |
848 if (prefs_display_names->GetStringWithoutPathExpansion(*it, | 848 if (prefs_display_names->GetStringWithoutPathExpansion(*it, |
849 &display_name)) { | 849 &display_name)) { |
(...skipping 28 matching lines...) Expand all Loading... | |
878 // Schedule a callback if device policy has not yet been verified. | 878 // Schedule a callback if device policy has not yet been verified. |
879 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( | 879 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( |
880 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies, | 880 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies, |
881 base::Unretained(this)))) { | 881 base::Unretained(this)))) { |
882 return; | 882 return; |
883 } | 883 } |
884 | 884 |
885 cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled, | 885 cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled, |
886 &ephemeral_users_enabled_); | 886 &ephemeral_users_enabled_); |
887 cros_settings_->GetString(kDeviceOwner, &owner_email_); | 887 cros_settings_->GetString(kDeviceOwner, &owner_email_); |
888 const base::ListValue* public_accounts; | 888 base::ListValue public_accounts; |
889 cros_settings_->GetList(kAccountsPrefDeviceLocalAccounts, &public_accounts); | 889 ReadPublicAccounts(&public_accounts); |
890 | 890 |
891 EnsureUsersLoaded(); | 891 EnsureUsersLoaded(); |
892 | 892 |
893 bool changed = UpdateAndCleanUpPublicAccounts(*public_accounts); | 893 bool changed = UpdateAndCleanUpPublicAccounts(public_accounts); |
894 | 894 |
895 // If ephemeral users are enabled and we are on the login screen, take this | 895 // If ephemeral users are enabled and we are on the login screen, take this |
896 // opportunity to clean up by removing all regular users except the owner. | 896 // opportunity to clean up by removing all regular users except the owner. |
897 if (ephemeral_users_enabled_ && !IsUserLoggedIn()) { | 897 if (ephemeral_users_enabled_ && !IsUserLoggedIn()) { |
898 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), | 898 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), |
899 kRegularUsers); | 899 kRegularUsers); |
900 prefs_users_update->Clear(); | 900 prefs_users_update->Clear(); |
901 for (UserList::iterator it = users_.begin(); it != users_.end(); ) { | 901 for (UserList::iterator it = users_.begin(); it != users_.end(); ) { |
902 const std::string user_email = (*it)->email(); | 902 const std::string user_email = (*it)->email(); |
903 if ((*it)->GetType() == User::USER_TYPE_REGULAR && | 903 if ((*it)->GetType() == User::USER_TYPE_REGULAR && |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1419 else if (active_user_->GetType() == User::USER_TYPE_LOCALLY_MANAGED) | 1419 else if (active_user_->GetType() == User::USER_TYPE_LOCALLY_MANAGED) |
1420 login_user_type = LoginState::LOGGED_IN_USER_LOCALLY_MANAGED; | 1420 login_user_type = LoginState::LOGGED_IN_USER_LOCALLY_MANAGED; |
1421 else if (active_user_->GetType() == User::USER_TYPE_KIOSK_APP) | 1421 else if (active_user_->GetType() == User::USER_TYPE_KIOSK_APP) |
1422 login_user_type = LoginState::LOGGED_IN_USER_KIOSK_APP; | 1422 login_user_type = LoginState::LOGGED_IN_USER_KIOSK_APP; |
1423 else | 1423 else |
1424 login_user_type = LoginState::LOGGED_IN_USER_REGULAR; | 1424 login_user_type = LoginState::LOGGED_IN_USER_REGULAR; |
1425 | 1425 |
1426 LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type); | 1426 LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type); |
1427 } | 1427 } |
1428 | 1428 |
1429 void UserManagerImpl::ReadPublicAccounts(base::ListValue* public_accounts) { | |
1430 const base::DictionaryValue* device_local_accounts = NULL; | |
1431 if (cros_settings_->GetDictionary( | |
1432 kAccountsPrefDeviceLocalAccounts, &device_local_accounts)) { | |
bartfab (slow)
2013/04/25 11:17:28
By switching from a ListValue to a DictionaryValue
Mattias Nissler (ping if slow)
2013/04/26 09:10:05
Switched to the list.
| |
1433 for (base::DictionaryValue::Iterator account(*device_local_accounts); | |
1434 !account.IsAtEnd(); account.Advance()) { | |
1435 const base::DictionaryValue* entry_dict = NULL; | |
1436 if (!account.value().GetAsDictionary(&entry_dict)) { | |
1437 NOTREACHED(); | |
1438 continue; | |
1439 } | |
1440 | |
1441 if (entry_dict->HasKey(kAccountsPrefDeviceLocalAccountsKeyKioskAppId)) { | |
bartfab (slow)
2013/04/25 11:17:28
As in KioskAppManager, this code should look at ac
Mattias Nissler (ping if slow)
2013/04/26 09:10:05
Switched to checking the type key.
| |
1442 // TODO(mnissler, nkostylev, bartfab): Process Kiosk Apps within the | |
1443 // standard login framework: http://crbug.com/234694 | |
1444 } else { | |
1445 // Regular public account. | |
1446 public_accounts->AppendString(account.key()); | |
1447 } | |
1448 } | |
1449 } | |
1450 } | |
1451 | |
1429 } // namespace chromeos | 1452 } // namespace chromeos |
OLD | NEW |