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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 DCHECK(success); | 70 DCHECK(success); |
71 std::string name; | 71 std::string name; |
72 value->GetString(ManagedUserSyncService::kName, &name); | 72 value->GetString(ManagedUserSyncService::kName, &name); |
73 std::string avatar_str; | 73 std::string avatar_str; |
74 value->GetString(ManagedUserSyncService::kChromeAvatar, &avatar_str); | 74 value->GetString(ManagedUserSyncService::kChromeAvatar, &avatar_str); |
75 | 75 |
76 DictionaryValue* managed_user = new DictionaryValue; | 76 DictionaryValue* managed_user = new DictionaryValue; |
77 managed_user->SetString("id", it.key()); | 77 managed_user->SetString("id", it.key()); |
78 managed_user->SetString("name", name); | 78 managed_user->SetString("name", name); |
79 | 79 |
80 int avatar_index = -1; | 80 int avatar_index = ManagedUserSyncService::kNoAvatar; |
81 success = ManagedUserSyncService::GetAvatarIndex(avatar_str, &avatar_index); | 81 success = ManagedUserSyncService::GetAvatarIndex(avatar_str, &avatar_index); |
82 DCHECK(success); | 82 DCHECK(success); |
83 | 83 |
84 // TODO(ibraaaa): When we have an image indicating that this user | 84 // TODO(ibraaaa): When we have an image indicating that this user |
85 // has no synced avatar then change this to use it. | 85 // has no synced avatar then change this to use it. |
86 avatar_index = avatar_index < 0 ? 0 : avatar_index; | 86 avatar_index = |
| 87 avatar_index == ManagedUserSyncService::kNoAvatar ? 0 : avatar_index; |
87 std::string avatar_url = | 88 std::string avatar_url = |
88 ProfileInfoCache::GetDefaultAvatarIconUrl(avatar_index); | 89 ProfileInfoCache::GetDefaultAvatarIconUrl(avatar_index); |
89 managed_user->SetString("iconURL", avatar_url); | 90 managed_user->SetString("iconURL", avatar_url); |
90 bool on_current_device = | 91 bool on_current_device = |
91 managed_user_ids.find(it.key()) != managed_user_ids.end(); | 92 managed_user_ids.find(it.key()) != managed_user_ids.end(); |
92 managed_user->SetBoolean("onCurrentDevice", on_current_device); | 93 managed_user->SetBoolean("onCurrentDevice", on_current_device); |
93 | 94 |
94 managed_users.Append(managed_user); | 95 managed_users.Append(managed_user); |
95 } | 96 } |
96 | 97 |
97 web_ui()->CallJavascriptFunction( | 98 web_ui()->CallJavascriptFunction( |
98 "ManagedUserImportOverlay.receiveExistingManagedUsers", | 99 "ManagedUserImportOverlay.receiveExistingManagedUsers", |
99 managed_users); | 100 managed_users); |
100 } | 101 } |
101 | 102 |
102 } // namespace options | 103 } // namespace options |
OLD | NEW |