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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" |
12 #include "base/profiler/scoped_tracker.h" | 13 #include "base/profiler/scoped_tracker.h" |
13 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "components/pref_registry/pref_registry_syncable.h" | 18 #include "components/pref_registry/pref_registry_syncable.h" |
18 #include "components/prefs/scoped_user_pref_update.h" | 19 #include "components/prefs/scoped_user_pref_update.h" |
19 #include "components/signin/core/browser/signin_client.h" | 20 #include "components/signin/core/browser/signin_client.h" |
20 #include "components/signin/core/browser/signin_manager.h" | 21 #include "components/signin/core/browser/signin_manager.h" |
21 #include "components/signin/core/common/signin_pref_names.h" | 22 #include "components/signin/core/common/signin_pref_names.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 for (size_t i = 0; i < update->GetSize(); ++i, dict = nullptr) { | 399 for (size_t i = 0; i < update->GetSize(); ++i, dict = nullptr) { |
399 if (update->GetDictionary(i, &dict)) { | 400 if (update->GetDictionary(i, &dict)) { |
400 base::string16 value; | 401 base::string16 value; |
401 if (dict->GetString(kAccountKeyPath, &value) && value == account_id_16) | 402 if (dict->GetString(kAccountKeyPath, &value) && value == account_id_16) |
402 break; | 403 break; |
403 } | 404 } |
404 } | 405 } |
405 | 406 |
406 if (!dict) { | 407 if (!dict) { |
407 dict = new base::DictionaryValue(); | 408 dict = new base::DictionaryValue(); |
408 update->Append(dict); // |update| takes ownership. | 409 update->Append(base::WrapUnique(dict)); |
409 dict->SetString(kAccountKeyPath, account_id_16); | 410 dict->SetString(kAccountKeyPath, account_id_16); |
410 } | 411 } |
411 | 412 |
412 dict->SetString(kAccountEmailPath, state.info.email); | 413 dict->SetString(kAccountEmailPath, state.info.email); |
413 dict->SetString(kAccountGaiaPath, state.info.gaia); | 414 dict->SetString(kAccountGaiaPath, state.info.gaia); |
414 dict->SetString(kAccountHostedDomainPath, state.info.hosted_domain); | 415 dict->SetString(kAccountHostedDomainPath, state.info.hosted_domain); |
415 dict->SetString(kAccountFullNamePath, state.info.full_name); | 416 dict->SetString(kAccountFullNamePath, state.info.full_name); |
416 dict->SetString(kAccountGivenNamePath, state.info.given_name); | 417 dict->SetString(kAccountGivenNamePath, state.info.given_name); |
417 dict->SetString(kAccountLocalePath, state.info.locale); | 418 dict->SetString(kAccountLocalePath, state.info.locale); |
418 dict->SetString(kAccountPictureURLPath, state.info.picture_url); | 419 dict->SetString(kAccountPictureURLPath, state.info.picture_url); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 NotifyAccountUpdated(state); | 502 NotifyAccountUpdated(state); |
502 } | 503 } |
503 SaveToPrefs(state); | 504 SaveToPrefs(state); |
504 } | 505 } |
505 return info.account_id; | 506 return info.account_id; |
506 } | 507 } |
507 | 508 |
508 void AccountTrackerService::RemoveAccount(const std::string& account_id) { | 509 void AccountTrackerService::RemoveAccount(const std::string& account_id) { |
509 StopTrackingAccount(account_id); | 510 StopTrackingAccount(account_id); |
510 } | 511 } |
OLD | NEW |