Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: components/autofill/core/browser/personal_data_manager.cc

Issue 2077003002: [Autofill] Fix profiles with bad |use_date| values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 1line fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/personal_data_manager.cc
diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc
index 6ce10680e2d07e629e4c2f209efa253e8fadc79f..525f808c1b0bcd823eb9fbc0ae0109668c43ff52 100644
--- a/components/autofill/core/browser/personal_data_manager.cc
+++ b/components/autofill/core/browser/personal_data_manager.cc
@@ -324,6 +324,7 @@ void PersonalDataManager::OnWebDataServiceRequestDone(
ReceiveLoadedDbValues(h, result, &pending_profiles_query_,
&web_profiles_);
LogProfileCount(); // This only logs local profiles.
+ ApplyProfileUseDatesFix();
} else {
ReceiveLoadedDbValues(h, result, &pending_server_profiles_query_,
&server_profiles_);
@@ -1603,4 +1604,26 @@ void PersonalDataManager::FindAndMergeDuplicateProfiles(
profile_guids_to_delete->size());
}
+void PersonalDataManager::ApplyProfileUseDatesFix() {
+ // Don't run if the fix has already been applied.
+ if (pref_service_->GetBoolean(prefs::kAutofillProfileUseDatesFixed))
+ return;
+
+ std::vector<AutofillProfile> profiles;
+ bool has_changed_data = false;
+ for (AutofillProfile* profile : web_profiles()) {
+ if (profile->use_date() == base::Time()) {
+ profile->set_use_date(base::Time::Now() - base::TimeDelta::FromDays(14));
+ has_changed_data = true;
+ }
+ profiles.push_back(*profile);
+ }
+
+ // Set the pref so that this fix is never run again.
+ pref_service_->SetBoolean(prefs::kAutofillProfileUseDatesFixed, true);
+
+ if (has_changed_data)
+ SetProfiles(&profiles);
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698