| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/webdata/autofill_web_data_service_impl.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/stl_util.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/web_database_service.h" | |
| 13 #include "chrome/common/chrome_notification_types.h" | |
| 14 #include "components/autofill/browser/autofill_country.h" | |
| 15 #include "components/autofill/browser/autofill_profile.h" | |
| 16 #include "components/autofill/browser/credit_card.h" | |
| 17 #include "components/autofill/common/form_field_data.h" | |
| 18 #include "content/public/browser/notification_details.h" | |
| 19 #include "content/public/browser/notification_service.h" | |
| 20 #include "content/public/browser/notification_source.h" | |
| 21 | |
| 22 using base::Bind; | |
| 23 using base::Time; | |
| 24 using content::BrowserThread; | |
| 25 | |
| 26 namespace { | |
| 27 | |
| 28 // A task used by AutofillWebDataService (for Sync mainly) to inform the | |
| 29 // PersonalDataManager living on the UI thread that it needs to refresh. | |
| 30 void NotifyOfMultipleAutofillChangesTask( | |
| 31 const scoped_refptr<AutofillWebDataService>& web_data_service) { | |
| 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 33 | |
| 34 content::NotificationService::current()->Notify( | |
| 35 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED, | |
| 36 content::Source<AutofillWebDataService>(web_data_service.get()), | |
| 37 content::NotificationService::NoDetails()); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 // static | |
| 42 void AutofillWebDataService::NotifyOfMultipleAutofillChanges( | |
| 43 AutofillWebDataService* web_data_service) { | |
| 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 45 | |
| 46 if (!web_data_service) | |
| 47 return; | |
| 48 | |
| 49 BrowserThread::PostTask( | |
| 50 BrowserThread::UI, FROM_HERE, | |
| 51 Bind(&NotifyOfMultipleAutofillChangesTask, | |
| 52 make_scoped_refptr(web_data_service))); | |
| 53 } | |
| 54 | |
| 55 AutofillWebDataService::AutofillWebDataService( | |
| 56 scoped_refptr<WebDatabaseService> wdbs, | |
| 57 const ProfileErrorCallback& callback) | |
| 58 : WebDataServiceBase(wdbs, callback) { | |
| 59 } | |
| 60 | |
| 61 AutofillWebDataService::AutofillWebDataService() | |
| 62 : WebDataServiceBase(NULL, | |
| 63 WebDataServiceBase::ProfileErrorCallback()) { | |
| 64 } | |
| 65 | |
| 66 AutofillWebDataServiceImpl::AutofillWebDataServiceImpl( | |
| 67 scoped_refptr<WebDatabaseService> wdbs, | |
| 68 const ProfileErrorCallback& callback) | |
| 69 : AutofillWebDataService(wdbs, callback) { | |
| 70 } | |
| 71 | |
| 72 content::NotificationSource | |
| 73 AutofillWebDataServiceImpl::GetNotificationSource() { | |
| 74 return content::Source<AutofillWebDataService>(this); | |
| 75 } | |
| 76 | |
| 77 void AutofillWebDataServiceImpl::AddFormFields( | |
| 78 const std::vector<FormFieldData>& fields) { | |
| 79 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 80 Bind(&AutofillWebDataServiceImpl::AddFormElementsImpl, this, fields)); | |
| 81 } | |
| 82 | |
| 83 WebDataServiceBase::Handle | |
| 84 AutofillWebDataServiceImpl::GetFormValuesForElementName( | |
| 85 const string16& name, const string16& prefix, int limit, | |
| 86 WebDataServiceConsumer* consumer) { | |
| 87 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | |
| 88 Bind(&AutofillWebDataServiceImpl::GetFormValuesForElementNameImpl, | |
| 89 this, name, prefix, limit), consumer); | |
| 90 } | |
| 91 | |
| 92 void AutofillWebDataServiceImpl::RemoveExpiredFormElements() { | |
| 93 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 94 Bind(&AutofillWebDataServiceImpl::RemoveExpiredFormElementsImpl, this)); | |
| 95 } | |
| 96 | |
| 97 void AutofillWebDataServiceImpl::RemoveFormValueForElementName( | |
| 98 const string16& name, const string16& value) { | |
| 99 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 100 Bind(&AutofillWebDataServiceImpl::RemoveFormValueForElementNameImpl, | |
| 101 this, name, value)); | |
| 102 } | |
| 103 | |
| 104 void AutofillWebDataServiceImpl::AddAutofillProfile( | |
| 105 const AutofillProfile& profile) { | |
| 106 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 107 Bind(&AutofillWebDataServiceImpl::AddAutofillProfileImpl, this, profile)); | |
| 108 } | |
| 109 | |
| 110 void AutofillWebDataServiceImpl::UpdateAutofillProfile( | |
| 111 const AutofillProfile& profile) { | |
| 112 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 113 Bind(&AutofillWebDataServiceImpl::UpdateAutofillProfileImpl, | |
| 114 this, profile)); | |
| 115 } | |
| 116 | |
| 117 void AutofillWebDataServiceImpl::RemoveAutofillProfile( | |
| 118 const std::string& guid) { | |
| 119 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 120 Bind(&AutofillWebDataServiceImpl::RemoveAutofillProfileImpl, this, guid)); | |
| 121 } | |
| 122 | |
| 123 WebDataServiceBase::Handle AutofillWebDataServiceImpl::GetAutofillProfiles( | |
| 124 WebDataServiceConsumer* consumer) { | |
| 125 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | |
| 126 Bind(&AutofillWebDataServiceImpl::GetAutofillProfilesImpl, this), | |
| 127 consumer); | |
| 128 } | |
| 129 | |
| 130 void AutofillWebDataServiceImpl::AddCreditCard(const CreditCard& credit_card) { | |
| 131 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 132 Bind(&AutofillWebDataServiceImpl::AddCreditCardImpl, this, credit_card)); | |
| 133 } | |
| 134 | |
| 135 void AutofillWebDataServiceImpl::UpdateCreditCard( | |
| 136 const CreditCard& credit_card) { | |
| 137 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 138 Bind(&AutofillWebDataServiceImpl::UpdateCreditCardImpl, this, | |
| 139 credit_card)); | |
| 140 } | |
| 141 | |
| 142 void AutofillWebDataServiceImpl::RemoveCreditCard(const std::string& guid) { | |
| 143 wdbs_->ScheduleDBTask(FROM_HERE, | |
| 144 Bind(&AutofillWebDataServiceImpl::RemoveCreditCardImpl, this, guid)); | |
| 145 } | |
| 146 | |
| 147 AutofillWebDataServiceImpl::Handle AutofillWebDataServiceImpl::GetCreditCards( | |
| 148 WebDataServiceConsumer* consumer) { | |
| 149 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, | |
| 150 Bind(&AutofillWebDataServiceImpl::GetCreditCardsImpl, this), consumer); | |
| 151 } | |
| 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, | |
| 165 this, delete_begin, delete_end)); | |
| 166 } | |
| 167 | |
| 168 AutofillWebDataServiceImpl::~AutofillWebDataServiceImpl() { | |
| 169 } | |
| 170 | |
| 171 //////////////////////////////////////////////////////////////////////////////// | |
| 172 // | |
| 173 // Autofill implementation. | |
| 174 // | |
| 175 //////////////////////////////////////////////////////////////////////////////// | |
| 176 | |
| 177 WebDatabase::State AutofillWebDataServiceImpl::AddFormElementsImpl( | |
| 178 const std::vector<FormFieldData>& fields, WebDatabase* db) { | |
| 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 180 AutofillChangeList changes; | |
| 181 if (!AutofillTable::FromWebDatabase(db)->AddFormFieldValues( | |
| 182 fields, &changes)) { | |
| 183 NOTREACHED(); | |
| 184 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 185 } | |
| 186 | |
| 187 // Post the notifications including the list of affected keys. | |
| 188 // This is sent here so that work resulting from this notification will be | |
| 189 // done on the DB thread, and not the UI thread. | |
| 190 content::NotificationService::current()->Notify( | |
| 191 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
| 192 content::Source<AutofillWebDataService>(this), | |
| 193 content::Details<AutofillChangeList>(&changes)); | |
| 194 | |
| 195 return WebDatabase::COMMIT_NEEDED; | |
| 196 } | |
| 197 | |
| 198 scoped_ptr<WDTypedResult> | |
| 199 AutofillWebDataServiceImpl::GetFormValuesForElementNameImpl( | |
| 200 const string16& name, const string16& prefix, int limit, WebDatabase* db) { | |
| 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 202 std::vector<string16> values; | |
| 203 AutofillTable::FromWebDatabase(db)->GetFormValuesForElementName( | |
| 204 name, prefix, &values, limit); | |
| 205 return scoped_ptr<WDTypedResult>( | |
| 206 new WDResult<std::vector<string16> >(AUTOFILL_VALUE_RESULT, values)); | |
| 207 } | |
| 208 | |
| 209 WebDatabase::State | |
| 210 AutofillWebDataServiceImpl::RemoveFormElementsAddedBetweenImpl( | |
| 211 const base::Time& delete_begin, const base::Time& delete_end, | |
| 212 WebDatabase* db) { | |
| 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 214 AutofillChangeList changes; | |
| 215 | |
| 216 if (AutofillTable::FromWebDatabase(db)->RemoveFormElementsAddedBetween( | |
| 217 delete_begin, delete_end, &changes)) { | |
| 218 if (!changes.empty()) { | |
| 219 // Post the notifications including the list of affected keys. | |
| 220 // This is sent here so that work resulting from this notification | |
| 221 // will be done on the DB thread, and not the UI thread. | |
| 222 content::NotificationService::current()->Notify( | |
| 223 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
| 224 content::Source<AutofillWebDataService>(this), | |
| 225 content::Details<AutofillChangeList>(&changes)); | |
| 226 } | |
| 227 return WebDatabase::COMMIT_NEEDED; | |
| 228 } | |
| 229 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 230 } | |
| 231 | |
| 232 WebDatabase::State | |
| 233 AutofillWebDataServiceImpl::RemoveExpiredFormElementsImpl( | |
| 234 WebDatabase* db) { | |
| 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 236 AutofillChangeList changes; | |
| 237 | |
| 238 if (AutofillTable::FromWebDatabase(db)->RemoveExpiredFormElements(&changes)) { | |
| 239 if (!changes.empty()) { | |
| 240 // Post the notifications including the list of affected keys. | |
| 241 // This is sent here so that work resulting from this notification | |
| 242 // will be done on the DB thread, and not the UI thread. | |
| 243 content::NotificationService::current()->Notify( | |
| 244 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
| 245 content::Source<AutofillWebDataService>(this), | |
| 246 content::Details<AutofillChangeList>(&changes)); | |
| 247 } | |
| 248 return WebDatabase::COMMIT_NEEDED; | |
| 249 } | |
| 250 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 251 } | |
| 252 | |
| 253 WebDatabase::State | |
| 254 AutofillWebDataServiceImpl::RemoveFormValueForElementNameImpl( | |
| 255 const string16& name, const string16& value, WebDatabase* db) { | |
| 256 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 257 | |
| 258 if (AutofillTable::FromWebDatabase(db)->RemoveFormElement(name, value)) { | |
| 259 AutofillChangeList changes; | |
| 260 changes.push_back(AutofillChange(AutofillChange::REMOVE, | |
| 261 AutofillKey(name, value))); | |
| 262 | |
| 263 // Post the notifications including the list of affected keys. | |
| 264 content::NotificationService::current()->Notify( | |
| 265 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | |
| 266 content::Source<AutofillWebDataService>(this), | |
| 267 content::Details<AutofillChangeList>(&changes)); | |
| 268 | |
| 269 return WebDatabase::COMMIT_NEEDED; | |
| 270 } | |
| 271 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 272 } | |
| 273 | |
| 274 WebDatabase::State | |
| 275 AutofillWebDataServiceImpl::AddAutofillProfileImpl( | |
| 276 const AutofillProfile& profile, WebDatabase* db) { | |
| 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 278 if (!AutofillTable::FromWebDatabase(db)->AddAutofillProfile(profile)) { | |
| 279 NOTREACHED(); | |
| 280 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 281 } | |
| 282 | |
| 283 // Send GUID-based notification. | |
| 284 AutofillProfileChange change(AutofillProfileChange::ADD, | |
| 285 profile.guid(), &profile); | |
| 286 content::NotificationService::current()->Notify( | |
| 287 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
| 288 content::Source<AutofillWebDataService>(this), | |
| 289 content::Details<AutofillProfileChange>(&change)); | |
| 290 | |
| 291 return WebDatabase::COMMIT_NEEDED; | |
| 292 } | |
| 293 | |
| 294 WebDatabase::State | |
| 295 AutofillWebDataServiceImpl::UpdateAutofillProfileImpl( | |
| 296 const AutofillProfile& profile, WebDatabase* db) { | |
| 297 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 298 // Only perform the update if the profile exists. It is currently | |
| 299 // valid to try to update a missing profile. We simply drop the write and | |
| 300 // the caller will detect this on the next refresh. | |
| 301 AutofillProfile* original_profile = NULL; | |
| 302 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(profile.guid(), | |
| 303 &original_profile)) { | |
| 304 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 305 } | |
| 306 scoped_ptr<AutofillProfile> scoped_profile(original_profile); | |
| 307 | |
| 308 if (!AutofillTable::FromWebDatabase(db)->UpdateAutofillProfileMulti( | |
| 309 profile)) { | |
| 310 NOTREACHED(); | |
| 311 return WebDatabase::COMMIT_NEEDED; | |
| 312 } | |
| 313 | |
| 314 // Send GUID-based notification. | |
| 315 AutofillProfileChange change(AutofillProfileChange::UPDATE, | |
| 316 profile.guid(), &profile); | |
| 317 content::NotificationService::current()->Notify( | |
| 318 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
| 319 content::Source<AutofillWebDataService>(this), | |
| 320 content::Details<AutofillProfileChange>(&change)); | |
| 321 | |
| 322 return WebDatabase::COMMIT_NEEDED; | |
| 323 } | |
| 324 | |
| 325 WebDatabase::State | |
| 326 AutofillWebDataServiceImpl::RemoveAutofillProfileImpl( | |
| 327 const std::string& guid, WebDatabase* db) { | |
| 328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 329 AutofillProfile* profile = NULL; | |
| 330 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(guid, &profile)) { | |
| 331 NOTREACHED(); | |
| 332 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 333 } | |
| 334 scoped_ptr<AutofillProfile> scoped_profile(profile); | |
| 335 | |
| 336 if (!AutofillTable::FromWebDatabase(db)->RemoveAutofillProfile(guid)) { | |
| 337 NOTREACHED(); | |
| 338 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 339 } | |
| 340 | |
| 341 // Send GUID-based notification. | |
| 342 AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL); | |
| 343 content::NotificationService::current()->Notify( | |
| 344 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | |
| 345 content::Source<AutofillWebDataService>(this), | |
| 346 content::Details<AutofillProfileChange>(&change)); | |
| 347 | |
| 348 return WebDatabase::COMMIT_NEEDED; | |
| 349 } | |
| 350 | |
| 351 scoped_ptr<WDTypedResult> | |
| 352 AutofillWebDataServiceImpl::GetAutofillProfilesImpl( | |
| 353 WebDatabase* db) { | |
| 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 355 std::vector<AutofillProfile*> profiles; | |
| 356 AutofillTable::FromWebDatabase(db)->GetAutofillProfiles(&profiles); | |
| 357 return scoped_ptr<WDTypedResult>( | |
| 358 new WDDestroyableResult<std::vector<AutofillProfile*> >( | |
| 359 AUTOFILL_PROFILES_RESULT, | |
| 360 profiles, | |
| 361 base::Bind(&AutofillWebDataServiceImpl::DestroyAutofillProfileResult, | |
| 362 base::Unretained(this)))); | |
| 363 } | |
| 364 | |
| 365 WebDatabase::State | |
| 366 AutofillWebDataServiceImpl::AddCreditCardImpl( | |
| 367 const CreditCard& credit_card, WebDatabase* db) { | |
| 368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 369 if (!AutofillTable::FromWebDatabase(db)->AddCreditCard(credit_card)) { | |
| 370 NOTREACHED(); | |
| 371 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 372 } | |
| 373 | |
| 374 return WebDatabase::COMMIT_NEEDED; | |
| 375 } | |
| 376 | |
| 377 WebDatabase::State | |
| 378 AutofillWebDataServiceImpl::UpdateCreditCardImpl( | |
| 379 const CreditCard& credit_card, WebDatabase* db) { | |
| 380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 381 // It is currently valid to try to update a missing profile. We simply drop | |
| 382 // the write and the caller will detect this on the next refresh. | |
| 383 CreditCard* original_credit_card = NULL; | |
| 384 if (!AutofillTable::FromWebDatabase(db)->GetCreditCard(credit_card.guid(), | |
| 385 &original_credit_card)) { | |
| 386 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 387 } | |
| 388 scoped_ptr<CreditCard> scoped_credit_card(original_credit_card); | |
| 389 | |
| 390 if (!AutofillTable::FromWebDatabase(db)->UpdateCreditCard(credit_card)) { | |
| 391 NOTREACHED(); | |
| 392 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 393 } | |
| 394 return WebDatabase::COMMIT_NEEDED; | |
| 395 } | |
| 396 | |
| 397 WebDatabase::State | |
| 398 AutofillWebDataServiceImpl::RemoveCreditCardImpl( | |
| 399 const std::string& guid, WebDatabase* db) { | |
| 400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 401 if (!AutofillTable::FromWebDatabase(db)->RemoveCreditCard(guid)) { | |
| 402 NOTREACHED(); | |
| 403 return WebDatabase::COMMIT_NOT_NEEDED; | |
| 404 } | |
| 405 return WebDatabase::COMMIT_NEEDED; | |
| 406 } | |
| 407 | |
| 408 scoped_ptr<WDTypedResult> | |
| 409 AutofillWebDataServiceImpl::GetCreditCardsImpl(WebDatabase* db) { | |
| 410 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
| 411 std::vector<CreditCard*> credit_cards; | |
| 412 AutofillTable::FromWebDatabase(db)->GetCreditCards(&credit_cards); | |
| 413 return scoped_ptr<WDTypedResult>( | |
| 414 new WDDestroyableResult<std::vector<CreditCard*> >( | |
| 415 AUTOFILL_CREDITCARDS_RESULT, | |
| 416 credit_cards, | |
| 417 base::Bind(&AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult, | |
| 418 base::Unretained(this)))); | |
| 419 } | |
| 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 | |
| 449 void AutofillWebDataServiceImpl::DestroyAutofillProfileResult( | |
| 450 const WDTypedResult* result) { | |
| 451 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); | |
| 452 const WDResult<std::vector<AutofillProfile*> >* r = | |
| 453 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); | |
| 454 std::vector<AutofillProfile*> profiles = r->GetValue(); | |
| 455 STLDeleteElements(&profiles); | |
| 456 } | |
| 457 | |
| 458 void AutofillWebDataServiceImpl::DestroyAutofillCreditCardResult( | |
| 459 const WDTypedResult* result) { | |
| 460 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); | |
| 461 const WDResult<std::vector<CreditCard*> >* r = | |
| 462 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); | |
| 463 | |
| 464 std::vector<CreditCard*> credit_cards = r->GetValue(); | |
| 465 STLDeleteElements(&credit_cards); | |
| 466 } | |
| OLD | NEW |