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

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

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
9 #include <set> 10 #include <set>
11 #include <utility>
10 #include <vector> 12 #include <vector>
11 13
12 #include "base/bind.h" 14 #include "base/bind.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/values.h" 16 #include "base/values.h"
15 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_attributes_entry.h" 19 #include "chrome/browser/profiles/profile_attributes_entry.h"
18 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 20 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
19 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 Profile* profile = Profile::FromWebUI(web_ui()); 214 Profile* profile = Profile::FromWebUI(web_ui());
213 SupervisedUserSharedSettingsService* service = 215 SupervisedUserSharedSettingsService* service =
214 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile); 216 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
215 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { 217 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
216 const base::DictionaryValue* value = NULL; 218 const base::DictionaryValue* value = NULL;
217 bool success = it.value().GetAsDictionary(&value); 219 bool success = it.value().GetAsDictionary(&value);
218 DCHECK(success); 220 DCHECK(success);
219 std::string name; 221 std::string name;
220 value->GetString(SupervisedUserSyncService::kName, &name); 222 value->GetString(SupervisedUserSyncService::kName, &name);
221 223
222 base::DictionaryValue* supervised_user = new base::DictionaryValue; 224 std::unique_ptr<base::DictionaryValue> supervised_user(
225 new base::DictionaryValue);
223 supervised_user->SetString("id", it.key()); 226 supervised_user->SetString("id", it.key());
224 supervised_user->SetString("name", name); 227 supervised_user->SetString("name", name);
225 228
226 int avatar_index = SupervisedUserSyncService::kNoAvatar; 229 int avatar_index = SupervisedUserSyncService::kNoAvatar;
227 const base::Value* avatar_index_value = 230 const base::Value* avatar_index_value =
228 service->GetValue(it.key(), supervised_users::kChromeAvatarIndex); 231 service->GetValue(it.key(), supervised_users::kChromeAvatarIndex);
229 if (avatar_index_value) { 232 if (avatar_index_value) {
230 success = avatar_index_value->GetAsInteger(&avatar_index); 233 success = avatar_index_value->GetAsInteger(&avatar_index);
231 } else { 234 } else {
232 // Check if there is a legacy avatar index stored. 235 // Check if there is a legacy avatar index stored.
(...skipping 12 matching lines...) Expand all
245 "IDR_SUPERVISED_USER_PLACEHOLDER"; 248 "IDR_SUPERVISED_USER_PLACEHOLDER";
246 std::string avatar_url = 249 std::string avatar_url =
247 avatar_index == SupervisedUserSyncService::kNoAvatar ? 250 avatar_index == SupervisedUserSyncService::kNoAvatar ?
248 supervised_user_icon : 251 supervised_user_icon :
249 profiles::GetDefaultAvatarIconUrl(avatar_index); 252 profiles::GetDefaultAvatarIconUrl(avatar_index);
250 supervised_user->SetString("iconURL", avatar_url); 253 supervised_user->SetString("iconURL", avatar_url);
251 bool on_current_device = 254 bool on_current_device =
252 supervised_user_ids.find(it.key()) != supervised_user_ids.end(); 255 supervised_user_ids.find(it.key()) != supervised_user_ids.end();
253 supervised_user->SetBoolean("onCurrentDevice", on_current_device); 256 supervised_user->SetBoolean("onCurrentDevice", on_current_device);
254 257
255 supervised_users.Append(supervised_user); 258 supervised_users.Append(std::move(supervised_user));
256 } 259 }
257 260
258 web_ui()->CallJavascriptFunctionUnsafe( 261 web_ui()->CallJavascriptFunctionUnsafe(
259 "options.SupervisedUserListData.receiveExistingSupervisedUsers", 262 "options.SupervisedUserListData.receiveExistingSupervisedUsers",
260 supervised_users); 263 supervised_users);
261 } 264 }
262 265
263 void SupervisedUserImportHandler::ClearSupervisedUsersAndShowError() { 266 void SupervisedUserImportHandler::ClearSupervisedUsersAndShowError() {
264 web_ui()->CallJavascriptFunctionUnsafe( 267 web_ui()->CallJavascriptFunctionUnsafe(
265 "options.SupervisedUserListData.onSigninError"); 268 "options.SupervisedUserListData.onSigninError");
(...skipping 26 matching lines...) Expand all
292 const std::string& key) { 295 const std::string& key) {
293 if (key == supervised_users::kChromeAvatarIndex) 296 if (key == supervised_users::kChromeAvatarIndex)
294 FetchSupervisedUsers(); 297 FetchSupervisedUsers();
295 } 298 }
296 299
297 void SupervisedUserImportHandler::OnErrorChanged() { 300 void SupervisedUserImportHandler::OnErrorChanged() {
298 FetchSupervisedUsers(); 301 FetchSupervisedUsers();
299 } 302 }
300 303
301 } // namespace options 304 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/startup_pages_handler.cc ('k') | chrome/browser/ui/webui/predictors/predictors_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698