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 #if defined(OS_ANDROID) |
| 13 account_tracker_service_ = account_tracker_service; |
| 14 #endif |
| 15 } |
| 16 |
| 17 AccountSeedingTracker::~AccountSeedingTracker() {} |
| 18 |
| 19 bool AccountSeedingTracker::IsAccountSeeded(const std::string& account_id) { |
| 20 #if defined(OS_ANDROID) |
| 21 bool unseeded = |
| 22 account_tracker_service_->GetAccountInfo(account_id).email.empty(); |
| 23 if (unseeded) |
| 24 unseeded_accounts_.push_back(account_id); |
| 25 return !unseeded; |
| 26 #else |
| 27 return true; |
| 28 #endif |
| 29 } |
| 30 |
| 31 std::vector<std::string> AccountSeedingTracker::GetNewlySeededAccounts() { |
| 32 #if defined(OS_ANDROID) |
| 33 std::vector<std::string> newly_seeded; |
| 34 unseeded_accounts_.swap(newly_seeded); |
| 35 DCHECK(AreAllAccountsSeeded()); |
| 36 // We may have stopped tracking some accounts. |
| 37 for (std::vector<std::string>::iterator it = newly_seeded.begin(); |
| 38 it != newly_seeded.end();) { |
| 39 if (account_tracker_service_->GetAccountInfo(*it).email.empty()) { |
| 40 it = newly_seeded.erase(it); |
| 41 } else { |
| 42 ++it; |
| 43 } |
| 44 } |
| 45 return newly_seeded; |
| 46 #else |
| 47 NOTREACHED(); |
| 48 return std::vector<std::string>(); |
| 49 #endif |
| 50 } |
| 51 |
| 52 bool AccountSeedingTracker::AreAllAccountsSeeded() const { |
| 53 #if defined(OS_ANDROID) |
| 54 for (const AccountInfo& account : account_tracker_service_->GetAccounts()) { |
| 55 if (account.email.empty()) |
| 56 return false; |
| 57 } |
| 58 #else |
| 59 NOTREACHED(); |
| 60 #endif |
| 61 return true; |
| 62 } |
OLD | NEW |