Chromium Code Reviews| Index: components/signin/core/browser/account_tracker_service.cc |
| diff --git a/components/signin/core/browser/account_tracker_service.cc b/components/signin/core/browser/account_tracker_service.cc |
| index b57c58500e897372df481d6608843af8b5d09cb5..3176fc344b995eca7797b350b0e3a49e65ef32c4 100644 |
| --- a/components/signin/core/browser/account_tracker_service.cc |
| +++ b/components/signin/core/browser/account_tracker_service.cc |
| @@ -141,6 +141,24 @@ AccountInfo AccountTrackerService::FindAccountInfoByEmail( |
| return AccountInfo(); |
| } |
| +bool AccountTrackerService::IsTrackingAccount( |
| + const std::string& account_id) const { |
| + return ContainsKey(accounts_, account_id); |
| +} |
| + |
| +bool AccountTrackerService::HasIdNameMappingForAccount( |
| + const std::string& account_id) const { |
| + return !GetAccountInfo(account_id).email.empty(); |
|
Roger Tawa OOO till Jul 10th
2015/10/13 12:40:56
This should check if both gaiaid and email are not
knn
2015/10/13 13:15:42
Done.
|
| +} |
| + |
| +bool AccountTrackerService::HasIdNameMappingForAllAccounts() const { |
| + for (const auto& account : accounts_) { |
| + if (account.second.info.email.empty()) |
|
Roger Tawa OOO till Jul 10th
2015/10/13 12:40:56
Same as previous comment.
knn
2015/10/13 13:15:41
Done.
|
| + return false; |
| + } |
| + return true; |
| +} |
|
Roger Tawa OOO till Jul 10th
2015/10/13 12:40:56
Seems like this function is the same as IsMigratab
knn
2015/10/13 13:15:42
My bad. Do you think it makes sense to call this f
|
| + |
| AccountTrackerService::AccountIdMigrationState |
| AccountTrackerService::GetMigrationState() const { |
| return GetMigrationState(signin_client_->GetPrefs()); |
| @@ -182,7 +200,7 @@ void AccountTrackerService::NotifyAccountRemoved(const AccountState& state) { |
| void AccountTrackerService::StartTrackingAccount( |
| const std::string& account_id) { |
| - if (!ContainsKey(accounts_, account_id)) { |
| + if (!IsTrackingAccount(account_id)) { |
| DVLOG(1) << "StartTracking " << account_id; |
| AccountState state; |
| state.info.account_id = account_id; |
| @@ -193,7 +211,7 @@ void AccountTrackerService::StartTrackingAccount( |
| void AccountTrackerService::StopTrackingAccount(const std::string& account_id) { |
| DVLOG(1) << "StopTracking " << account_id; |
| - if (ContainsKey(accounts_, account_id)) { |
| + if (IsTrackingAccount(account_id)) { |
| AccountState& state = accounts_[account_id]; |
| RemoveFromPrefs(state); |
| if (!state.info.gaia.empty()) |
| @@ -206,7 +224,7 @@ void AccountTrackerService::StopTrackingAccount(const std::string& account_id) { |
| void AccountTrackerService::SetAccountStateFromUserInfo( |
| const std::string& account_id, |
| const base::DictionaryValue* user_info) { |
| - DCHECK(ContainsKey(accounts_, account_id)); |
| + DCHECK(IsTrackingAccount(account_id)); |
| AccountState& state = accounts_[account_id]; |
| std::string gaia_id; |
| @@ -241,7 +259,7 @@ void AccountTrackerService::SetAccountStateFromUserInfo( |
| void AccountTrackerService::SetIsChildAccount(const std::string& account_id, |
| const bool& is_child_account) { |
| - DCHECK(ContainsKey(accounts_, account_id)); |
| + DCHECK(IsTrackingAccount(account_id)); |
| AccountState& state = accounts_[account_id]; |
| if (state.info.is_child_account == is_child_account) |
| return; |
| @@ -276,7 +294,7 @@ void AccountTrackerService::MigrateToGaiaId() { |
| std::string account_id = it->first; |
| if (account_id != state.info.gaia) { |
| std::string new_account_id = state.info.gaia; |
| - if (!ContainsKey(accounts_, new_account_id)) { |
| + if (!IsTrackingAccount(new_account_id)) { |
| AccountState new_state = state; |
| new_state.info.account_id = new_account_id; |
| migrated_accounts.insert(make_pair(new_account_id, new_state)); |
| @@ -288,7 +306,7 @@ void AccountTrackerService::MigrateToGaiaId() { |
| // Remove any obsolete account. |
| for (auto account_id : to_remove) { |
| - if (ContainsKey(accounts_, account_id)) { |
| + if (IsTrackingAccount(account_id)) { |
| AccountState& state = accounts_[account_id]; |
| RemoveFromPrefs(state); |
| accounts_.erase(account_id); |
| @@ -466,7 +484,7 @@ std::string AccountTrackerService::PickAccountIdForAccount( |
| std::string AccountTrackerService::SeedAccountInfo(const std::string& gaia, |
| const std::string& email) { |
| const std::string account_id = PickAccountIdForAccount(gaia, email); |
| - const bool already_exists = ContainsKey(accounts_, account_id); |
| + const bool already_exists = IsTrackingAccount(account_id); |
| StartTrackingAccount(account_id); |
| AccountState& state = accounts_[account_id]; |
| DCHECK(!already_exists || state.info.gaia.empty() || state.info.gaia == gaia); |
| @@ -489,7 +507,7 @@ void AccountTrackerService::SeedAccountInfo(AccountInfo info) { |
| } |
| if(info.IsValid()) { |
| - if(!ContainsKey(accounts_, info.account_id)) { |
| + if (!IsTrackingAccount(info.account_id)) { |
| SeedAccountInfo(info.gaia, info.email); |
| } |