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/autofill_web_data_service_impl.h" | 5 #include "chrome/browser/webdata/autofill_web_data_service_impl.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 "chrome/browser/webdata/autofill_change.h" | 9 #include "chrome/browser/webdata/autofill_change.h" |
10 #include "chrome/browser/webdata/autofill_entry.h" | 10 #include "chrome/browser/webdata/autofill_entry.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 wdbs_->ScheduleDBTask(FROM_HERE, | 143 wdbs_->ScheduleDBTask(FROM_HERE, |
144 Bind(&AutofillWebDataServiceImpl::RemoveCreditCardImpl, this, guid)); | 144 Bind(&AutofillWebDataServiceImpl::RemoveCreditCardImpl, this, guid)); |
145 } | 145 } |
146 | 146 |
147 AutofillWebDataServiceImpl::Handle AutofillWebDataServiceImpl::GetCreditCards( | 147 AutofillWebDataServiceImpl::Handle AutofillWebDataServiceImpl::GetCreditCards( |
148 WebDataServiceConsumer* consumer) { | 148 WebDataServiceConsumer* consumer) { |
149 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 149 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
150 Bind(&AutofillWebDataServiceImpl::GetCreditCardsImpl, this), consumer); | 150 Bind(&AutofillWebDataServiceImpl::GetCreditCardsImpl, this), consumer); |
151 } | 151 } |
152 | 152 |
153 void AutofillWebDataServiceImpl::RemoveFormElementsAddedBetween( | |
154 const Time& delete_begin, const Time& delete_end) { | |
155 wdbs_->ScheduleDBTask(FROM_HERE, | |
156 Bind(&AutofillWebDataServiceImpl::RemoveFormElementsAddedBetweenImpl, | |
157 this, delete_begin, delete_end)); | |
158 } | |
159 | |
160 void | |
161 AutofillWebDataServiceImpl::RemoveAutofillProfilesAndCreditCardsModifiedBetween( | |
162 const Time& delete_begin, const Time& delete_end) { | |
163 wdbs_->ScheduleDBTask(FROM_HERE, Bind( | |
164 &AutofillWebDataServiceImpl::RemoveAutofillProfilesAndCreditCardsModifiedBetween Impl, | |
dhollowa
2013/03/25 21:50:38
Gosh, this is excessive. How would you feel about
Cait (Slow)
2013/03/26 14:29:23
Done. There is a method of the same name on the Au
dhollowa
2013/03/26 15:14:09
Yes, please.
| |
165 this, delete_begin, delete_end)); | |
166 } | |
167 | |
153 AutofillWebDataServiceImpl::~AutofillWebDataServiceImpl() { | 168 AutofillWebDataServiceImpl::~AutofillWebDataServiceImpl() { |
154 } | 169 } |
155 | 170 |
156 //////////////////////////////////////////////////////////////////////////////// | 171 //////////////////////////////////////////////////////////////////////////////// |
157 // | 172 // |
158 // Autofill implementation. | 173 // Autofill implementation. |
159 // | 174 // |
160 //////////////////////////////////////////////////////////////////////////////// | 175 //////////////////////////////////////////////////////////////////////////////// |
161 | 176 |
162 WebDatabase::State AutofillWebDataServiceImpl::AddFormElementsImpl( | 177 WebDatabase::State AutofillWebDataServiceImpl::AddFormElementsImpl( |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 std::vector<CreditCard*> credit_cards; | 411 std::vector<CreditCard*> credit_cards; |
397 AutofillTable::FromWebDatabase(db)->GetCreditCards(&credit_cards); | 412 AutofillTable::FromWebDatabase(db)->GetCreditCards(&credit_cards); |
398 return scoped_ptr<WDTypedResult>( | 413 return scoped_ptr<WDTypedResult>( |
399 new WDDestroyableResult<std::vector<CreditCard*> >( | 414 new WDDestroyableResult<std::vector<CreditCard*> >( |
400 AUTOFILL_CREDITCARDS_RESULT, | 415 AUTOFILL_CREDITCARDS_RESULT, |
401 credit_cards, | 416 credit_cards, |
402 base::Bind(&AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult, | 417 base::Bind(&AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult, |
403 base::Unretained(this)))); | 418 base::Unretained(this)))); |
404 } | 419 } |
405 | 420 |
421 WebDatabase::State | |
422 AutofillWebDataServiceImpl::RemoveAutofillProfilesAndCreditCardsModifiedBetweenI mpl( | |
423 const base::Time& delete_begin, const base::Time& delete_end, | |
424 WebDatabase* db) { | |
425 std::vector<std::string> profile_guids; | |
426 std::vector<std::string> credit_card_guids; | |
427 if (AutofillTable::FromWebDatabase(db)-> | |
428 RemoveAutofillProfilesAndCreditCardsModifiedBetween( | |
429 delete_begin, | |
430 delete_end, | |
431 &profile_guids, | |
432 &credit_card_guids)) { | |
433 for (std::vector<std::string>::iterator iter = profile_guids.begin(); | |
434 iter != profile_guids.end(); ++iter) { | |
435 AutofillProfileChange change(AutofillProfileChange::REMOVE, *iter, | |
436 NULL); | |
437 content::NotificationService::current()->Notify( | |
438 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
439 content::Source<AutofillWebDataService>(this), | |
440 content::Details<AutofillProfileChange>(&change)); | |
441 } | |
442 // Note: It is the caller's responsibility to post notifications for any | |
443 // changes, e.g. by calling the Refresh() method of PersonalDataManager. | |
444 return WebDatabase::COMMIT_NEEDED; | |
445 } | |
446 return WebDatabase::COMMIT_NOT_NEEDED; | |
447 } | |
448 | |
406 void AutofillWebDataServiceImpl::DestroyAutofillProfileResult( | 449 void AutofillWebDataServiceImpl::DestroyAutofillProfileResult( |
407 const WDTypedResult* result) { | 450 const WDTypedResult* result) { |
408 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); | 451 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); |
409 const WDResult<std::vector<AutofillProfile*> >* r = | 452 const WDResult<std::vector<AutofillProfile*> >* r = |
410 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); | 453 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); |
411 std::vector<AutofillProfile*> profiles = r->GetValue(); | 454 std::vector<AutofillProfile*> profiles = r->GetValue(); |
412 STLDeleteElements(&profiles); | 455 STLDeleteElements(&profiles); |
413 } | 456 } |
414 | 457 |
415 void AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult( | 458 void AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult( |
416 const WDTypedResult* result) { | 459 const WDTypedResult* result) { |
417 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); | 460 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); |
418 const WDResult<std::vector<CreditCard*> >* r = | 461 const WDResult<std::vector<CreditCard*> >* r = |
419 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); | 462 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); |
420 | 463 |
421 std::vector<CreditCard*> credit_cards = r->GetValue(); | 464 std::vector<CreditCard*> credit_cards = r->GetValue(); |
422 STLDeleteElements(&credit_cards); | 465 STLDeleteElements(&credit_cards); |
423 } | 466 } |
OLD | NEW |