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

Side by Side Diff: chrome/browser/supervised_user/child_accounts/family_info_fetcher.cc

Issue 1878143002: Convert //chrome/browser/supervised_user from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/supervised_user/child_accounts/family_info_fetcher.h" 5 #include "chrome/browser/supervised_user/child_accounts/family_info_fetcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 FamilyMember* member) { 268 FamilyMember* member) {
269 dict->GetString(kIdDisplayName, &member->display_name); 269 dict->GetString(kIdDisplayName, &member->display_name);
270 dict->GetString(kIdEmail, &member->email); 270 dict->GetString(kIdEmail, &member->email);
271 dict->GetString(kIdProfileUrl, &member->profile_url); 271 dict->GetString(kIdProfileUrl, &member->profile_url);
272 dict->GetString(kIdProfileImageUrl, &member->profile_image_url); 272 dict->GetString(kIdProfileImageUrl, &member->profile_image_url);
273 if (member->profile_image_url.empty()) 273 if (member->profile_image_url.empty())
274 dict->GetString(kIdDefaultProfileImageUrl, &member->profile_image_url); 274 dict->GetString(kIdDefaultProfileImageUrl, &member->profile_image_url);
275 } 275 }
276 276
277 void FamilyInfoFetcher::FamilyProfileFetched(const std::string& response) { 277 void FamilyInfoFetcher::FamilyProfileFetched(const std::string& response) {
278 scoped_ptr<base::Value> value = base::JSONReader::Read(response); 278 std::unique_ptr<base::Value> value = base::JSONReader::Read(response);
279 const base::DictionaryValue* dict = NULL; 279 const base::DictionaryValue* dict = NULL;
280 if (!value || !value->GetAsDictionary(&dict)) { 280 if (!value || !value->GetAsDictionary(&dict)) {
281 consumer_->OnFailure(SERVICE_ERROR); 281 consumer_->OnFailure(SERVICE_ERROR);
282 return; 282 return;
283 } 283 }
284 const base::DictionaryValue* family_dict = NULL; 284 const base::DictionaryValue* family_dict = NULL;
285 if (!dict->GetDictionary(kIdFamily, &family_dict)) { 285 if (!dict->GetDictionary(kIdFamily, &family_dict)) {
286 consumer_->OnFailure(SERVICE_ERROR); 286 consumer_->OnFailure(SERVICE_ERROR);
287 return; 287 return;
288 } 288 }
289 FamilyProfile family; 289 FamilyProfile family;
290 if (!family_dict->GetStringWithoutPathExpansion(kIdFamilyId, &family.id)) { 290 if (!family_dict->GetStringWithoutPathExpansion(kIdFamilyId, &family.id)) {
291 consumer_->OnFailure(SERVICE_ERROR); 291 consumer_->OnFailure(SERVICE_ERROR);
292 return; 292 return;
293 } 293 }
294 const base::DictionaryValue* profile_dict = NULL; 294 const base::DictionaryValue* profile_dict = NULL;
295 if (!family_dict->GetDictionary(kIdProfile, &profile_dict)) { 295 if (!family_dict->GetDictionary(kIdProfile, &profile_dict)) {
296 consumer_->OnFailure(SERVICE_ERROR); 296 consumer_->OnFailure(SERVICE_ERROR);
297 return; 297 return;
298 } 298 }
299 if (!profile_dict->GetStringWithoutPathExpansion(kIdFamilyName, 299 if (!profile_dict->GetStringWithoutPathExpansion(kIdFamilyName,
300 &family.name)) { 300 &family.name)) {
301 consumer_->OnFailure(SERVICE_ERROR); 301 consumer_->OnFailure(SERVICE_ERROR);
302 return; 302 return;
303 } 303 }
304 consumer_->OnGetFamilyProfileSuccess(family); 304 consumer_->OnGetFamilyProfileSuccess(family);
305 } 305 }
306 306
307 void FamilyInfoFetcher::FamilyMembersFetched(const std::string& response) { 307 void FamilyInfoFetcher::FamilyMembersFetched(const std::string& response) {
308 scoped_ptr<base::Value> value = base::JSONReader::Read(response); 308 std::unique_ptr<base::Value> value = base::JSONReader::Read(response);
309 const base::DictionaryValue* dict = NULL; 309 const base::DictionaryValue* dict = NULL;
310 if (!value || !value->GetAsDictionary(&dict)) { 310 if (!value || !value->GetAsDictionary(&dict)) {
311 consumer_->OnFailure(SERVICE_ERROR); 311 consumer_->OnFailure(SERVICE_ERROR);
312 return; 312 return;
313 } 313 }
314 const base::ListValue* members_list = NULL; 314 const base::ListValue* members_list = NULL;
315 if (!dict->GetList(kIdMembers, &members_list)) { 315 if (!dict->GetList(kIdMembers, &members_list)) {
316 consumer_->OnFailure(SERVICE_ERROR); 316 consumer_->OnFailure(SERVICE_ERROR);
317 return; 317 return;
318 } 318 }
319 std::vector<FamilyMember> members; 319 std::vector<FamilyMember> members;
320 if (!ParseMembers(members_list, &members)){ 320 if (!ParseMembers(members_list, &members)){
321 consumer_->OnFailure(SERVICE_ERROR); 321 consumer_->OnFailure(SERVICE_ERROR);
322 return; 322 return;
323 } 323 }
324 consumer_->OnGetFamilyMembersSuccess(members); 324 consumer_->OnGetFamilyMembersSuccess(members);
325 } 325 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698