Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: chrome/browser/ui/webui/options/supervised_user_import_handler.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/supervised_user_import_handler.h" 5 #include "chrome/browser/ui/webui/options/supervised_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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 14 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
15 #include "chrome/browser/profiles/profile_info_cache.h" 15 #include "chrome/browser/profiles/profile_info_cache.h"
16 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/signin/signin_error_controller_factory.h" 17 #include "chrome/browser/signin/signin_error_controller_factory.h"
18 #include "chrome/browser/signin/signin_manager_factory.h" 18 #include "chrome/browser/signin/signin_manager_factory.h"
19 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service.h" 19 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service.h"
20 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service_factory.h" 20 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service_factory.h"
21 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h" 21 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
22 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_fac tory.h" 22 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_fac tory.h"
23 #include "chrome/browser/supervised_user/supervised_user_constants.h" 23 #include "chrome/browser/supervised_user/supervised_user_constants.h"
24 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
25 #include "chrome/grit/generated_resources.h" 25 #include "chrome/grit/generated_resources.h"
26 #include "components/signin/core/browser/signin_error_controller.h" 26 #include "components/signin/core/browser/signin_error_controller.h"
27 #include "components/signin/core/browser/signin_manager.h" 27 #include "components/signin/core/browser/signin_manager.h"
28 #include "components/user_manager/user_id.h"
28 #include "content/public/browser/web_ui.h" 29 #include "content/public/browser/web_ui.h"
29 #include "grit/theme_resources.h" 30 #include "grit/theme_resources.h"
30 31
31 namespace { 32 namespace {
32 33
33 scoped_ptr<base::ListValue> GetAvatarIcons() { 34 scoped_ptr<base::ListValue> GetAvatarIcons() {
34 scoped_ptr<base::ListValue> avatar_icons(new base::ListValue); 35 scoped_ptr<base::ListValue> avatar_icons(new base::ListValue);
35 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount(); ++i) { 36 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount(); ++i) {
36 std::string avatar_url = profiles::GetDefaultAvatarIconUrl(i); 37 std::string avatar_url = profiles::GetDefaultAvatarIconUrl(i);
37 avatar_icons->Append(new base::StringValue(avatar_url)); 38 avatar_icons->Append(new base::StringValue(avatar_url));
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 179 }
179 } 180 }
180 181
181 void SupervisedUserImportHandler::SendExistingSupervisedUsers( 182 void SupervisedUserImportHandler::SendExistingSupervisedUsers(
182 const base::DictionaryValue* dict) { 183 const base::DictionaryValue* dict) {
183 DCHECK(dict); 184 DCHECK(dict);
184 const ProfileInfoCache& cache = 185 const ProfileInfoCache& cache =
185 g_browser_process->profile_manager()->GetProfileInfoCache(); 186 g_browser_process->profile_manager()->GetProfileInfoCache();
186 187
187 // Collect the ids of local supervised user profiles. 188 // Collect the ids of local supervised user profiles.
188 std::set<std::string> supervised_user_ids; 189 std::set<user_manager::UserID> supervised_user_ids;
189 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { 190 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
190 if (cache.ProfileIsLegacySupervisedAtIndex(i)) 191 if (cache.ProfileIsLegacySupervisedAtIndex(i))
191 supervised_user_ids.insert(cache.GetSupervisedUserIdOfProfileAtIndex(i)); 192 supervised_user_ids.insert(cache.GetSupervisedUserIdOfProfileAtIndex(i));
192 } 193 }
193 194
194 base::ListValue supervised_users; 195 base::ListValue supervised_users;
195 Profile* profile = Profile::FromWebUI(web_ui()); 196 Profile* profile = Profile::FromWebUI(web_ui());
196 SupervisedUserSharedSettingsService* service = 197 SupervisedUserSharedSettingsService* service =
197 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile); 198 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
198 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { 199 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
(...skipping 26 matching lines...) Expand all
225 226
226 std::string supervised_user_icon = 227 std::string supervised_user_icon =
227 std::string(chrome::kChromeUIThemeURL) + 228 std::string(chrome::kChromeUIThemeURL) +
228 "IDR_SUPERVISED_USER_PLACEHOLDER"; 229 "IDR_SUPERVISED_USER_PLACEHOLDER";
229 std::string avatar_url = 230 std::string avatar_url =
230 avatar_index == SupervisedUserSyncService::kNoAvatar ? 231 avatar_index == SupervisedUserSyncService::kNoAvatar ?
231 supervised_user_icon : 232 supervised_user_icon :
232 profiles::GetDefaultAvatarIconUrl(avatar_index); 233 profiles::GetDefaultAvatarIconUrl(avatar_index);
233 supervised_user->SetString("iconURL", avatar_url); 234 supervised_user->SetString("iconURL", avatar_url);
234 bool on_current_device = 235 bool on_current_device =
235 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); 236 supervised_user_ids.find(user_manager::UserID::FromUserEmail(it.key())) != supervised_user_ids.end();
236 supervised_user->SetBoolean("onCurrentDevice", on_current_device); 237 supervised_user->SetBoolean("onCurrentDevice", on_current_device);
237 238
238 supervised_users.Append(supervised_user); 239 supervised_users.Append(supervised_user);
239 } 240 }
240 241
241 web_ui()->CallJavascriptFunction( 242 web_ui()->CallJavascriptFunction(
242 "options.SupervisedUserListData.receiveExistingSupervisedUsers", 243 "options.SupervisedUserListData.receiveExistingSupervisedUsers",
243 supervised_users); 244 supervised_users);
244 } 245 }
245 246
(...skipping 29 matching lines...) Expand all
275 const std::string& key) { 276 const std::string& key) {
276 if (key == supervised_users::kChromeAvatarIndex) 277 if (key == supervised_users::kChromeAvatarIndex)
277 FetchSupervisedUsers(); 278 FetchSupervisedUsers();
278 } 279 }
279 280
280 void SupervisedUserImportHandler::OnErrorChanged() { 281 void SupervisedUserImportHandler::OnErrorChanged() {
281 FetchSupervisedUsers(); 282 FetchSupervisedUsers();
282 } 283 }
283 284
284 } // namespace options 285 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698