| 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/ui/webui/options/managed_user_import_handler.h" | 5 #include "chrome/browser/ui/webui/options/managed_user_import_handler.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 managed_user_ids.insert(cache.GetManagedUserIdOfProfileAtIndex(i)); | 62 managed_user_ids.insert(cache.GetManagedUserIdOfProfileAtIndex(i)); |
| 63 | 63 |
| 64 const DictionaryValue* dict = | 64 const DictionaryValue* dict = |
| 65 ManagedUserSyncServiceFactory::GetForProfile(profile)->GetManagedUsers(); | 65 ManagedUserSyncServiceFactory::GetForProfile(profile)->GetManagedUsers(); |
| 66 ListValue managed_users; | 66 ListValue managed_users; |
| 67 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 67 for (DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
| 68 const DictionaryValue* value = NULL; | 68 const DictionaryValue* value = NULL; |
| 69 bool success = it.value().GetAsDictionary(&value); | 69 bool success = it.value().GetAsDictionary(&value); |
| 70 DCHECK(success); | 70 DCHECK(success); |
| 71 std::string name; | 71 std::string name; |
| 72 value->GetString("name", &name); | 72 value->GetString(ManagedUserSyncService::kName, &name); |
| 73 std::string avatar_str; |
| 74 value->GetString(ManagedUserSyncService::kChromeAvatar, &avatar_str); |
| 73 | 75 |
| 74 DictionaryValue* managed_user = new DictionaryValue; | 76 DictionaryValue* managed_user = new DictionaryValue; |
| 75 managed_user->SetString("id", it.key()); | 77 managed_user->SetString("id", it.key()); |
| 76 managed_user->SetString("name", name); | 78 managed_user->SetString("name", name); |
| 77 | 79 |
| 78 // TODO(ibraaaa): Update this to use the correct avatar | 80 int avatar_index = -1; |
| 79 // when avatar syncing is implemented: http://crbug.com/278083 | 81 success = ManagedUserSyncService::GetAvatarIndex(avatar_str, &avatar_index); |
| 80 std::string avatar_url = ProfileInfoCache::GetDefaultAvatarIconUrl(0); | 82 DCHECK(success); |
| 83 |
| 84 // TODO(ibraaaa): When we have an image indicating that this user |
| 85 // has no synced avatar then change this to use it. |
| 86 avatar_index = avatar_index < 0 ? 0 : avatar_index; |
| 87 std::string avatar_url = |
| 88 ProfileInfoCache::GetDefaultAvatarIconUrl(avatar_index); |
| 81 managed_user->SetString("iconURL", avatar_url); | 89 managed_user->SetString("iconURL", avatar_url); |
| 82 bool on_current_device = | 90 bool on_current_device = |
| 83 managed_user_ids.find(it.key()) != managed_user_ids.end(); | 91 managed_user_ids.find(it.key()) != managed_user_ids.end(); |
| 84 managed_user->SetBoolean("onCurrentDevice", on_current_device); | 92 managed_user->SetBoolean("onCurrentDevice", on_current_device); |
| 85 | 93 |
| 86 managed_users.Append(managed_user); | 94 managed_users.Append(managed_user); |
| 87 } | 95 } |
| 88 | 96 |
| 89 web_ui()->CallJavascriptFunction( | 97 web_ui()->CallJavascriptFunction( |
| 90 "ManagedUserImportOverlay.receiveExistingManagedUsers", | 98 "ManagedUserImportOverlay.receiveExistingManagedUsers", |
| 91 managed_users); | 99 managed_users); |
| 92 } | 100 } |
| 93 | 101 |
| 94 } // namespace options | 102 } // namespace options |
| OLD | NEW |