OLD | NEW |
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 "components/signin/core/browser/account_tracker_service.h" | 5 #include "components/signin/core/browser/account_tracker_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 if (dict->GetString(kAccountPictureURLPath, &value)) | 343 if (dict->GetString(kAccountPictureURLPath, &value)) |
344 state.info.picture_url = base::UTF16ToUTF8(value); | 344 state.info.picture_url = base::UTF16ToUTF8(value); |
345 | 345 |
346 bool is_child_account = false; | 346 bool is_child_account = false; |
347 // Migrate deprecated service flag preference. | 347 // Migrate deprecated service flag preference. |
348 const base::ListValue* service_flags_list; | 348 const base::ListValue* service_flags_list; |
349 if (dict->GetList(kAccountServiceFlagsPath, &service_flags_list)) { | 349 if (dict->GetList(kAccountServiceFlagsPath, &service_flags_list)) { |
350 contains_deprecated_service_flags = true; | 350 contains_deprecated_service_flags = true; |
351 std::string flag_string; | 351 std::string flag_string; |
352 for (const auto& flag : *service_flags_list) { | 352 for (const auto& flag : *service_flags_list) { |
353 if (flag.GetAsString(&flag_string) && | 353 if (flag->GetAsString(&flag_string) && |
354 flag_string == kChildAccountServiceFlag) { | 354 flag_string == kChildAccountServiceFlag) { |
355 is_child_account = true; | 355 is_child_account = true; |
356 break; | 356 break; |
357 } | 357 } |
358 } | 358 } |
359 state.info.is_child_account = is_child_account; | 359 state.info.is_child_account = is_child_account; |
360 } | 360 } |
361 if (dict->GetBoolean(kAccountChildAccountStatusPath, &is_child_account)) | 361 if (dict->GetBoolean(kAccountChildAccountStatusPath, &is_child_account)) |
362 state.info.is_child_account = is_child_account; | 362 state.info.is_child_account = is_child_account; |
363 | 363 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 if (update->GetDictionary(i, &dict)) { | 400 if (update->GetDictionary(i, &dict)) { |
401 base::string16 value; | 401 base::string16 value; |
402 if (dict->GetString(kAccountKeyPath, &value) && value == account_id_16) | 402 if (dict->GetString(kAccountKeyPath, &value) && value == account_id_16) |
403 break; | 403 break; |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 if (!dict) { | 407 if (!dict) { |
408 dict = new base::DictionaryValue(); | 408 dict = new base::DictionaryValue(); |
409 update->Append(base::WrapUnique(dict)); | 409 update->Append(base::WrapUnique(dict)); |
410 // |dict| is invalidated at this point, so it needs to be reset. | |
411 update->GetDictionary(update->GetSize() - 1, &dict); | |
412 dict->SetString(kAccountKeyPath, account_id_16); | 410 dict->SetString(kAccountKeyPath, account_id_16); |
413 } | 411 } |
414 | 412 |
415 dict->SetString(kAccountEmailPath, state.info.email); | 413 dict->SetString(kAccountEmailPath, state.info.email); |
416 dict->SetString(kAccountGaiaPath, state.info.gaia); | 414 dict->SetString(kAccountGaiaPath, state.info.gaia); |
417 dict->SetString(kAccountHostedDomainPath, state.info.hosted_domain); | 415 dict->SetString(kAccountHostedDomainPath, state.info.hosted_domain); |
418 dict->SetString(kAccountFullNamePath, state.info.full_name); | 416 dict->SetString(kAccountFullNamePath, state.info.full_name); |
419 dict->SetString(kAccountGivenNamePath, state.info.given_name); | 417 dict->SetString(kAccountGivenNamePath, state.info.given_name); |
420 dict->SetString(kAccountLocalePath, state.info.locale); | 418 dict->SetString(kAccountLocalePath, state.info.locale); |
421 dict->SetString(kAccountPictureURLPath, state.info.picture_url); | 419 dict->SetString(kAccountPictureURLPath, state.info.picture_url); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 NotifyAccountUpdated(state); | 500 NotifyAccountUpdated(state); |
503 | 501 |
504 SaveToPrefs(state); | 502 SaveToPrefs(state); |
505 } | 503 } |
506 return info.account_id; | 504 return info.account_id; |
507 } | 505 } |
508 | 506 |
509 void AccountTrackerService::RemoveAccount(const std::string& account_id) { | 507 void AccountTrackerService::RemoveAccount(const std::string& account_id) { |
510 StopTrackingAccount(account_id); | 508 StopTrackingAccount(account_id); |
511 } | 509 } |
OLD | NEW |