#include "components/browsing_data/core/counters/passwords_counter.h"
#include <algorithm>
#include <memory>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/browsing_data/core/pref_names.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_store/password_store_change.h"
#include "components/password_manager/core/browser/password_store/password_store_interface.h"
#include "components/password_manager/core/browser/password_sync_util.h"
#include "components/sync/base/user_selectable_type.h"
#include "components/sync/service/sync_service.h"
#include "components/sync/service/sync_user_settings.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_ANDROID)
#include "components/password_manager/core/browser/split_stores_and_local_upm.h"
#endif
namespace browsing_data {
namespace {
bool IsProfilePasswordSyncEnabled(PrefService* pref_service,
const syncer::SyncService* sync_service) { … }
}
class PasswordStoreFetcher
: public password_manager::PasswordStoreConsumer,
public password_manager::PasswordStoreInterface::Observer { … };
PasswordStoreFetcher::PasswordStoreFetcher(
scoped_refptr<password_manager::PasswordStoreInterface> store,
base::RepeatingClosure logins_changed_closure)
: … { … }
PasswordStoreFetcher::~PasswordStoreFetcher() = default;
void PasswordStoreFetcher::OnLoginsChanged(
password_manager::PasswordStoreInterface* ,
const password_manager::PasswordStoreChangeList& ) { … }
void PasswordStoreFetcher::OnLoginsRetained(
password_manager::PasswordStoreInterface* ,
const std::vector<password_manager::PasswordForm>& ) { … }
void PasswordStoreFetcher::Fetch(base::Time start,
base::Time end,
base::OnceClosure fetch_complete) { … }
void PasswordStoreFetcher::OnGetPasswordStoreResults(
std::vector<std::unique_ptr<password_manager::PasswordForm>> results) { … }
void PasswordStoreFetcher::CancelAllRequests() { … }
PasswordsCounter::PasswordsResult::PasswordsResult(
const BrowsingDataCounter* source,
ResultInt profile_passwords,
ResultInt account_passwords,
bool sync_enabled,
std::vector<std::string> domain_examples,
std::vector<std::string> account_domain_examples)
: … { … }
PasswordsCounter::PasswordsResult::~PasswordsResult() = default;
PasswordsCounter::PasswordsCounter(
scoped_refptr<password_manager::PasswordStoreInterface> profile_store,
scoped_refptr<password_manager::PasswordStoreInterface> account_store,
PrefService* pref_service,
syncer::SyncService* sync_service)
: … { … }
PasswordsCounter::~PasswordsCounter() = default;
int PasswordsCounter::num_passwords() { … }
int PasswordsCounter::num_account_passwords() { … }
const std::vector<std::string>& PasswordsCounter::domain_examples() { … }
const std::vector<std::string>& PasswordsCounter::account_domain_examples() { … }
void PasswordsCounter::OnInitialized() { … }
const char* PasswordsCounter::GetPrefName() const { … }
void PasswordsCounter::Count() { … }
void PasswordsCounter::OnPasswordsFetchDone() { … }
std::unique_ptr<PasswordsCounter::PasswordsResult>
PasswordsCounter::MakeResult() { … }
void PasswordsCounter::OnFetchDone() { … }
}