Commit 7f9d9cc4 authored by Jialiu Lin's avatar Jialiu Lin Committed by Commit Bot

Rename PrepareSyncPasswordHashData to PreparePasswordHashData

Since now we need to prepare password hash for both sync, other gaia
and enterprise passwords, we should rename the function as
PasswordStore::PreparePasswordHashData(..) and don't gate on empty
sync username.

Also fix minor UMA logging issue in
PasswordStore::SaveProtectedPasswordHashImpl

Bug: 830998
Change-Id: I26cb613babcdd0268785e61b52c021aa9f343cb5
Reviewed-on: https://chromium-review.googlesource.com/1112586Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Commit-Queue: Jialiu Lin <jialiul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570099}
parent bc8d1089
...@@ -271,10 +271,8 @@ PasswordStoreFactory::BuildServiceInstanceFor( ...@@ -271,10 +271,8 @@ PasswordStoreFactory::BuildServiceInstanceFor(
} }
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED) #if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
// Prepare sync password hash data for reuse detection. // Prepare password hash data for reuse detection.
std::string sync_username = GetSyncUsername(profile); ps->PreparePasswordHashData(GetSyncUsername(profile));
if (!sync_username.empty())
ps->PrepareSyncPasswordHashData(sync_username);
#endif #endif
// TODO(https://crbug.com/817754): remove the code once majority of the users // TODO(https://crbug.com/817754): remove the code once majority of the users
......
...@@ -361,11 +361,11 @@ void PasswordStore::CheckReuse(const base::string16& input, ...@@ -361,11 +361,11 @@ void PasswordStore::CheckReuse(const base::string16& input,
#endif #endif
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED) #if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
void PasswordStore::PrepareSyncPasswordHashData( void PasswordStore::PreparePasswordHashData(const std::string& sync_username) {
const std::string& sync_username) {
// TODO(crbug.com/841438): Delete migration code when most users complete // TODO(crbug.com/841438): Delete migration code when most users complete
// the migration. // the migration.
hash_password_manager_.MaybeMigrateExistingSyncPasswordHash(sync_username); if (!sync_username.empty())
hash_password_manager_.MaybeMigrateExistingSyncPasswordHash(sync_username);
SchedulePasswordHashUpdate(/*should_log_metrics=*/true); SchedulePasswordHashUpdate(/*should_log_metrics=*/true);
ScheduleEnterprisePasswordURLUpdate(); ScheduleEnterprisePasswordURLUpdate();
} }
...@@ -560,8 +560,11 @@ void PasswordStore::SaveProtectedPasswordHashImpl( ...@@ -560,8 +560,11 @@ void PasswordStore::SaveProtectedPasswordHashImpl(
else else
enterprise_password_hash_list.push_back(std::move(password_hash)); enterprise_password_hash_list.push_back(std::move(password_hash));
} }
metrics_util::LogProtectedPasswordHashCounts(
gaia_password_hash_list.size(), enterprise_password_hash_list.size()); if (should_log_metrics) {
metrics_util::LogProtectedPasswordHashCounts(
gaia_password_hash_list.size(), enterprise_password_hash_list.size());
}
reuse_detector_->UseGaiaPasswordHash(std::move(gaia_password_hash_list)); reuse_detector_->UseGaiaPasswordHash(std::move(gaia_password_hash_list));
reuse_detector_->UseNonGaiaEnterprisePasswordHash( reuse_detector_->UseNonGaiaEnterprisePasswordHash(
std::move(enterprise_password_hash_list)); std::move(enterprise_password_hash_list));
......
...@@ -256,9 +256,9 @@ class PasswordStore : protected PasswordStoreSync, ...@@ -256,9 +256,9 @@ class PasswordStore : protected PasswordStoreSync,
// TODO(crbug.com/706392): Fix password reuse detection for Android. // TODO(crbug.com/706392): Fix password reuse detection for Android.
#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED) #if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
// Immediately called after |Init()| to retrieve sync password hash data for // Immediately called after |Init()| to retrieve password hash data for
// reuse detection. // reuse detection.
void PrepareSyncPasswordHashData(const std::string& sync_username); void PreparePasswordHashData(const std::string& sync_username);
// Checks that some suffix of |input| equals to a password saved on another // Checks that some suffix of |input| equals to a password saved on another
// registry controlled domain than |domain|. // registry controlled domain than |domain|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment