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

Unified Diff: chrome/browser/webdata/web_data_service.cc

Issue 6676031: Autofill database migration to clean up bogus profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adds fix for upload. Created 9 years, 9 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
« no previous file with comments | « chrome/browser/webdata/web_data_service.h ('k') | chrome/browser/webdata/web_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/web_data_service.cc
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index 6fa69b4d1258e6e69c2840633540f73ac5d8e207..1391dbfadaa1dc2d749dce4d8b08ea26ae285753 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -434,6 +434,16 @@ WebDataService::Handle WebDataService::GetAutofillProfiles(
return request->GetHandle();
}
+void WebDataService::EmptyMigrationTrash(bool notify_sync) {
+ GenericRequest<bool>* request =
+ new GenericRequest<bool>(
+ this, GetNextRequestHandle(), NULL, notify_sync);
+ RegisterRequest(request);
+ ScheduleTask(NewRunnableMethod(this,
+ &WebDataService::EmptyMigrationTrashImpl,
+ request));
+}
+
void WebDataService::AddCreditCard(const CreditCard& credit_card) {
GenericRequest<CreditCard>* request =
new GenericRequest<CreditCard>(
@@ -1088,6 +1098,57 @@ void WebDataService::GetAutofillProfilesImpl(WebDataRequest* request) {
request->RequestComplete();
}
+void WebDataService::EmptyMigrationTrashImpl(
+ GenericRequest<bool>* request) {
+ InitializeDatabaseIfNecessary();
+ if (db_ && !request->IsCancelled()) {
+ bool notify_sync = request->GetArgument();
+ if (notify_sync) {
+ std::vector<std::string> guids;
+ if (!db_->GetAutofillProfilesInTrash(&guids)) {
+ NOTREACHED();
+ return;
+ }
+
+ for (std::vector<std::string>::const_iterator iter = guids.begin();
+ iter != guids.end(); ++iter) {
+ // Send GUID-based notification.
+ AutofillProfileChange change(AutofillProfileChange::REMOVE,
+ *iter, NULL);
+ NotificationService::current()->Notify(
+ NotificationType::AUTOFILL_PROFILE_CHANGED,
+ Source<WebDataService>(this),
+ Details<AutofillProfileChange>(&change));
+ }
+
+ // If we trashed any profiles they may have been merged, so send out
+ // update notifications as well.
+ if (!guids.empty()) {
+ std::vector<AutofillProfile*> profiles;
+ db_->GetAutofillProfiles(&profiles);
+ for (std::vector<AutofillProfile*>::const_iterator
+ iter = profiles.begin();
+ iter != profiles.end(); ++iter) {
+ AutofillProfileChange change(AutofillProfileChange::UPDATE,
+ (*iter)->guid(), *iter);
+ NotificationService::current()->Notify(
+ NotificationType::AUTOFILL_PROFILE_CHANGED,
+ Source<WebDataService>(this),
+ Details<AutofillProfileChange>(&change));
+ }
+ STLDeleteElements(&profiles);
+ }
+ }
+
+ if (!db_->EmptyAutofillProfilesTrash()) {
+ NOTREACHED();
+ return;
+ }
+ ScheduleCommit();
+ }
+ request->RequestComplete();
+}
+
void WebDataService::AddCreditCardImpl(
GenericRequest<CreditCard>* request) {
InitializeDatabaseIfNecessary();
« no previous file with comments | « chrome/browser/webdata/web_data_service.h ('k') | chrome/browser/webdata/web_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698