| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/webdata/web_data_service.h" | 5 #include "chrome/browser/webdata/web_data_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 GetNextRequestHandle(), | 508 GetNextRequestHandle(), |
| 509 NULL, | 509 NULL, |
| 510 delete_begin, | 510 delete_begin, |
| 511 delete_end); | 511 delete_end); |
| 512 RegisterRequest(request); | 512 RegisterRequest(request); |
| 513 ScheduleTask(FROM_HERE, | 513 ScheduleTask(FROM_HERE, |
| 514 Bind(&WebDataService::RemoveFormElementsAddedBetweenImpl, | 514 Bind(&WebDataService::RemoveFormElementsAddedBetweenImpl, |
| 515 this, request)); | 515 this, request)); |
| 516 } | 516 } |
| 517 | 517 |
| 518 void WebDataService::RemoveExpiredFormElements() { |
| 519 WebDataRequest* request = |
| 520 new WebDataRequest(this, GetNextRequestHandle(), NULL); |
| 521 RegisterRequest(request); |
| 522 ScheduleTask(FROM_HERE, |
| 523 Bind(&WebDataService::RemoveExpiredFormElementsImpl, |
| 524 this, request)); |
| 525 } |
| 526 |
| 518 void WebDataService::RemoveFormValueForElementName( | 527 void WebDataService::RemoveFormValueForElementName( |
| 519 const string16& name, const string16& value) { | 528 const string16& name, const string16& value) { |
| 520 GenericRequest2<string16, string16>* request = | 529 GenericRequest2<string16, string16>* request = |
| 521 new GenericRequest2<string16, string16>(this, | 530 new GenericRequest2<string16, string16>(this, |
| 522 GetNextRequestHandle(), | 531 GetNextRequestHandle(), |
| 523 NULL, | 532 NULL, |
| 524 name, value); | 533 name, value); |
| 525 RegisterRequest(request); | 534 RegisterRequest(request); |
| 526 ScheduleTask(FROM_HERE, | 535 ScheduleTask(FROM_HERE, |
| 527 Bind(&WebDataService::RemoveFormValueForElementNameImpl, | 536 Bind(&WebDataService::RemoveFormValueForElementNameImpl, |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 1260 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
| 1252 content::Source<WebDataService>(this), | 1261 content::Source<WebDataService>(this), |
| 1253 content::Details<AutofillChangeList>(&changes)); | 1262 content::Details<AutofillChangeList>(&changes)); |
| 1254 } | 1263 } |
| 1255 ScheduleCommit(); | 1264 ScheduleCommit(); |
| 1256 } | 1265 } |
| 1257 } | 1266 } |
| 1258 request->RequestComplete(); | 1267 request->RequestComplete(); |
| 1259 } | 1268 } |
| 1260 | 1269 |
| 1270 void WebDataService::RemoveExpiredFormElementsImpl(WebDataRequest* request) { |
| 1271 InitializeDatabaseIfNecessary(); |
| 1272 if (db_ && !request->IsCancelled(NULL)) { |
| 1273 AutofillChangeList changes; |
| 1274 if (db_->GetAutofillTable()->RemoveExpiredFormElements(&changes)) { |
| 1275 if (!changes.empty()) { |
| 1276 request->SetResult( |
| 1277 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); |
| 1278 |
| 1279 // Post the notifications including the list of affected keys. |
| 1280 // This is sent here so that work resulting from this notification |
| 1281 // will be done on the DB thread, and not the UI thread. |
| 1282 content::NotificationService::current()->Notify( |
| 1283 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
| 1284 content::Source<WebDataService>(this), |
| 1285 content::Details<AutofillChangeList>(&changes)); |
| 1286 } |
| 1287 ScheduleCommit(); |
| 1288 } |
| 1289 } |
| 1290 request->RequestComplete(); |
| 1291 } |
| 1292 |
| 1261 void WebDataService::RemoveFormValueForElementNameImpl( | 1293 void WebDataService::RemoveFormValueForElementNameImpl( |
| 1262 GenericRequest2<string16, string16>* request) { | 1294 GenericRequest2<string16, string16>* request) { |
| 1263 InitializeDatabaseIfNecessary(); | 1295 InitializeDatabaseIfNecessary(); |
| 1264 if (db_ && !request->IsCancelled(NULL)) { | 1296 if (db_ && !request->IsCancelled(NULL)) { |
| 1265 const string16& name = request->arg1(); | 1297 const string16& name = request->arg1(); |
| 1266 const string16& value = request->arg2(); | 1298 const string16& value = request->arg2(); |
| 1267 | 1299 |
| 1268 if (db_->GetAutofillTable()->RemoveFormElement(name, value)) { | 1300 if (db_->GetAutofillTable()->RemoveFormElement(name, value)) { |
| 1269 AutofillChangeList changes; | 1301 AutofillChangeList changes; |
| 1270 changes.push_back(AutofillChange(AutofillChange::REMOVE, | 1302 changes.push_back(AutofillChange(AutofillChange::REMOVE, |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 } | 1652 } |
| 1621 | 1653 |
| 1622 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1654 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
| 1623 return result_; | 1655 return result_; |
| 1624 } | 1656 } |
| 1625 | 1657 |
| 1626 void WebDataService::WebDataRequest::RequestComplete() { | 1658 void WebDataService::WebDataRequest::RequestComplete() { |
| 1627 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1659 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
| 1628 service_.get(), handle_)); | 1660 service_.get(), handle_)); |
| 1629 } | 1661 } |
| OLD | NEW |