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

Side by Side Diff: components/signin/core/browser/account_tracker_service.cc

Issue 2187743003: Do not crash if no Account Info Preferences exist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Proper code formatting Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 for (std::map<std::string, AccountState>::const_iterator it = 301 for (std::map<std::string, AccountState>::const_iterator it =
302 migrated_accounts.begin(); 302 migrated_accounts.begin();
303 it != migrated_accounts.end(); ++it) { 303 it != migrated_accounts.end(); ++it) {
304 accounts_.insert(*it); 304 accounts_.insert(*it);
305 } 305 }
306 } 306 }
307 307
308 void AccountTrackerService::LoadFromPrefs() { 308 void AccountTrackerService::LoadFromPrefs() {
309 const base::ListValue* list = 309 const base::ListValue* list =
310 signin_client_->GetPrefs()->GetList(kAccountInfoPref); 310 signin_client_->GetPrefs()->GetList(kAccountInfoPref);
311 if (list == nullptr)
312 return;
311 std::set<std::string> to_remove; 313 std::set<std::string> to_remove;
312 bool contains_deprecated_service_flags = false; 314 bool contains_deprecated_service_flags = false;
313 for (size_t i = 0; i < list->GetSize(); ++i) { 315 for (size_t i = 0; i < list->GetSize(); ++i) {
314 const base::DictionaryValue* dict; 316 const base::DictionaryValue* dict;
315 if (list->GetDictionary(i, &dict)) { 317 if (list->GetDictionary(i, &dict)) {
316 base::string16 value; 318 base::string16 value;
317 if (dict->GetString(kAccountKeyPath, &value)) { 319 if (dict->GetString(kAccountKeyPath, &value)) {
318 std::string account_id = base::UTF16ToUTF8(value); 320 std::string account_id = base::UTF16ToUTF8(value);
319 321
320 // Ignore incorrectly persisted non-canonical account ids. 322 // Ignore incorrectly persisted non-canonical account ids.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 NotifyAccountUpdated(state); 503 NotifyAccountUpdated(state);
502 } 504 }
503 SaveToPrefs(state); 505 SaveToPrefs(state);
504 } 506 }
505 return info.account_id; 507 return info.account_id;
506 } 508 }
507 509
508 void AccountTrackerService::RemoveAccount(const std::string& account_id) { 510 void AccountTrackerService::RemoveAccount(const std::string& account_id) {
509 StopTrackingAccount(account_id); 511 StopTrackingAccount(account_id);
510 } 512 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698