| 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/webdata/autofill/autofill_webdata_service.h" | 5 #include "components/webdata/autofill/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" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 WebDataServiceBase::ProfileErrorCallback()) { | 45 WebDataServiceBase::ProfileErrorCallback()) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 void AutofillWebDataService::AddFormFields( | 48 void AutofillWebDataService::AddFormFields( |
| 49 const std::vector<FormFieldData>& fields) { | 49 const std::vector<FormFieldData>& fields) { |
| 50 wdbs_->ScheduleDBTask(FROM_HERE, | 50 wdbs_->ScheduleDBTask(FROM_HERE, |
| 51 Bind(&AutofillWebDataService::AddFormElementsImpl, this, fields)); | 51 Bind(&AutofillWebDataService::AddFormElementsImpl, this, fields)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 WebDataServiceBase::Handle AutofillWebDataService::GetFormValuesForElementName( | 54 WebDataServiceBase::Handle AutofillWebDataService::GetFormValuesForElementName( |
| 55 const string16& name, const string16& prefix, int limit, | 55 const base::string16& name, const base::string16& prefix, int limit, |
| 56 WebDataServiceConsumer* consumer) { | 56 WebDataServiceConsumer* consumer) { |
| 57 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 57 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
| 58 Bind(&AutofillWebDataService::GetFormValuesForElementNameImpl, | 58 Bind(&AutofillWebDataService::GetFormValuesForElementNameImpl, |
| 59 this, name, prefix, limit), consumer); | 59 this, name, prefix, limit), consumer); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void AutofillWebDataService::RemoveFormElementsAddedBetween( | 62 void AutofillWebDataService::RemoveFormElementsAddedBetween( |
| 63 const Time& delete_begin, const Time& delete_end) { | 63 const Time& delete_begin, const Time& delete_end) { |
| 64 wdbs_->ScheduleDBTask(FROM_HERE, | 64 wdbs_->ScheduleDBTask(FROM_HERE, |
| 65 Bind(&AutofillWebDataService::RemoveFormElementsAddedBetweenImpl, | 65 Bind(&AutofillWebDataService::RemoveFormElementsAddedBetweenImpl, |
| 66 this, delete_begin, delete_end)); | 66 this, delete_begin, delete_end)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void AutofillWebDataService::RemoveExpiredFormElements() { | 69 void AutofillWebDataService::RemoveExpiredFormElements() { |
| 70 wdbs_->ScheduleDBTask(FROM_HERE, | 70 wdbs_->ScheduleDBTask(FROM_HERE, |
| 71 Bind(&AutofillWebDataService::RemoveExpiredFormElementsImpl, this)); | 71 Bind(&AutofillWebDataService::RemoveExpiredFormElementsImpl, this)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void AutofillWebDataService::RemoveFormValueForElementName( | 74 void AutofillWebDataService::RemoveFormValueForElementName( |
| 75 const string16& name, const string16& value) { | 75 const base::string16& name, const base::string16& value) { |
| 76 wdbs_->ScheduleDBTask(FROM_HERE, | 76 wdbs_->ScheduleDBTask(FROM_HERE, |
| 77 Bind(&AutofillWebDataService::RemoveFormValueForElementNameImpl, | 77 Bind(&AutofillWebDataService::RemoveFormValueForElementNameImpl, |
| 78 this, name, value)); | 78 this, name, value)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void AutofillWebDataService::AddAutofillProfile( | 81 void AutofillWebDataService::AddAutofillProfile( |
| 82 const AutofillProfile& profile) { | 82 const AutofillProfile& profile) { |
| 83 wdbs_->ScheduleDBTask(FROM_HERE, | 83 wdbs_->ScheduleDBTask(FROM_HERE, |
| 84 Bind(&AutofillWebDataService::AddAutofillProfileImpl, this, profile)); | 84 Bind(&AutofillWebDataService::AddAutofillProfileImpl, this, profile)); |
| 85 } | 85 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // done on the DB thread, and not the UI thread. | 192 // done on the DB thread, and not the UI thread. |
| 193 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnDBThread, | 193 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnDBThread, |
| 194 db_observer_list_, | 194 db_observer_list_, |
| 195 AutofillEntriesChanged(changes)); | 195 AutofillEntriesChanged(changes)); |
| 196 | 196 |
| 197 return WebDatabase::COMMIT_NEEDED; | 197 return WebDatabase::COMMIT_NEEDED; |
| 198 } | 198 } |
| 199 | 199 |
| 200 scoped_ptr<WDTypedResult> | 200 scoped_ptr<WDTypedResult> |
| 201 AutofillWebDataService::GetFormValuesForElementNameImpl( | 201 AutofillWebDataService::GetFormValuesForElementNameImpl( |
| 202 const string16& name, const string16& prefix, int limit, WebDatabase* db) { | 202 const base::string16& name, const base::string16& prefix, int limit, |
| 203 WebDatabase* db) { |
| 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 204 std::vector<string16> values; | 205 std::vector<base::string16> values; |
| 205 AutofillTable::FromWebDatabase(db)->GetFormValuesForElementName( | 206 AutofillTable::FromWebDatabase(db)->GetFormValuesForElementName( |
| 206 name, prefix, &values, limit); | 207 name, prefix, &values, limit); |
| 207 return scoped_ptr<WDTypedResult>( | 208 return scoped_ptr<WDTypedResult>( |
| 208 new WDResult<std::vector<string16> >(AUTOFILL_VALUE_RESULT, values)); | 209 new WDResult<std::vector<base::string16> >(AUTOFILL_VALUE_RESULT, |
| 210 values)); |
| 209 } | 211 } |
| 210 | 212 |
| 211 WebDatabase::State AutofillWebDataService::RemoveFormElementsAddedBetweenImpl( | 213 WebDatabase::State AutofillWebDataService::RemoveFormElementsAddedBetweenImpl( |
| 212 const base::Time& delete_begin, const base::Time& delete_end, | 214 const base::Time& delete_begin, const base::Time& delete_end, |
| 213 WebDatabase* db) { | 215 WebDatabase* db) { |
| 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 215 AutofillChangeList changes; | 217 AutofillChangeList changes; |
| 216 | 218 |
| 217 if (AutofillTable::FromWebDatabase(db)->RemoveFormElementsAddedBetween( | 219 if (AutofillTable::FromWebDatabase(db)->RemoveFormElementsAddedBetween( |
| 218 delete_begin, delete_end, &changes)) { | 220 delete_begin, delete_end, &changes)) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 242 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnDBThread, | 244 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnDBThread, |
| 243 db_observer_list_, | 245 db_observer_list_, |
| 244 AutofillEntriesChanged(changes)); | 246 AutofillEntriesChanged(changes)); |
| 245 } | 247 } |
| 246 return WebDatabase::COMMIT_NEEDED; | 248 return WebDatabase::COMMIT_NEEDED; |
| 247 } | 249 } |
| 248 return WebDatabase::COMMIT_NOT_NEEDED; | 250 return WebDatabase::COMMIT_NOT_NEEDED; |
| 249 } | 251 } |
| 250 | 252 |
| 251 WebDatabase::State AutofillWebDataService::RemoveFormValueForElementNameImpl( | 253 WebDatabase::State AutofillWebDataService::RemoveFormValueForElementNameImpl( |
| 252 const string16& name, const string16& value, WebDatabase* db) { | 254 const base::string16& name, const base::string16& value, WebDatabase* db) { |
| 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 254 | 256 |
| 255 if (AutofillTable::FromWebDatabase(db)->RemoveFormElement(name, value)) { | 257 if (AutofillTable::FromWebDatabase(db)->RemoveFormElement(name, value)) { |
| 256 AutofillChangeList changes; | 258 AutofillChangeList changes; |
| 257 changes.push_back( | 259 changes.push_back( |
| 258 AutofillChange(AutofillChange::REMOVE, AutofillKey(name, value))); | 260 AutofillChange(AutofillChange::REMOVE, AutofillKey(name, value))); |
| 259 | 261 |
| 260 // Post the notifications including the list of affected keys. | 262 // Post the notifications including the list of affected keys. |
| 261 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnDBThread, | 263 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnDBThread, |
| 262 db_observer_list_, | 264 db_observer_list_, |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 std::vector<CreditCard*> credit_cards = r->GetValue(); | 451 std::vector<CreditCard*> credit_cards = r->GetValue(); |
| 450 STLDeleteElements(&credit_cards); | 452 STLDeleteElements(&credit_cards); |
| 451 } | 453 } |
| 452 | 454 |
| 453 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { | 455 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { |
| 454 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 456 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 455 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, | 457 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, |
| 456 ui_observer_list_, | 458 ui_observer_list_, |
| 457 AutofillMultipleChanged()); | 459 AutofillMultipleChanged()); |
| 458 } | 460 } |
| OLD | NEW |