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/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "chrome/browser/search_engines/template_url.h" | 8 #include "chrome/browser/search_engines/template_url.h" |
9 #include "chrome/browser/webdata/autofill_change.h" | |
10 #include "chrome/browser/webdata/autofill_entry.h" | |
11 #include "chrome/browser/webdata/autofill_table.h" | |
12 #include "chrome/browser/webdata/keyword_table.h" | 9 #include "chrome/browser/webdata/keyword_table.h" |
13 #include "chrome/browser/webdata/logins_table.h" | 10 #include "chrome/browser/webdata/logins_table.h" |
14 #include "chrome/browser/webdata/token_service_table.h" | 11 #include "chrome/browser/webdata/token_service_table.h" |
15 #include "chrome/browser/webdata/web_apps_table.h" | 12 #include "chrome/browser/webdata/web_apps_table.h" |
16 #include "chrome/browser/webdata/web_database_service.h" | 13 #include "chrome/browser/webdata/web_database_service.h" |
17 #include "chrome/browser/webdata/web_intents_table.h" | 14 #include "chrome/browser/webdata/web_intents_table.h" |
18 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
19 #include "components/autofill/browser/autofill_country.h" | |
20 #include "components/autofill/browser/autofill_profile.h" | |
21 #include "components/autofill/browser/credit_card.h" | |
22 #include "components/autofill/common/form_field_data.h" | |
23 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
26 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
27 | 20 |
28 //////////////////////////////////////////////////////////////////////////////// | 21 //////////////////////////////////////////////////////////////////////////////// |
29 // | 22 // |
30 // WebDataService implementation. | 23 // WebDataService implementation. |
31 // | 24 // |
32 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
33 | 26 |
34 using base::Bind; | 27 using base::Bind; |
35 using base::Time; | 28 using base::Time; |
36 using content::BrowserThread; | 29 using content::BrowserThread; |
37 | 30 |
38 namespace { | |
39 | |
40 // A task used by WebDataService (for Sync mainly) to inform the | |
41 // PersonalDataManager living on the UI thread that it needs to refresh. | |
42 void NotifyOfMultipleAutofillChangesTask( | |
43 const scoped_refptr<WebDataService>& web_data_service) { | |
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
45 | |
46 content::NotificationService::current()->Notify( | |
47 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED, | |
48 content::Source<WebDataServiceBase>(web_data_service.get()), | |
49 content::NotificationService::NoDetails()); | |
50 } | |
51 | |
52 } // namespace | |
53 | |
54 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {} | 31 WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {} |
55 | 32 |
56 WDAppImagesResult::~WDAppImagesResult() {} | 33 WDAppImagesResult::~WDAppImagesResult() {} |
57 | 34 |
58 WDKeywordsResult::WDKeywordsResult() | 35 WDKeywordsResult::WDKeywordsResult() |
59 : default_search_provider_id(0), | 36 : default_search_provider_id(0), |
60 builtin_keyword_version(0) { | 37 builtin_keyword_version(0) { |
61 } | 38 } |
62 | 39 |
63 WDKeywordsResult::~WDKeywordsResult() {} | 40 WDKeywordsResult::~WDKeywordsResult() {} |
64 | 41 |
65 WebDataService::WebDataService(scoped_refptr<WebDatabaseService> wdbs, | 42 WebDataService::WebDataService(scoped_refptr<WebDatabaseService> wdbs, |
66 const ProfileErrorCallback& callback) | 43 const ProfileErrorCallback& callback) |
67 : WebDataServiceBase(wdbs, callback) { | 44 : WebDataServiceBase(wdbs, callback) { |
68 } | 45 } |
69 | 46 |
70 // static | |
71 void WebDataService::NotifyOfMultipleAutofillChanges( | |
72 WebDataService* web_data_service) { | |
73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
74 | |
75 if (!web_data_service) | |
76 return; | |
77 | |
78 BrowserThread::PostTask( | |
79 BrowserThread::UI, FROM_HERE, | |
80 Bind(&NotifyOfMultipleAutofillChangesTask, | |
81 make_scoped_refptr(web_data_service))); | |
82 } | |
83 | |
84 ////////////////////////////////////////////////////////////////////////////// | 47 ////////////////////////////////////////////////////////////////////////////// |
85 // | 48 // |
86 // Keywords. | 49 // Keywords. |
87 // | 50 // |
88 ////////////////////////////////////////////////////////////////////////////// | 51 ////////////////////////////////////////////////////////////////////////////// |
89 | 52 |
90 void WebDataService::AddKeyword(const TemplateURLData& data) { | 53 void WebDataService::AddKeyword(const TemplateURLData& data) { |
91 wdbs_->ScheduleDBTask( | 54 wdbs_->ScheduleDBTask( |
92 FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, data)); | 55 FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, data)); |
93 } | 56 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 130 } |
168 | 131 |
169 // Null on failure. Success is WDResult<std::string> | 132 // Null on failure. Success is WDResult<std::string> |
170 WebDataServiceBase::Handle WebDataService::GetAllTokens( | 133 WebDataServiceBase::Handle WebDataService::GetAllTokens( |
171 WebDataServiceConsumer* consumer) { | 134 WebDataServiceConsumer* consumer) { |
172 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 135 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
173 Bind(&WebDataService::GetAllTokensImpl, this), consumer); | 136 Bind(&WebDataService::GetAllTokensImpl, this), consumer); |
174 } | 137 } |
175 | 138 |
176 //////////////////////////////////////////////////////////////////////////////// | 139 //////////////////////////////////////////////////////////////////////////////// |
177 // | |
178 // Autofill. | |
179 // | |
180 //////////////////////////////////////////////////////////////////////////////// | |
181 | |
182 void WebDataService::AddFormFields( | |
183 const std::vector<FormFieldData>& fields) { | |
184 wdbs_->ScheduleDBTask(FROM_HERE, | |
185 Bind(&WebDataService::AddFormElementsImpl, this, fields)); | |
186 } | |
187 | |
188 WebDataServiceBase::Handle WebDataService::GetFormValuesForElementName( | |
189 const string16& name, const string16& prefix, int limit, | |
190 WebDataServiceConsumer* consumer) { | |
191 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | |
192 Bind(&WebDataService::GetFormValuesForElementNameImpl, | |
193 this, name, prefix, limit), consumer); | |
194 } | |
195 | |
196 void WebDataService::RemoveFormElementsAddedBetween(const Time& delete_begin, | |
197 const Time& delete_end) { | |
198 wdbs_->ScheduleDBTask(FROM_HERE, | |
199 Bind(&WebDataService::RemoveFormElementsAddedBetweenImpl, | |
200 this, delete_begin, delete_end)); | |
201 } | |
202 | |
203 void WebDataService::RemoveExpiredFormElements() { | |
204 wdbs_->ScheduleDBTask(FROM_HERE, | |
205 Bind(&WebDataService::RemoveExpiredFormElementsImpl, this)); | |
206 } | |
207 | |
208 void WebDataService::RemoveFormValueForElementName( | |
209 const string16& name, const string16& value) { | |
210 wdbs_->ScheduleDBTask(FROM_HERE, | |
211 Bind(&WebDataService::RemoveFormValueForElementNameImpl, | |
212 this, name, value)); | |
213 } | |
214 | |
215 void WebDataService::AddAutofillProfile(const AutofillProfile& profile) { | |
216 wdbs_->ScheduleDBTask(FROM_HERE, | |
217 Bind(&WebDataService::AddAutofillProfileImpl, this, profile)); | |
218 } | |
219 | |
220 void WebDataService::UpdateAutofillProfile(const AutofillProfile& profile) { | |
221 wdbs_->ScheduleDBTask(FROM_HERE, | |
222 Bind(&WebDataService::UpdateAutofillProfileImpl, this, profile)); | |
223 } | |
224 | |
225 void WebDataService::RemoveAutofillProfile(const std::string& guid) { | |
226 wdbs_->ScheduleDBTask(FROM_HERE, | |
227 Bind(&WebDataService::RemoveAutofillProfileImpl, this, guid)); | |
228 } | |
229 | |
230 WebDataServiceBase::Handle WebDataService::GetAutofillProfiles( | |
231 WebDataServiceConsumer* consumer) { | |
232 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | |
233 Bind(&WebDataService::GetAutofillProfilesImpl, this), consumer); | |
234 } | |
235 | |
236 void WebDataService::AddCreditCard(const CreditCard& credit_card) { | |
237 wdbs_->ScheduleDBTask(FROM_HERE, | |
238 Bind(&WebDataService::AddCreditCardImpl, this, credit_card)); | |
239 } | |
240 | |
241 void WebDataService::UpdateCreditCard(const CreditCard& credit_card) { | |
242 wdbs_->ScheduleDBTask(FROM_HERE, | |
243 Bind(&WebDataService::UpdateCreditCardImpl, this, credit_card)); | |
244 } | |
245 | |
246 void WebDataService::RemoveCreditCard(const std::string& guid) { | |
247 wdbs_->ScheduleDBTask(FROM_HERE, | |
248 Bind(&WebDataService::RemoveCreditCardImpl, this, guid)); | |
249 } | |
250 | |
251 WebDataServiceBase::Handle WebDataService::GetCreditCards( | |
252 WebDataServiceConsumer* consumer) { | |
253 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | |
254 Bind(&WebDataService::GetCreditCardsImpl, this), consumer); | |
255 } | |
256 | |
257 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween( | |
258 const Time& delete_begin, | |
259 const Time& delete_end) { | |
260 wdbs_->ScheduleDBTask(FROM_HERE, Bind( | |
261 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl, | |
262 this, delete_begin, delete_end)); | |
263 } | |
264 | 140 |
265 WebDataService::WebDataService() | 141 WebDataService::WebDataService() |
266 : WebDataServiceBase(NULL, ProfileErrorCallback()) { | 142 : WebDataServiceBase(NULL, ProfileErrorCallback()) { |
267 } | 143 } |
268 | 144 |
269 WebDataService::~WebDataService() { | 145 WebDataService::~WebDataService() { |
270 } | 146 } |
271 | 147 |
272 //////////////////////////////////////////////////////////////////////////////// | 148 //////////////////////////////////////////////////////////////////////////////// |
273 // | 149 // |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 258 } |
383 return WebDatabase::COMMIT_NOT_NEEDED; | 259 return WebDatabase::COMMIT_NOT_NEEDED; |
384 } | 260 } |
385 | 261 |
386 scoped_ptr<WDTypedResult> WebDataService::GetAllTokensImpl(WebDatabase* db) { | 262 scoped_ptr<WDTypedResult> WebDataService::GetAllTokensImpl(WebDatabase* db) { |
387 std::map<std::string, std::string> map; | 263 std::map<std::string, std::string> map; |
388 TokenServiceTable::FromWebDatabase(db)->GetAllTokens(&map); | 264 TokenServiceTable::FromWebDatabase(db)->GetAllTokens(&map); |
389 return scoped_ptr<WDTypedResult>( | 265 return scoped_ptr<WDTypedResult>( |
390 new WDResult<std::map<std::string, std::string> >(TOKEN_RESULT, map)); | 266 new WDResult<std::map<std::string, std::string> >(TOKEN_RESULT, map)); |
391 } | 267 } |
392 | |
393 //////////////////////////////////////////////////////////////////////////////// | |
394 // | |
395 // Autofill implementation. | |
396 // | |
397 //////////////////////////////////////////////////////////////////////////////// | |
398 | |
399 WebDatabase::State WebDataService::AddFormElementsImpl( | |
400 const std::vector<FormFieldData>& fields, WebDatabase* db) { | |
401 AutofillChangeList changes; | |
402 if (!AutofillTable::FromWebDatabase(db)->AddFormFieldValues( | |
403 fields, &changes)) { | |
404 NOTREACHED(); | |
405 return WebDatabase::COMMIT_NOT_NEEDED; | |
406 } | |
407 | |
408 // Post the notifications including the list of affected keys. | |
409 // This is sent here so that work resulting from this notification will be | |
410 // done on the DB thread, and not the UI thread. | |
411 content::NotificationService::current()->Notify( | |
412 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
413 content::Source<WebDataService>(this), | |
414 content::Details<AutofillChangeList>(&changes)); | |
415 | |
416 return WebDatabase::COMMIT_NEEDED; | |
417 } | |
418 | |
419 scoped_ptr<WDTypedResult> WebDataService::GetFormValuesForElementNameImpl( | |
420 const string16& name, const string16& prefix, int limit, WebDatabase* db) { | |
421 std::vector<string16> values; | |
422 AutofillTable::FromWebDatabase(db)->GetFormValuesForElementName( | |
423 name, prefix, &values, limit); | |
424 return scoped_ptr<WDTypedResult>( | |
425 new WDResult<std::vector<string16> >(AUTOFILL_VALUE_RESULT, values)); | |
426 } | |
427 | |
428 WebDatabase::State WebDataService::RemoveFormElementsAddedBetweenImpl( | |
429 const base::Time& delete_begin, const base::Time& delete_end, | |
430 WebDatabase* db) { | |
431 AutofillChangeList changes; | |
432 | |
433 if (AutofillTable::FromWebDatabase(db)->RemoveFormElementsAddedBetween( | |
434 delete_begin, delete_end, &changes)) { | |
435 if (!changes.empty()) { | |
436 // Post the notifications including the list of affected keys. | |
437 // This is sent here so that work resulting from this notification | |
438 // will be done on the DB thread, and not the UI thread. | |
439 content::NotificationService::current()->Notify( | |
440 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
441 content::Source<WebDataService>(this), | |
442 content::Details<AutofillChangeList>(&changes)); | |
443 } | |
444 return WebDatabase::COMMIT_NEEDED; | |
445 } | |
446 return WebDatabase::COMMIT_NOT_NEEDED; | |
447 } | |
448 | |
449 WebDatabase::State WebDataService::RemoveExpiredFormElementsImpl( | |
450 WebDatabase* db) { | |
451 AutofillChangeList changes; | |
452 | |
453 if (AutofillTable::FromWebDatabase(db)->RemoveExpiredFormElements(&changes)) { | |
454 if (!changes.empty()) { | |
455 // Post the notifications including the list of affected keys. | |
456 // This is sent here so that work resulting from this notification | |
457 // will be done on the DB thread, and not the UI thread. | |
458 content::NotificationService::current()->Notify( | |
459 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
460 content::Source<WebDataService>(this), | |
461 content::Details<AutofillChangeList>(&changes)); | |
462 } | |
463 return WebDatabase::COMMIT_NEEDED; | |
464 } | |
465 return WebDatabase::COMMIT_NOT_NEEDED; | |
466 } | |
467 | |
468 WebDatabase::State WebDataService::RemoveFormValueForElementNameImpl( | |
469 const string16& name, const string16& value, WebDatabase* db) { | |
470 | |
471 if (AutofillTable::FromWebDatabase(db)->RemoveFormElement(name, value)) { | |
472 AutofillChangeList changes; | |
473 changes.push_back(AutofillChange(AutofillChange::REMOVE, | |
474 AutofillKey(name, value))); | |
475 | |
476 // Post the notifications including the list of affected keys. | |
477 content::NotificationService::current()->Notify( | |
478 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
479 content::Source<WebDataService>(this), | |
480 content::Details<AutofillChangeList>(&changes)); | |
481 | |
482 return WebDatabase::COMMIT_NEEDED; | |
483 } | |
484 return WebDatabase::COMMIT_NOT_NEEDED; | |
485 } | |
486 | |
487 WebDatabase::State WebDataService::AddAutofillProfileImpl( | |
488 const AutofillProfile& profile, WebDatabase* db) { | |
489 if (!AutofillTable::FromWebDatabase(db)->AddAutofillProfile(profile)) { | |
490 NOTREACHED(); | |
491 return WebDatabase::COMMIT_NOT_NEEDED; | |
492 } | |
493 | |
494 // Send GUID-based notification. | |
495 AutofillProfileChange change(AutofillProfileChange::ADD, | |
496 profile.guid(), &profile); | |
497 content::NotificationService::current()->Notify( | |
498 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
499 content::Source<WebDataService>(this), | |
500 content::Details<AutofillProfileChange>(&change)); | |
501 | |
502 return WebDatabase::COMMIT_NEEDED; | |
503 } | |
504 | |
505 WebDatabase::State WebDataService::UpdateAutofillProfileImpl( | |
506 const AutofillProfile& profile, WebDatabase* db) { | |
507 // Only perform the update if the profile exists. It is currently | |
508 // valid to try to update a missing profile. We simply drop the write and | |
509 // the caller will detect this on the next refresh. | |
510 AutofillProfile* original_profile = NULL; | |
511 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(profile.guid(), | |
512 &original_profile)) { | |
513 return WebDatabase::COMMIT_NOT_NEEDED; | |
514 } | |
515 scoped_ptr<AutofillProfile> scoped_profile(original_profile); | |
516 | |
517 if (!AutofillTable::FromWebDatabase(db)->UpdateAutofillProfileMulti( | |
518 profile)) { | |
519 NOTREACHED(); | |
520 return WebDatabase::COMMIT_NEEDED; | |
521 } | |
522 | |
523 // Send GUID-based notification. | |
524 AutofillProfileChange change(AutofillProfileChange::UPDATE, | |
525 profile.guid(), &profile); | |
526 content::NotificationService::current()->Notify( | |
527 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
528 content::Source<WebDataService>(this), | |
529 content::Details<AutofillProfileChange>(&change)); | |
530 | |
531 return WebDatabase::COMMIT_NEEDED; | |
532 } | |
533 | |
534 WebDatabase::State WebDataService::RemoveAutofillProfileImpl( | |
535 const std::string& guid, WebDatabase* db) { | |
536 AutofillProfile* profile = NULL; | |
537 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(guid, &profile)) { | |
538 NOTREACHED(); | |
539 return WebDatabase::COMMIT_NOT_NEEDED; | |
540 } | |
541 scoped_ptr<AutofillProfile> scoped_profile(profile); | |
542 | |
543 if (!AutofillTable::FromWebDatabase(db)->RemoveAutofillProfile(guid)) { | |
544 NOTREACHED(); | |
545 return WebDatabase::COMMIT_NOT_NEEDED; | |
546 } | |
547 | |
548 // Send GUID-based notification. | |
549 AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL); | |
550 content::NotificationService::current()->Notify( | |
551 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
552 content::Source<WebDataService>(this), | |
553 content::Details<AutofillProfileChange>(&change)); | |
554 | |
555 return WebDatabase::COMMIT_NEEDED; | |
556 } | |
557 | |
558 scoped_ptr<WDTypedResult> WebDataService::GetAutofillProfilesImpl( | |
559 WebDatabase* db) { | |
560 std::vector<AutofillProfile*> profiles; | |
561 AutofillTable::FromWebDatabase(db)->GetAutofillProfiles(&profiles); | |
562 return scoped_ptr<WDTypedResult>( | |
563 new WDDestroyableResult<std::vector<AutofillProfile*> >( | |
564 AUTOFILL_PROFILES_RESULT, | |
565 profiles, | |
566 base::Bind(&WebDataService::DestroyAutofillProfileResult, | |
567 base::Unretained(this)))); | |
568 } | |
569 | |
570 WebDatabase::State WebDataService::AddCreditCardImpl( | |
571 const CreditCard& credit_card, WebDatabase* db) { | |
572 if (!AutofillTable::FromWebDatabase(db)->AddCreditCard(credit_card)) { | |
573 NOTREACHED(); | |
574 return WebDatabase::COMMIT_NOT_NEEDED; | |
575 } | |
576 | |
577 return WebDatabase::COMMIT_NEEDED; | |
578 } | |
579 | |
580 WebDatabase::State WebDataService::UpdateCreditCardImpl( | |
581 const CreditCard& credit_card, WebDatabase* db) { | |
582 // It is currently valid to try to update a missing profile. We simply drop | |
583 // the write and the caller will detect this on the next refresh. | |
584 CreditCard* original_credit_card = NULL; | |
585 if (!AutofillTable::FromWebDatabase(db)->GetCreditCard(credit_card.guid(), | |
586 &original_credit_card)) { | |
587 return WebDatabase::COMMIT_NOT_NEEDED; | |
588 } | |
589 scoped_ptr<CreditCard> scoped_credit_card(original_credit_card); | |
590 | |
591 if (!AutofillTable::FromWebDatabase(db)->UpdateCreditCard(credit_card)) { | |
592 NOTREACHED(); | |
593 return WebDatabase::COMMIT_NOT_NEEDED; | |
594 } | |
595 return WebDatabase::COMMIT_NEEDED; | |
596 } | |
597 | |
598 WebDatabase::State WebDataService::RemoveCreditCardImpl( | |
599 const std::string& guid, WebDatabase* db) { | |
600 if (!AutofillTable::FromWebDatabase(db)->RemoveCreditCard(guid)) { | |
601 NOTREACHED(); | |
602 return WebDatabase::COMMIT_NOT_NEEDED; | |
603 } | |
604 return WebDatabase::COMMIT_NEEDED; | |
605 } | |
606 | |
607 scoped_ptr<WDTypedResult> WebDataService::GetCreditCardsImpl(WebDatabase* db) { | |
608 std::vector<CreditCard*> credit_cards; | |
609 AutofillTable::FromWebDatabase(db)->GetCreditCards(&credit_cards); | |
610 return scoped_ptr<WDTypedResult>( | |
611 new WDDestroyableResult<std::vector<CreditCard*> >( | |
612 AUTOFILL_CREDITCARDS_RESULT, | |
613 credit_cards, | |
614 base::Bind(&WebDataService::DestroyAutofillCreditCardResult, | |
615 base::Unretained(this)))); | |
616 } | |
617 | |
618 WebDatabase::State | |
619 WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( | |
620 const base::Time& delete_begin, const base::Time& delete_end, | |
621 WebDatabase* db) { | |
622 std::vector<std::string> profile_guids; | |
623 std::vector<std::string> credit_card_guids; | |
624 if (AutofillTable::FromWebDatabase(db)-> | |
625 RemoveAutofillProfilesAndCreditCardsModifiedBetween( | |
626 delete_begin, | |
627 delete_end, | |
628 &profile_guids, | |
629 &credit_card_guids)) { | |
630 for (std::vector<std::string>::iterator iter = profile_guids.begin(); | |
631 iter != profile_guids.end(); ++iter) { | |
632 AutofillProfileChange change(AutofillProfileChange::REMOVE, *iter, | |
633 NULL); | |
634 content::NotificationService::current()->Notify( | |
635 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
636 content::Source<WebDataService>(this), | |
637 content::Details<AutofillProfileChange>(&change)); | |
638 } | |
639 // Note: It is the caller's responsibility to post notifications for any | |
640 // changes, e.g. by calling the Refresh() method of PersonalDataManager. | |
641 return WebDatabase::COMMIT_NEEDED; | |
642 } | |
643 return WebDatabase::COMMIT_NOT_NEEDED; | |
644 } | |
645 | |
646 void WebDataService::DestroyAutofillProfileResult(const WDTypedResult* result) { | |
647 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); | |
648 const WDResult<std::vector<AutofillProfile*> >* r = | |
649 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); | |
650 std::vector<AutofillProfile*> profiles = r->GetValue(); | |
651 STLDeleteElements(&profiles); | |
652 } | |
653 | |
654 void WebDataService::DestroyAutofillCreditCardResult( | |
655 const WDTypedResult* result) { | |
656 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); | |
657 const WDResult<std::vector<CreditCard*> >* r = | |
658 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); | |
659 | |
660 std::vector<CreditCard*> credit_cards = r->GetValue(); | |
661 STLDeleteElements(&credit_cards); | |
662 } | |
OLD | NEW |