OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/signin/core/browser/account_seeding_tracker.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "components/signin/core/browser/account_tracker_service.h" |
| 9 |
| 10 AccountSeedingTracker::AccountSeedingTracker( |
| 11 const AccountTrackerService* account_tracker_service) |
| 12 : account_tracker_service_(account_tracker_service) {} |
| 13 |
| 14 AccountSeedingTracker::~AccountSeedingTracker() {} |
| 15 |
| 16 bool AccountSeedingTracker::IsAccountSeeded(const std::string& account_id) { |
| 17 #if defined(OS_ANDROID) |
| 18 bool unseeded = |
| 19 account_tracker_service_->GetAccountInfo(account_id).email.empty(); |
| 20 if (unseeded) |
| 21 unseeded_accounts_.push_back(account_id); |
| 22 return !unseeded; |
| 23 #else |
| 24 return true; |
| 25 #endif |
| 26 } |
| 27 |
| 28 std::vector<std::string> AccountSeedingTracker::GetNewlySeededAccounts() { |
| 29 #if defined(OS_ANDROID) |
| 30 std::vector<std::string> newly_seeded; |
| 31 unseeded_accounts_.swap(newly_seeded); |
| 32 DCHECK(AreAllAccountsSeeded()); |
| 33 // We may have stopped tracking some accounts. |
| 34 for (std::vector<std::string>::iterator it = newly_seeded.begin(); |
| 35 it != newly_seeded.end();) { |
| 36 if (account_tracker_service_->GetAccountInfo(*it).email.empty()) { |
| 37 it = newly_seeded.erase(it); |
| 38 } else { |
| 39 ++it; |
| 40 } |
| 41 } |
| 42 return newly_seeded; |
| 43 #else |
| 44 NOTREACHED(); |
| 45 return std::vector<std::string>(); |
| 46 #endif |
| 47 } |
| 48 |
| 49 bool AccountSeedingTracker::AreAllAccountsSeeded() const { |
| 50 #if defined(OS_ANDROID) |
| 51 for (const AccountInfo& account : account_tracker_service_->GetAccounts()) { |
| 52 if (account.email.empty()) |
| 53 return false; |
| 54 } |
| 55 #else |
| 56 NOTREACHED(); |
| 57 #endif |
| 58 return true; |
| 59 } |
OLD | NEW |