Commit 22b6bf27 authored by Vidhan's avatar Vidhan Committed by Chromium LUCI CQ

[Autofill][States] Use Observer to populate AlternativeStateNameMap if

profile dedupe has already run

The profile deduplication is run once every chrome version. Since,
AlternativeStateNameMap needs to be populated before running the
deduplication logic, it does not make sense to synchronize populating
the map every time on browser startup.

With this change, AlternativeStateNameMapUpdater would be populating
the AlternativeStateNameMap on the browser startup if the profile
deduplication logic has already been run for the current chrome
version.

Bug: 1111960
Change-Id: I2964d292c726083dcde069bf1e2596e723db2679
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2632671Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Reviewed-by: default avatarMatthias Körber <koerber@google.com>
Commit-Queue: Vidhan Jain <vidhanj@google.com>
Cr-Commit-Position: refs/heads/master@{#844547}
parent 023cbbd9
......@@ -38,10 +38,16 @@ PersonalDataManagerCleaner::PersonalDataManagerCleaner(
PersonalDataManagerCleaner::~PersonalDataManagerCleaner() = default;
void PersonalDataManagerCleaner::CleanupDataAndNotifyPersonalDataObservers() {
// The profile de-duplication is run once every major chrome version. If the
// profile de-duplication has not run for the |CHROME_VERSION_MAJOR| yet,
// |AlternativeStateNameMap| needs to be populated first. Otherwise,
// defer the insertion to when the observers are notified.
if (!alternative_state_name_map_updater_
->is_alternative_state_name_map_populated() &&
base::FeatureList::IsEnabled(
features::kAutofillUseAlternativeStateNameMap)) {
features::kAutofillUseAlternativeStateNameMap) &&
pref_service_->GetInteger(prefs::kAutofillLastVersionDeduped) <
CHROME_VERSION_MAJOR) {
alternative_state_name_map_updater_->PopulateAlternativeStateNameMap(
base::BindOnce(&PersonalDataManagerCleaner::
CleanupDataAndNotifyPersonalDataObservers,
......@@ -68,10 +74,16 @@ void PersonalDataManagerCleaner::CleanupDataAndNotifyPersonalDataObservers() {
}
void PersonalDataManagerCleaner::SyncStarted(syncer::ModelType model_type) {
// The profile de-duplication is run once every major chrome version. If the
// profile de-duplication has not run for the |CHROME_VERSION_MAJOR| yet,
// |AlternativeStateNameMap| needs to be populated first. Otherwise,
// defer the insertion to when the observers are notified.
if (!alternative_state_name_map_updater_
->is_alternative_state_name_map_populated() &&
base::FeatureList::IsEnabled(
features::kAutofillUseAlternativeStateNameMap)) {
features::kAutofillUseAlternativeStateNameMap) &&
pref_service_->GetInteger(prefs::kAutofillLastVersionDeduped) <
CHROME_VERSION_MAJOR) {
alternative_state_name_map_updater_->PopulateAlternativeStateNameMap(
base::BindOnce(&PersonalDataManagerCleaner::SyncStarted,
weak_ptr_factory_.GetWeakPtr(), model_type));
......
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