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

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: Move to Lingesh's observer mechanism. 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
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..bf48b23a68ad26c3f7b11b65f610ea6c72c96ee5 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,39 @@ 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 (!db_->EmptyAutofillProfilesTrash()) {
+ NOTREACHED();
+ return;
+ }
+ ScheduleCommit();
+ }
+ request->RequestComplete();
+}
+
void WebDataService::AddCreditCardImpl(
GenericRequest<CreditCard>* request) {
InitializeDatabaseIfNecessary();

Powered by Google App Engine
This is Rietveld 408576698