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

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

Issue 606083002: patch from issue 473153002 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix saml Created 6 years, 2 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 "components/signin/core/browser/account_tracker_service.h" 5 #include "components/signin/core/browser/account_tracker_service.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 435 }
436 } 436 }
437 437
438 void AccountTrackerService::LoadFromTokenService() { 438 void AccountTrackerService::LoadFromTokenService() {
439 std::vector<std::string> accounts = token_service_->GetAccounts(); 439 std::vector<std::string> accounts = token_service_->GetAccounts();
440 for (std::vector<std::string>::const_iterator it = accounts.begin(); 440 for (std::vector<std::string>::const_iterator it = accounts.begin();
441 it != accounts.end(); ++it) { 441 it != accounts.end(); ++it) {
442 OnRefreshTokenAvailable(*it); 442 OnRefreshTokenAvailable(*it);
443 } 443 }
444 } 444 }
445
446 std::string AccountTrackerService::PickAccountIdForAccount(
447 const std::string& gaia_id,
448 const std::string& email) {
449 return PickAccountIdForAccount(pref_service_, gaia_id, email);
450 }
451
452 // static
453 std::string AccountTrackerService::PickAccountIdForAccount(
454 PrefService* pref_service,
455 const std::string& gaia_id,
456 const std::string& email) {
457 DCHECK(!gaia_id.empty());
458 DCHECK(!email.empty());
459 switch(GetMigrationState(pref_service)) {
460 case MIGRATION_NOT_STARTED:
461 case MIGRATION_IN_PROGRESS:
462 return email;
463 case MIGRATION_DONE:
464 return gaia_id;
465 default:
466 NOTREACHED();
467 return email;
468 }
469 }
470
471 void AccountTrackerService::SeedAccountInfo(const std::string& account_id,
472 const std::string& gaia,
473 const std::string& email) {
474 DCHECK(!account_id.empty());
475 DCHECK(!gaia.empty());
476 DCHECK(!email.empty());
477 bool already_exists = ContainsKey(accounts_, account_id);
478 StartTrackingAccount(account_id);
479 AccountState& state = accounts_[account_id];
480 DCHECK(!already_exists || state.info.gaia == gaia);
481 state.info.gaia = gaia;
482 state.info.email = email;
483 SaveToPrefs(state);
484
485 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698