summaryrefslogtreecommitdiffstats
path: root/chrome/browser/webdata/web_data_service.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 21:57:13 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 21:57:13 +0000
commit693d828b212b0c072c108a4530434aeeb6554845 (patch)
tree4166ac193b8dd5faf007ae3bf29c00404b58f7f5 /chrome/browser/webdata/web_data_service.cc
parenteb54a569a3683b10f1d0f8548177d29a3b4ef9be (diff)
downloadchromium_src-693d828b212b0c072c108a4530434aeeb6554845.zip
chromium_src-693d828b212b0c072c108a4530434aeeb6554845.tar.gz
chromium_src-693d828b212b0c072c108a4530434aeeb6554845.tar.bz2
Hook up AutoFill profile DB handling in WebDataService.
BUG=none TEST=none Review URL: http://codereview.chromium.org/552072 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata/web_data_service.cc')
-rw-r--r--chrome/browser/webdata/web_data_service.cc93
1 files changed, 93 insertions, 0 deletions
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index d25492b..3601b8b 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -7,6 +7,7 @@
#include "base/message_loop.h"
#include "base/task.h"
#include "base/thread.h"
+#include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/webdata/autofill_change.h"
#include "chrome/browser/webdata/autofill_entry.h"
#include "chrome/browser/webdata/web_database.h"
@@ -139,6 +140,49 @@ void WebDataService::RemoveFormValueForElementName(
request));
}
+void WebDataService::AddAutoFillProfile(const AutoFillProfile& profile) {
+ GenericRequest<AutoFillProfile>* request =
+ new GenericRequest<AutoFillProfile>(
+ this, GetNextRequestHandle(), NULL, profile);
+ RegisterRequest(request);
+ ScheduleTask(NewRunnableMethod(this,
+ &WebDataService::AddAutoFillProfileImpl,
+ request));
+}
+
+void WebDataService::UpdateAutoFillProfile(const AutoFillProfile& profile) {
+ GenericRequest<AutoFillProfile>* request =
+ new GenericRequest<AutoFillProfile>(
+ this, GetNextRequestHandle(), NULL, profile);
+ RegisterRequest(request);
+ ScheduleTask(NewRunnableMethod(this,
+ &WebDataService::UpdateAutoFillProfileImpl,
+ request));
+}
+
+void WebDataService::RemoveAutoFillProfile(const AutoFillProfile& profile) {
+ GenericRequest<AutoFillProfile>* request =
+ new GenericRequest<AutoFillProfile>(
+ this, GetNextRequestHandle(), NULL, profile);
+ RegisterRequest(request);
+ ScheduleTask(NewRunnableMethod(this,
+ &WebDataService::RemoveAutoFillProfileImpl,
+ request));
+}
+
+WebDataService::Handle WebDataService::GetAutoFillProfileForLabel(
+ const string16& label, WebDataServiceConsumer* consumer) {
+ WebDataRequest* request =
+ new WebDataRequest(this, GetNextRequestHandle(), consumer);
+ RegisterRequest(request);
+ ScheduleTask(
+ NewRunnableMethod(this,
+ &WebDataService::GetAutoFillProfileForLabelImpl,
+ request,
+ label));
+ return request->GetHandle();
+}
+
void WebDataService::RequestCompleted(Handle h) {
pending_lock_.Acquire();
RequestMap::iterator i = pending_requests_.find(h);
@@ -665,6 +709,55 @@ void WebDataService::RemoveFormValueForElementNameImpl(
request->RequestComplete();
}
+void WebDataService::AddAutoFillProfileImpl(
+ GenericRequest<AutoFillProfile>* request) {
+ InitializeDatabaseIfNecessary();
+ if (db_ && !request->IsCancelled()) {
+ const AutoFillProfile& profile = request->GetArgument();
+ if (!db_->AddAutoFillProfile(profile))
+ NOTREACHED();
+ ScheduleCommit();
+ }
+ request->RequestComplete();
+}
+
+void WebDataService::UpdateAutoFillProfileImpl(
+ GenericRequest<AutoFillProfile>* request) {
+ InitializeDatabaseIfNecessary();
+ if (db_ && !request->IsCancelled()) {
+ const AutoFillProfile& profile = request->GetArgument();
+ if (!db_->UpdateAutoFillProfile(profile))
+ NOTREACHED();
+ ScheduleCommit();
+ }
+ request->RequestComplete();
+}
+
+void WebDataService::RemoveAutoFillProfileImpl(
+ GenericRequest<AutoFillProfile>* request) {
+ InitializeDatabaseIfNecessary();
+ if (db_ && !request->IsCancelled()) {
+ const AutoFillProfile& profile = request->GetArgument();
+ if (!db_->RemoveAutoFillProfile(profile))
+ NOTREACHED();
+ ScheduleCommit();
+ }
+ request->RequestComplete();
+}
+
+void WebDataService::GetAutoFillProfileForLabelImpl(WebDataRequest* request,
+ const string16& label) {
+ InitializeDatabaseIfNecessary();
+ if (db_ && !request->IsCancelled()) {
+ AutoFillProfile* profile;
+ db_->GetAutoFillProfileForLabel(label, &profile);
+ request->SetResult(
+ new WDResult<AutoFillProfile>(AUTOFILL_PROFILE_RESULT, *profile));
+ delete profile;
+ }
+ request->RequestComplete();
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// Web Apps implementation.