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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/personal_data_manager.h" 5 #include "components/autofill/core/browser/personal_data_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 pending_profiles_query_ = 0; 317 pending_profiles_query_ = 0;
318 return; 318 return;
319 } 319 }
320 320
321 switch (result->GetType()) { 321 switch (result->GetType()) {
322 case AUTOFILL_PROFILES_RESULT: 322 case AUTOFILL_PROFILES_RESULT:
323 if (h == pending_profiles_query_) { 323 if (h == pending_profiles_query_) {
324 ReceiveLoadedDbValues(h, result, &pending_profiles_query_, 324 ReceiveLoadedDbValues(h, result, &pending_profiles_query_,
325 &web_profiles_); 325 &web_profiles_);
326 LogProfileCount(); // This only logs local profiles. 326 LogProfileCount(); // This only logs local profiles.
327 ApplyProfileUseDatesFix();
327 } else { 328 } else {
328 ReceiveLoadedDbValues(h, result, &pending_server_profiles_query_, 329 ReceiveLoadedDbValues(h, result, &pending_server_profiles_query_,
329 &server_profiles_); 330 &server_profiles_);
330 331
331 if (!server_profiles_.empty()) { 332 if (!server_profiles_.empty()) {
332 std::string account_id = signin_manager_->GetAuthenticatedAccountId(); 333 std::string account_id = signin_manager_->GetAuthenticatedAccountId();
333 base::string16 email = 334 base::string16 email =
334 base::UTF8ToUTF16( 335 base::UTF8ToUTF16(
335 account_tracker_->GetAccountInfo(account_id).email); 336 account_tracker_->GetAccountInfo(account_id).email);
336 337
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 // existing profiles. 1597 // existing profiles.
1597 profile_to_merge = existing_profile; 1598 profile_to_merge = existing_profile;
1598 } 1599 }
1599 } 1600 }
1600 } 1601 }
1601 1602
1602 AutofillMetrics::LogNumberOfProfilesRemovedDuringDedupe( 1603 AutofillMetrics::LogNumberOfProfilesRemovedDuringDedupe(
1603 profile_guids_to_delete->size()); 1604 profile_guids_to_delete->size());
1604 } 1605 }
1605 1606
1607 void PersonalDataManager::ApplyProfileUseDatesFix() {
1608 // Don't run if the fix has already been applied.
1609 if (pref_service_->GetBoolean(prefs::kAutofillProfileUseDatesFixed))
1610 return;
1611
1612 std::vector<AutofillProfile> profiles;
1613 bool has_changed_data = false;
1614 for (AutofillProfile* profile : web_profiles()) {
1615 if (profile->use_date() == base::Time()) {
1616 profile->set_use_date(base::Time::Now() - base::TimeDelta::FromDays(14));
1617 has_changed_data = true;
1618 }
1619 profiles.push_back(*profile);
1620 }
1621
1622 // Set the pref so that this fix is never run again.
1623 pref_service_->SetBoolean(prefs::kAutofillProfileUseDatesFixed, true);
1624
1625 if (has_changed_data)
1626 SetProfiles(&profiles);
1627 }
1628
1606 } // namespace autofill 1629 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698