#include "chrome/browser/ui/safety_hub/password_status_check_service.h"
#include <memory>
#include <random>
#include <vector>
#include "base/barrier_closure.h"
#include "base/json/values_util.h"
#include "base/metrics/user_metrics.h"
#include "base/rand_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/affiliations/affiliation_service_factory.h"
#include "chrome/browser/password_manager/account_password_store_factory.h"
#include "chrome/browser/password_manager/profile_password_store_factory.h"
#include "chrome/browser/ui/safety_hub/password_status_check_result.h"
#include "chrome/browser/ui/safety_hub/safety_hub_constants.h"
#include "chrome/browser/ui/safety_hub/safety_hub_prefs.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/browser/leak_detection/bulk_leak_check_service.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_request_utils.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/ui/bulk_leak_check_service_adapter.h"
#include "components/password_manager/core/browser/ui/credential_ui_entry.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/time_format.h"
InsecureType;
namespace {
std::map<std::string, int> GetDayPrefWeightMap() { … }
base::TimeDelta FindNewCheckTime() { … }
bool ShouldFindNewCheckTime(Profile* profile) { … }
base::Value::Dict GetCompromisedPasswordCardData(int compromised_count) { … }
base::Value::Dict GetReusedPasswordCardData(int reused_count, bool signed_in) { … }
base::Value::Dict GetWeakPasswordCardData(int weak_count, bool signed_in) { … }
base::Value::Dict GetSafePasswordCardData(base::Time last_check) { … }
base::Value::Dict GetNoWeakOrReusedPasswordCardData(bool signed_in) { … }
base::Value::Dict GetNoPasswordCardData(bool password_saving_allowed) { … }
bool ShouldAddToCompromisedPasswords(
const password_manager::PasswordForm form) { … }
int GetSavedPasswordsCount(
password_manager::SavedPasswordsPresenter* saved_passwords_presenter) { … }
}
PasswordStatusCheckService::PasswordStatusCheckService(Profile* profile)
: … { … }
PasswordStatusCheckService::~PasswordStatusCheckService() = default;
void PasswordStatusCheckService::Shutdown() { … }
bool PasswordStatusCheckService::is_password_check_running() const { … }
void PasswordStatusCheckService::StartRepeatedUpdates() { … }
void PasswordStatusCheckService::UpdateInsecureCredentialCountAsync() { … }
void PasswordStatusCheckService::RunPasswordCheckAsync() { … }
void PasswordStatusCheckService::RunWeakReusedCheckAsync() { … }
void PasswordStatusCheckService::OnWeakAndReuseChecksDone() { … }
void PasswordStatusCheckService::OnStateChanged(
password_manager::BulkLeakCheckServiceInterface::State state) { … }
void PasswordStatusCheckService::OnCredentialDone(
const password_manager::LeakCheckCredential& credential,
password_manager::IsLeaked is_leaked) { … }
void PasswordStatusCheckService::OnLoginsChanged(
password_manager::PasswordStoreInterface* store,
const password_manager::PasswordStoreChangeList& changes) { … }
void PasswordStatusCheckService::OnLoginsRetained(
password_manager::PasswordStoreInterface* store,
const std::vector<password_manager::PasswordForm>& retained_passwords) { … }
void PasswordStatusCheckService::OnInsecureCredentialsChanged() { … }
void PasswordStatusCheckService::MaybeInitializePasswordCheckInfrastructure(
base::OnceClosure completion) { … }
void PasswordStatusCheckService::UpdateInsecureCredentialCount() { … }
void PasswordStatusCheckService::MaybeResetInfrastructure() { … }
bool PasswordStatusCheckService::IsInfrastructureReady() const { … }
void PasswordStatusCheckService::SetPasswordCheckSchedulePrefsWithInterval(
base::Time check_time) { … }
base::Time PasswordStatusCheckService::GetScheduledPasswordCheckTime() const { … }
base::TimeDelta PasswordStatusCheckService::GetScheduledPasswordCheckInterval()
const { … }
base::Value::Dict PasswordStatusCheckService::GetPasswordCardData(
bool signed_in) { … }
void PasswordStatusCheckService::ScheduleCheckAndStartRepeatedUpdates() { … }
void PasswordStatusCheckService::OnBulkCheckServiceShutDown() { … }
bool PasswordStatusCheckService::IsUpdateRunning() const { … }
std::optional<std::unique_ptr<SafetyHubService::Result>>
PasswordStatusCheckService::GetCachedResult() { … }