| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/supervised_user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/supervised_user_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 std::string SupervisedUserManagerImpl::GetUserSyncId(const std::string& user_id) | 176 std::string SupervisedUserManagerImpl::GetUserSyncId(const std::string& user_id) |
| 177 const { | 177 const { |
| 178 std::string result; | 178 std::string result; |
| 179 GetUserStringValue(user_id, kManagedUserSyncId, &result); | 179 GetUserStringValue(user_id, kManagedUserSyncId, &result); |
| 180 return result; | 180 return result; |
| 181 } | 181 } |
| 182 | 182 |
| 183 base::string16 SupervisedUserManagerImpl::GetManagerDisplayName( | 183 base::string16 SupervisedUserManagerImpl::GetManagerDisplayName( |
| 184 const std::string& user_id) const { | 184 const std::string& user_id) const { |
| 185 PrefService* local_state = g_browser_process->local_state(); | 185 PrefService* local_state = g_browser_process->local_state(); |
| 186 const DictionaryValue* manager_names = | 186 const base::DictionaryValue* manager_names = |
| 187 local_state->GetDictionary(kManagedUserManagerNames); | 187 local_state->GetDictionary(kManagedUserManagerNames); |
| 188 base::string16 result; | 188 base::string16 result; |
| 189 if (manager_names->GetStringWithoutPathExpansion(user_id, &result) && | 189 if (manager_names->GetStringWithoutPathExpansion(user_id, &result) && |
| 190 !result.empty()) | 190 !result.empty()) |
| 191 return result; | 191 return result; |
| 192 return UTF8ToUTF16(GetManagerDisplayEmail(user_id)); | 192 return UTF8ToUTF16(GetManagerDisplayEmail(user_id)); |
| 193 } | 193 } |
| 194 | 194 |
| 195 std::string SupervisedUserManagerImpl::GetManagerUserId( | 195 std::string SupervisedUserManagerImpl::GetManagerUserId( |
| 196 const std::string& user_id) const { | 196 const std::string& user_id) const { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 bool SupervisedUserManagerImpl::CheckForFirstRun(const std::string& user_id) { | 388 bool SupervisedUserManagerImpl::CheckForFirstRun(const std::string& user_id) { |
| 389 ListPrefUpdate prefs_new_users_update(g_browser_process->local_state(), | 389 ListPrefUpdate prefs_new_users_update(g_browser_process->local_state(), |
| 390 kLocallyManagedUsersFirstRun); | 390 kLocallyManagedUsersFirstRun); |
| 391 return prefs_new_users_update->Remove(base::StringValue(user_id), NULL); | 391 return prefs_new_users_update->Remove(base::StringValue(user_id), NULL); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void SupervisedUserManagerImpl::UpdateManagerName(const std::string& manager_id, | 394 void SupervisedUserManagerImpl::UpdateManagerName(const std::string& manager_id, |
| 395 const base::string16& new_display_name) { | 395 const base::string16& new_display_name) { |
| 396 PrefService* local_state = g_browser_process->local_state(); | 396 PrefService* local_state = g_browser_process->local_state(); |
| 397 | 397 |
| 398 const DictionaryValue* manager_ids = | 398 const base::DictionaryValue* manager_ids = |
| 399 local_state->GetDictionary(kManagedUserManagers); | 399 local_state->GetDictionary(kManagedUserManagers); |
| 400 | 400 |
| 401 DictionaryPrefUpdate manager_name_update(local_state, | 401 DictionaryPrefUpdate manager_name_update(local_state, |
| 402 kManagedUserManagerNames); | 402 kManagedUserManagerNames); |
| 403 for (DictionaryValue::Iterator it(*manager_ids); !it.IsAtEnd(); | 403 for (base::DictionaryValue::Iterator it(*manager_ids); !it.IsAtEnd(); |
| 404 it.Advance()) { | 404 it.Advance()) { |
| 405 std::string user_id; | 405 std::string user_id; |
| 406 bool has_manager_id = it.value().GetAsString(&user_id); | 406 bool has_manager_id = it.value().GetAsString(&user_id); |
| 407 DCHECK(has_manager_id); | 407 DCHECK(has_manager_id); |
| 408 if (user_id == manager_id) { | 408 if (user_id == manager_id) { |
| 409 manager_name_update->SetWithoutPathExpansion( | 409 manager_name_update->SetWithoutPathExpansion( |
| 410 it.key(), | 410 it.key(), |
| 411 new base::StringValue(new_display_name)); | 411 new base::StringValue(new_display_name)); |
| 412 } | 412 } |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 | 415 |
| 416 SupervisedUserAuthentication* SupervisedUserManagerImpl::GetAuthentication() { | 416 SupervisedUserAuthentication* SupervisedUserManagerImpl::GetAuthentication() { |
| 417 return authentication_.get(); | 417 return authentication_.get(); |
| 418 } | 418 } |
| 419 | 419 |
| 420 } // namespace chromeos | 420 } // namespace chromeos |
| OLD | NEW |