| 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 "components/autofill/browser/webdata/autofill_webdata_service.h" | 5 #include "components/autofill/browser/webdata/autofill_webdata_service.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "components/autofill/browser/autofill_country.h" | 9 #include "components/autofill/browser/autofill_country.h" |
| 10 #include "components/autofill/browser/autofill_profile.h" | 10 #include "components/autofill/browser/autofill_profile.h" |
| 11 #include "components/autofill/browser/credit_card.h" | 11 #include "components/autofill/browser/credit_card.h" |
| 12 #include "components/autofill/browser/webdata/autofill_change.h" | 12 #include "components/autofill/browser/webdata/autofill_change.h" |
| 13 #include "components/autofill/browser/webdata/autofill_entry.h" | 13 #include "components/autofill/browser/webdata/autofill_entry.h" |
| 14 #include "components/autofill/browser/webdata/autofill_table.h" | 14 #include "components/autofill/browser/webdata/autofill_table.h" |
| 15 #include "components/autofill/browser/webdata/autofill_webdata_backend_impl.h" | 15 #include "components/autofill/browser/webdata/autofill_webdata_backend_impl.h" |
| 16 #include "components/autofill/browser/webdata/autofill_webdata_service_observer.
h" | 16 #include "components/autofill/browser/webdata/autofill_webdata_service_observer.
h" |
| 17 #include "components/autofill/common/form_field_data.h" | 17 #include "components/autofill/common/form_field_data.h" |
| 18 #include "components/webdata/common/web_data_service_backend.h" | 18 #include "components/webdata/common/web_data_service_backend.h" |
| 19 #include "components/webdata/common/web_database_service.h" | 19 #include "components/webdata/common/web_database_service.h" |
| 20 | 20 |
| 21 using base::Bind; | 21 using base::Bind; |
| 22 using base::Time; | 22 using base::Time; |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 | 24 |
| 25 namespace autofill { | 25 namespace autofill { |
| 26 | 26 |
| 27 // static | |
| 28 void AutofillWebDataService::NotifyOfMultipleAutofillChanges( | |
| 29 AutofillWebDataService* web_data_service) { | |
| 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 31 | |
| 32 if (!web_data_service) | |
| 33 return; | |
| 34 | |
| 35 BrowserThread::PostTask( | |
| 36 BrowserThread::UI, FROM_HERE, | |
| 37 Bind(&AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread, | |
| 38 make_scoped_refptr(web_data_service))); | |
| 39 } | |
| 40 | |
| 41 AutofillWebDataService::AutofillWebDataService( | 27 AutofillWebDataService::AutofillWebDataService( |
| 42 scoped_refptr<WebDatabaseService> wdbs, | 28 scoped_refptr<WebDatabaseService> wdbs, |
| 43 const ProfileErrorCallback& callback) | 29 const ProfileErrorCallback& callback) |
| 44 : WebDataServiceBase(wdbs, callback), | 30 : WebDataServiceBase(wdbs, callback), |
| 45 weak_ptr_factory_(this), | 31 weak_ptr_factory_(this), |
| 46 autofill_backend_(NULL) { | 32 autofill_backend_(NULL) { |
| 47 | 33 |
| 48 base::Closure on_changed_callback = Bind( | 34 base::Closure on_changed_callback = Bind( |
| 49 &AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread, | 35 &AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread, |
| 50 weak_ptr_factory_.GetWeakPtr()); | 36 weak_ptr_factory_.GetWeakPtr()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 consumer); | 77 consumer); |
| 92 } | 78 } |
| 93 | 79 |
| 94 void AutofillWebDataService::RemoveFormElementsAddedBetween( | 80 void AutofillWebDataService::RemoveFormElementsAddedBetween( |
| 95 const Time& delete_begin, const Time& delete_end) { | 81 const Time& delete_begin, const Time& delete_end) { |
| 96 wdbs_->ScheduleDBTask(FROM_HERE, | 82 wdbs_->ScheduleDBTask(FROM_HERE, |
| 97 Bind(&AutofillWebDataBackendImpl::RemoveFormElementsAddedBetween, | 83 Bind(&AutofillWebDataBackendImpl::RemoveFormElementsAddedBetween, |
| 98 autofill_backend_, delete_begin, delete_end)); | 84 autofill_backend_, delete_begin, delete_end)); |
| 99 } | 85 } |
| 100 | 86 |
| 101 void AutofillWebDataService::RemoveExpiredFormElements() { | |
| 102 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 103 Bind(&AutofillWebDataBackendImpl::RemoveExpiredFormElements, | |
| 104 autofill_backend_)); | |
| 105 } | |
| 106 | |
| 107 void AutofillWebDataService::RemoveFormValueForElementName( | 87 void AutofillWebDataService::RemoveFormValueForElementName( |
| 108 const base::string16& name, const base::string16& value) { | 88 const base::string16& name, const base::string16& value) { |
| 109 wdbs_->ScheduleDBTask(FROM_HERE, | 89 wdbs_->ScheduleDBTask(FROM_HERE, |
| 110 Bind(&AutofillWebDataBackendImpl::RemoveFormValueForElementName, | 90 Bind(&AutofillWebDataBackendImpl::RemoveFormValueForElementName, |
| 111 autofill_backend_, name, value)); | 91 autofill_backend_, name, value)); |
| 112 } | 92 } |
| 113 | 93 |
| 114 void AutofillWebDataService::AddAutofillProfile( | 94 void AutofillWebDataService::AddAutofillProfile( |
| 115 const AutofillProfile& profile) { | 95 const AutofillProfile& profile) { |
| 116 wdbs_->ScheduleDBTask(FROM_HERE, | 96 wdbs_->ScheduleDBTask(FROM_HERE, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } | 207 } |
| 228 | 208 |
| 229 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { | 209 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { |
| 230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 231 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, | 211 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, |
| 232 ui_observer_list_, | 212 ui_observer_list_, |
| 233 AutofillMultipleChanged()); | 213 AutofillMultipleChanged()); |
| 234 } | 214 } |
| 235 | 215 |
| 236 } // namespace autofill | 216 } // namespace autofill |
| OLD | NEW |