| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 WebDataServiceBase::Handle | 83 WebDataServiceBase::Handle |
| 84 AutofillWebDataServiceImpl::GetFormValuesForElementName( | 84 AutofillWebDataServiceImpl::GetFormValuesForElementName( |
| 85 const string16& name, const string16& prefix, int limit, | 85 const string16& name, const string16& prefix, int limit, |
| 86 WebDataServiceConsumer* consumer) { | 86 WebDataServiceConsumer* consumer) { |
| 87 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 87 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
| 88 Bind(&AutofillWebDataServiceImpl::GetFormValuesForElementNameImpl, | 88 Bind(&AutofillWebDataServiceImpl::GetFormValuesForElementNameImpl, |
| 89 this, name, prefix, limit), consumer); | 89 this, name, prefix, limit), consumer); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void AutofillWebDataServiceImpl::RemoveFormElementsAddedBetween( |
| 93 const Time& delete_begin, const Time& delete_end) { |
| 94 wdbs_->ScheduleDBTask(FROM_HERE, |
| 95 Bind(&AutofillWebDataServiceImpl::RemoveFormElementsAddedBetweenImpl, |
| 96 this, delete_begin, delete_end)); |
| 97 } |
| 98 |
| 92 void AutofillWebDataServiceImpl::RemoveExpiredFormElements() { | 99 void AutofillWebDataServiceImpl::RemoveExpiredFormElements() { |
| 93 wdbs_->ScheduleDBTask(FROM_HERE, | 100 wdbs_->ScheduleDBTask(FROM_HERE, |
| 94 Bind(&AutofillWebDataServiceImpl::RemoveExpiredFormElementsImpl, this)); | 101 Bind(&AutofillWebDataServiceImpl::RemoveExpiredFormElementsImpl, this)); |
| 95 } | 102 } |
| 96 | 103 |
| 97 void AutofillWebDataServiceImpl::RemoveFormValueForElementName( | 104 void AutofillWebDataServiceImpl::RemoveFormValueForElementName( |
| 98 const string16& name, const string16& value) { | 105 const string16& name, const string16& value) { |
| 99 wdbs_->ScheduleDBTask(FROM_HERE, | 106 wdbs_->ScheduleDBTask(FROM_HERE, |
| 100 Bind(&AutofillWebDataServiceImpl::RemoveFormValueForElementNameImpl, | 107 Bind(&AutofillWebDataServiceImpl::RemoveFormValueForElementNameImpl, |
| 101 this, name, value)); | 108 this, name, value)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 wdbs_->ScheduleDBTask(FROM_HERE, | 150 wdbs_->ScheduleDBTask(FROM_HERE, |
| 144 Bind(&AutofillWebDataServiceImpl::RemoveCreditCardImpl, this, guid)); | 151 Bind(&AutofillWebDataServiceImpl::RemoveCreditCardImpl, this, guid)); |
| 145 } | 152 } |
| 146 | 153 |
| 147 AutofillWebDataServiceImpl::Handle AutofillWebDataServiceImpl::GetCreditCards( | 154 AutofillWebDataServiceImpl::Handle AutofillWebDataServiceImpl::GetCreditCards( |
| 148 WebDataServiceConsumer* consumer) { | 155 WebDataServiceConsumer* consumer) { |
| 149 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | 156 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
| 150 Bind(&AutofillWebDataServiceImpl::GetCreditCardsImpl, this), consumer); | 157 Bind(&AutofillWebDataServiceImpl::GetCreditCardsImpl, this), consumer); |
| 151 } | 158 } |
| 152 | 159 |
| 160 void AutofillWebDataServiceImpl::RemoveAutofillDataModifiedBetween( |
| 161 const Time& delete_begin, const Time& delete_end) { |
| 162 wdbs_->ScheduleDBTask(FROM_HERE, Bind( |
| 163 &AutofillWebDataServiceImpl::RemoveAutofillDataModifiedBetweenImpl, |
| 164 this, delete_begin, delete_end)); |
| 165 } |
| 166 |
| 153 AutofillWebDataServiceImpl::~AutofillWebDataServiceImpl() { | 167 AutofillWebDataServiceImpl::~AutofillWebDataServiceImpl() { |
| 154 } | 168 } |
| 155 | 169 |
| 156 //////////////////////////////////////////////////////////////////////////////// | 170 //////////////////////////////////////////////////////////////////////////////// |
| 157 // | 171 // |
| 158 // Autofill implementation. | 172 // Autofill implementation. |
| 159 // | 173 // |
| 160 //////////////////////////////////////////////////////////////////////////////// | 174 //////////////////////////////////////////////////////////////////////////////// |
| 161 | 175 |
| 162 WebDatabase::State AutofillWebDataServiceImpl::AddFormElementsImpl( | 176 WebDatabase::State AutofillWebDataServiceImpl::AddFormElementsImpl( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 content::NotificationService::current()->Notify( | 221 content::NotificationService::current()->Notify( |
| 208 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 222 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
| 209 content::Source<AutofillWebDataService>(this), | 223 content::Source<AutofillWebDataService>(this), |
| 210 content::Details<AutofillChangeList>(&changes)); | 224 content::Details<AutofillChangeList>(&changes)); |
| 211 } | 225 } |
| 212 return WebDatabase::COMMIT_NEEDED; | 226 return WebDatabase::COMMIT_NEEDED; |
| 213 } | 227 } |
| 214 return WebDatabase::COMMIT_NOT_NEEDED; | 228 return WebDatabase::COMMIT_NOT_NEEDED; |
| 215 } | 229 } |
| 216 | 230 |
| 217 WebDatabase::State | 231 WebDatabase::State AutofillWebDataServiceImpl::RemoveExpiredFormElementsImpl( |
| 218 AutofillWebDataServiceImpl::RemoveExpiredFormElementsImpl( | |
| 219 WebDatabase* db) { | 232 WebDatabase* db) { |
| 220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 221 AutofillChangeList changes; | 234 AutofillChangeList changes; |
| 222 | 235 |
| 223 if (AutofillTable::FromWebDatabase(db)->RemoveExpiredFormElements(&changes)) { | 236 if (AutofillTable::FromWebDatabase(db)->RemoveExpiredFormElements(&changes)) { |
| 224 if (!changes.empty()) { | 237 if (!changes.empty()) { |
| 225 // Post the notifications including the list of affected keys. | 238 // Post the notifications including the list of affected keys. |
| 226 // This is sent here so that work resulting from this notification | 239 // This is sent here so that work resulting from this notification |
| 227 // will be done on the DB thread, and not the UI thread. | 240 // will be done on the DB thread, and not the UI thread. |
| 228 content::NotificationService::current()->Notify( | 241 content::NotificationService::current()->Notify( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 249 content::NotificationService::current()->Notify( | 262 content::NotificationService::current()->Notify( |
| 250 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 263 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
| 251 content::Source<AutofillWebDataService>(this), | 264 content::Source<AutofillWebDataService>(this), |
| 252 content::Details<AutofillChangeList>(&changes)); | 265 content::Details<AutofillChangeList>(&changes)); |
| 253 | 266 |
| 254 return WebDatabase::COMMIT_NEEDED; | 267 return WebDatabase::COMMIT_NEEDED; |
| 255 } | 268 } |
| 256 return WebDatabase::COMMIT_NOT_NEEDED; | 269 return WebDatabase::COMMIT_NOT_NEEDED; |
| 257 } | 270 } |
| 258 | 271 |
| 259 WebDatabase::State | 272 WebDatabase::State AutofillWebDataServiceImpl::AddAutofillProfileImpl( |
| 260 AutofillWebDataServiceImpl::AddAutofillProfileImpl( | |
| 261 const AutofillProfile& profile, WebDatabase* db) { | 273 const AutofillProfile& profile, WebDatabase* db) { |
| 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 263 if (!AutofillTable::FromWebDatabase(db)->AddAutofillProfile(profile)) { | 275 if (!AutofillTable::FromWebDatabase(db)->AddAutofillProfile(profile)) { |
| 264 NOTREACHED(); | 276 NOTREACHED(); |
| 265 return WebDatabase::COMMIT_NOT_NEEDED; | 277 return WebDatabase::COMMIT_NOT_NEEDED; |
| 266 } | 278 } |
| 267 | 279 |
| 268 // Send GUID-based notification. | 280 // Send GUID-based notification. |
| 269 AutofillProfileChange change(AutofillProfileChange::ADD, | 281 AutofillProfileChange change(AutofillProfileChange::ADD, |
| 270 profile.guid(), &profile); | 282 profile.guid(), &profile); |
| 271 content::NotificationService::current()->Notify( | 283 content::NotificationService::current()->Notify( |
| 272 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 284 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
| 273 content::Source<AutofillWebDataService>(this), | 285 content::Source<AutofillWebDataService>(this), |
| 274 content::Details<AutofillProfileChange>(&change)); | 286 content::Details<AutofillProfileChange>(&change)); |
| 275 | 287 |
| 276 return WebDatabase::COMMIT_NEEDED; | 288 return WebDatabase::COMMIT_NEEDED; |
| 277 } | 289 } |
| 278 | 290 |
| 279 WebDatabase::State | 291 WebDatabase::State AutofillWebDataServiceImpl::UpdateAutofillProfileImpl( |
| 280 AutofillWebDataServiceImpl::UpdateAutofillProfileImpl( | |
| 281 const AutofillProfile& profile, WebDatabase* db) { | 292 const AutofillProfile& profile, WebDatabase* db) { |
| 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 283 // Only perform the update if the profile exists. It is currently | 294 // Only perform the update if the profile exists. It is currently |
| 284 // valid to try to update a missing profile. We simply drop the write and | 295 // valid to try to update a missing profile. We simply drop the write and |
| 285 // the caller will detect this on the next refresh. | 296 // the caller will detect this on the next refresh. |
| 286 AutofillProfile* original_profile = NULL; | 297 AutofillProfile* original_profile = NULL; |
| 287 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(profile.guid(), | 298 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(profile.guid(), |
| 288 &original_profile)) { | 299 &original_profile)) { |
| 289 return WebDatabase::COMMIT_NOT_NEEDED; | 300 return WebDatabase::COMMIT_NOT_NEEDED; |
| 290 } | 301 } |
| 291 scoped_ptr<AutofillProfile> scoped_profile(original_profile); | 302 scoped_ptr<AutofillProfile> scoped_profile(original_profile); |
| 292 | 303 |
| 293 if (!AutofillTable::FromWebDatabase(db)->UpdateAutofillProfileMulti( | 304 if (!AutofillTable::FromWebDatabase(db)->UpdateAutofillProfileMulti( |
| 294 profile)) { | 305 profile)) { |
| 295 NOTREACHED(); | 306 NOTREACHED(); |
| 296 return WebDatabase::COMMIT_NEEDED; | 307 return WebDatabase::COMMIT_NEEDED; |
| 297 } | 308 } |
| 298 | 309 |
| 299 // Send GUID-based notification. | 310 // Send GUID-based notification. |
| 300 AutofillProfileChange change(AutofillProfileChange::UPDATE, | 311 AutofillProfileChange change(AutofillProfileChange::UPDATE, |
| 301 profile.guid(), &profile); | 312 profile.guid(), &profile); |
| 302 content::NotificationService::current()->Notify( | 313 content::NotificationService::current()->Notify( |
| 303 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 314 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
| 304 content::Source<AutofillWebDataService>(this), | 315 content::Source<AutofillWebDataService>(this), |
| 305 content::Details<AutofillProfileChange>(&change)); | 316 content::Details<AutofillProfileChange>(&change)); |
| 306 | 317 |
| 307 return WebDatabase::COMMIT_NEEDED; | 318 return WebDatabase::COMMIT_NEEDED; |
| 308 } | 319 } |
| 309 | 320 |
| 310 WebDatabase::State | 321 WebDatabase::State AutofillWebDataServiceImpl::RemoveAutofillProfileImpl( |
| 311 AutofillWebDataServiceImpl::RemoveAutofillProfileImpl( | |
| 312 const std::string& guid, WebDatabase* db) { | 322 const std::string& guid, WebDatabase* db) { |
| 313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 314 AutofillProfile* profile = NULL; | 324 AutofillProfile* profile = NULL; |
| 315 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(guid, &profile)) { | 325 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(guid, &profile)) { |
| 316 NOTREACHED(); | 326 NOTREACHED(); |
| 317 return WebDatabase::COMMIT_NOT_NEEDED; | 327 return WebDatabase::COMMIT_NOT_NEEDED; |
| 318 } | 328 } |
| 319 scoped_ptr<AutofillProfile> scoped_profile(profile); | 329 scoped_ptr<AutofillProfile> scoped_profile(profile); |
| 320 | 330 |
| 321 if (!AutofillTable::FromWebDatabase(db)->RemoveAutofillProfile(guid)) { | 331 if (!AutofillTable::FromWebDatabase(db)->RemoveAutofillProfile(guid)) { |
| 322 NOTREACHED(); | 332 NOTREACHED(); |
| 323 return WebDatabase::COMMIT_NOT_NEEDED; | 333 return WebDatabase::COMMIT_NOT_NEEDED; |
| 324 } | 334 } |
| 325 | 335 |
| 326 // Send GUID-based notification. | 336 // Send GUID-based notification. |
| 327 AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL); | 337 AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL); |
| 328 content::NotificationService::current()->Notify( | 338 content::NotificationService::current()->Notify( |
| 329 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 339 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
| 330 content::Source<AutofillWebDataService>(this), | 340 content::Source<AutofillWebDataService>(this), |
| 331 content::Details<AutofillProfileChange>(&change)); | 341 content::Details<AutofillProfileChange>(&change)); |
| 332 | 342 |
| 333 return WebDatabase::COMMIT_NEEDED; | 343 return WebDatabase::COMMIT_NEEDED; |
| 334 } | 344 } |
| 335 | 345 |
| 336 scoped_ptr<WDTypedResult> | 346 scoped_ptr<WDTypedResult> AutofillWebDataServiceImpl::GetAutofillProfilesImpl( |
| 337 AutofillWebDataServiceImpl::GetAutofillProfilesImpl( | |
| 338 WebDatabase* db) { | 347 WebDatabase* db) { |
| 339 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 348 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 340 std::vector<AutofillProfile*> profiles; | 349 std::vector<AutofillProfile*> profiles; |
| 341 AutofillTable::FromWebDatabase(db)->GetAutofillProfiles(&profiles); | 350 AutofillTable::FromWebDatabase(db)->GetAutofillProfiles(&profiles); |
| 342 return scoped_ptr<WDTypedResult>( | 351 return scoped_ptr<WDTypedResult>( |
| 343 new WDDestroyableResult<std::vector<AutofillProfile*> >( | 352 new WDDestroyableResult<std::vector<AutofillProfile*> >( |
| 344 AUTOFILL_PROFILES_RESULT, | 353 AUTOFILL_PROFILES_RESULT, |
| 345 profiles, | 354 profiles, |
| 346 base::Bind(&AutofillWebDataServiceImpl::DestroyAutofillProfileResult, | 355 base::Bind(&AutofillWebDataServiceImpl::DestroyAutofillProfileResult, |
| 347 base::Unretained(this)))); | 356 base::Unretained(this)))); |
| 348 } | 357 } |
| 349 | 358 |
| 350 WebDatabase::State | 359 WebDatabase::State AutofillWebDataServiceImpl::AddCreditCardImpl( |
| 351 AutofillWebDataServiceImpl::AddCreditCardImpl( | |
| 352 const CreditCard& credit_card, WebDatabase* db) { | 360 const CreditCard& credit_card, WebDatabase* db) { |
| 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 361 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 354 if (!AutofillTable::FromWebDatabase(db)->AddCreditCard(credit_card)) { | 362 if (!AutofillTable::FromWebDatabase(db)->AddCreditCard(credit_card)) { |
| 355 NOTREACHED(); | 363 NOTREACHED(); |
| 356 return WebDatabase::COMMIT_NOT_NEEDED; | 364 return WebDatabase::COMMIT_NOT_NEEDED; |
| 357 } | 365 } |
| 358 | 366 |
| 359 return WebDatabase::COMMIT_NEEDED; | 367 return WebDatabase::COMMIT_NEEDED; |
| 360 } | 368 } |
| 361 | 369 |
| 362 WebDatabase::State | 370 WebDatabase::State AutofillWebDataServiceImpl::UpdateCreditCardImpl( |
| 363 AutofillWebDataServiceImpl::UpdateCreditCardImpl( | |
| 364 const CreditCard& credit_card, WebDatabase* db) { | 371 const CreditCard& credit_card, WebDatabase* db) { |
| 365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 372 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 366 // It is currently valid to try to update a missing profile. We simply drop | 373 // It is currently valid to try to update a missing profile. We simply drop |
| 367 // the write and the caller will detect this on the next refresh. | 374 // the write and the caller will detect this on the next refresh. |
| 368 CreditCard* original_credit_card = NULL; | 375 CreditCard* original_credit_card = NULL; |
| 369 if (!AutofillTable::FromWebDatabase(db)->GetCreditCard(credit_card.guid(), | 376 if (!AutofillTable::FromWebDatabase(db)->GetCreditCard(credit_card.guid(), |
| 370 &original_credit_card)) { | 377 &original_credit_card)) { |
| 371 return WebDatabase::COMMIT_NOT_NEEDED; | 378 return WebDatabase::COMMIT_NOT_NEEDED; |
| 372 } | 379 } |
| 373 scoped_ptr<CreditCard> scoped_credit_card(original_credit_card); | 380 scoped_ptr<CreditCard> scoped_credit_card(original_credit_card); |
| 374 | 381 |
| 375 if (!AutofillTable::FromWebDatabase(db)->UpdateCreditCard(credit_card)) { | 382 if (!AutofillTable::FromWebDatabase(db)->UpdateCreditCard(credit_card)) { |
| 376 NOTREACHED(); | 383 NOTREACHED(); |
| 377 return WebDatabase::COMMIT_NOT_NEEDED; | 384 return WebDatabase::COMMIT_NOT_NEEDED; |
| 378 } | 385 } |
| 379 return WebDatabase::COMMIT_NEEDED; | 386 return WebDatabase::COMMIT_NEEDED; |
| 380 } | 387 } |
| 381 | 388 |
| 382 WebDatabase::State | 389 WebDatabase::State AutofillWebDataServiceImpl::RemoveCreditCardImpl( |
| 383 AutofillWebDataServiceImpl::RemoveCreditCardImpl( | |
| 384 const std::string& guid, WebDatabase* db) { | 390 const std::string& guid, WebDatabase* db) { |
| 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 386 if (!AutofillTable::FromWebDatabase(db)->RemoveCreditCard(guid)) { | 392 if (!AutofillTable::FromWebDatabase(db)->RemoveCreditCard(guid)) { |
| 387 NOTREACHED(); | 393 NOTREACHED(); |
| 388 return WebDatabase::COMMIT_NOT_NEEDED; | 394 return WebDatabase::COMMIT_NOT_NEEDED; |
| 389 } | 395 } |
| 390 return WebDatabase::COMMIT_NEEDED; | 396 return WebDatabase::COMMIT_NEEDED; |
| 391 } | 397 } |
| 392 | 398 |
| 393 scoped_ptr<WDTypedResult> | 399 scoped_ptr<WDTypedResult> AutofillWebDataServiceImpl::GetCreditCardsImpl( |
| 394 AutofillWebDataServiceImpl::GetCreditCardsImpl(WebDatabase* db) { | 400 WebDatabase* db) { |
| 395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 401 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 396 std::vector<CreditCard*> credit_cards; | 402 std::vector<CreditCard*> credit_cards; |
| 397 AutofillTable::FromWebDatabase(db)->GetCreditCards(&credit_cards); | 403 AutofillTable::FromWebDatabase(db)->GetCreditCards(&credit_cards); |
| 398 return scoped_ptr<WDTypedResult>( | 404 return scoped_ptr<WDTypedResult>( |
| 399 new WDDestroyableResult<std::vector<CreditCard*> >( | 405 new WDDestroyableResult<std::vector<CreditCard*> >( |
| 400 AUTOFILL_CREDITCARDS_RESULT, | 406 AUTOFILL_CREDITCARDS_RESULT, |
| 401 credit_cards, | 407 credit_cards, |
| 402 base::Bind(&AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult, | 408 base::Bind(&AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult, |
| 403 base::Unretained(this)))); | 409 base::Unretained(this)))); |
| 404 } | 410 } |
| 405 | 411 |
| 412 WebDatabase::State |
| 413 AutofillWebDataServiceImpl::RemoveAutofillDataModifiedBetweenImpl( |
| 414 const base::Time& delete_begin, const base::Time& delete_end, |
| 415 WebDatabase* db) { |
| 416 std::vector<std::string> profile_guids; |
| 417 std::vector<std::string> credit_card_guids; |
| 418 if (AutofillTable::FromWebDatabase(db)-> |
| 419 RemoveAutofillDataModifiedBetween( |
| 420 delete_begin, |
| 421 delete_end, |
| 422 &profile_guids, |
| 423 &credit_card_guids)) { |
| 424 for (std::vector<std::string>::iterator iter = profile_guids.begin(); |
| 425 iter != profile_guids.end(); ++iter) { |
| 426 AutofillProfileChange change(AutofillProfileChange::REMOVE, *iter, |
| 427 NULL); |
| 428 content::NotificationService::current()->Notify( |
| 429 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
| 430 content::Source<AutofillWebDataService>(this), |
| 431 content::Details<AutofillProfileChange>(&change)); |
| 432 } |
| 433 // Note: It is the caller's responsibility to post notifications for any |
| 434 // changes, e.g. by calling the Refresh() method of PersonalDataManager. |
| 435 return WebDatabase::COMMIT_NEEDED; |
| 436 } |
| 437 return WebDatabase::COMMIT_NOT_NEEDED; |
| 438 } |
| 439 |
| 406 void AutofillWebDataServiceImpl::DestroyAutofillProfileResult( | 440 void AutofillWebDataServiceImpl::DestroyAutofillProfileResult( |
| 407 const WDTypedResult* result) { | 441 const WDTypedResult* result) { |
| 408 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); | 442 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); |
| 409 const WDResult<std::vector<AutofillProfile*> >* r = | 443 const WDResult<std::vector<AutofillProfile*> >* r = |
| 410 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); | 444 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); |
| 411 std::vector<AutofillProfile*> profiles = r->GetValue(); | 445 std::vector<AutofillProfile*> profiles = r->GetValue(); |
| 412 STLDeleteElements(&profiles); | 446 STLDeleteElements(&profiles); |
| 413 } | 447 } |
| 414 | 448 |
| 415 void AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult( | 449 void AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult( |
| 416 const WDTypedResult* result) { | 450 const WDTypedResult* result) { |
| 417 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); | 451 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); |
| 418 const WDResult<std::vector<CreditCard*> >* r = | 452 const WDResult<std::vector<CreditCard*> >* r = |
| 419 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); | 453 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); |
| 420 | 454 |
| 421 std::vector<CreditCard*> credit_cards = r->GetValue(); | 455 std::vector<CreditCard*> credit_cards = r->GetValue(); |
| 422 STLDeleteElements(&credit_cards); | 456 STLDeleteElements(&credit_cards); |
| 423 } | 457 } |
| OLD | NEW |