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/bind.h" | |
8 #include "base/command_line.h" | |
9 #include "base/message_loop.h" | |
10 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
11 #include "base/threading/thread.h" | |
12 #include "chrome/browser/profiles/profile.h" | |
13 #include "chrome/browser/profiles/profile_manager.h" | |
14 #include "chrome/browser/search_engines/template_url.h" | 8 #include "chrome/browser/search_engines/template_url.h" |
15 #include "chrome/browser/ui/profile_error_dialog.h" | |
16 #include "chrome/browser/webdata/autocomplete_syncable_service.h" | |
17 #include "chrome/browser/webdata/autofill_change.h" | 9 #include "chrome/browser/webdata/autofill_change.h" |
18 #include "chrome/browser/webdata/autofill_entry.h" | 10 #include "chrome/browser/webdata/autofill_entry.h" |
19 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" | |
20 #include "chrome/browser/webdata/autofill_table.h" | 11 #include "chrome/browser/webdata/autofill_table.h" |
21 #include "chrome/browser/webdata/keyword_table.h" | 12 #include "chrome/browser/webdata/keyword_table.h" |
22 #include "chrome/browser/webdata/logins_table.h" | 13 #include "chrome/browser/webdata/logins_table.h" |
23 #include "chrome/browser/webdata/token_service_table.h" | 14 #include "chrome/browser/webdata/token_service_table.h" |
24 #include "chrome/browser/webdata/web_apps_table.h" | 15 #include "chrome/browser/webdata/web_apps_table.h" |
25 #include "chrome/browser/webdata/web_database_service.h" | 16 #include "chrome/browser/webdata/web_database_service.h" |
26 #include "chrome/browser/webdata/web_intents_table.h" | 17 #include "chrome/browser/webdata/web_intents_table.h" |
27 #include "chrome/common/chrome_constants.h" | |
28 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
29 #include "components/autofill/browser/autofill_country.h" | 19 #include "components/autofill/browser/autofill_country.h" |
30 #include "components/autofill/browser/autofill_profile.h" | 20 #include "components/autofill/browser/autofill_profile.h" |
31 #include "components/autofill/browser/credit_card.h" | 21 #include "components/autofill/browser/credit_card.h" |
32 #include "components/autofill/common/form_field_data.h" | 22 #include "components/autofill/common/form_field_data.h" |
33 #ifdef DEBUG | |
34 #include "content/public/browser/browser_thread.h" | |
35 #endif | |
36 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
37 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
38 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
39 #include "grit/chromium_strings.h" | |
40 #include "grit/generated_resources.h" | |
41 #include "third_party/skia/include/core/SkBitmap.h" | 26 #include "third_party/skia/include/core/SkBitmap.h" |
42 | 27 |
43 //////////////////////////////////////////////////////////////////////////////// | 28 //////////////////////////////////////////////////////////////////////////////// |
44 // | 29 // |
45 // WebDataService implementation. | 30 // WebDataService implementation. |
46 // | 31 // |
47 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
48 | 33 |
49 using base::Bind; | 34 using base::Bind; |
50 using base::Time; | 35 using base::Time; |
(...skipping 19 matching lines...) Expand all Loading... |
70 | 55 |
71 WDAppImagesResult::~WDAppImagesResult() {} | 56 WDAppImagesResult::~WDAppImagesResult() {} |
72 | 57 |
73 WDKeywordsResult::WDKeywordsResult() | 58 WDKeywordsResult::WDKeywordsResult() |
74 : default_search_provider_id(0), | 59 : default_search_provider_id(0), |
75 builtin_keyword_version(0) { | 60 builtin_keyword_version(0) { |
76 } | 61 } |
77 | 62 |
78 WDKeywordsResult::~WDKeywordsResult() {} | 63 WDKeywordsResult::~WDKeywordsResult() {} |
79 | 64 |
80 WebDataService::WebDataService() | 65 WebDataService::WebDataService(const ProfileErrorCallback& callback) |
81 : db_loaded_(false), | 66 : WebDataServiceBase(callback) { |
82 autocomplete_syncable_service_(NULL), | |
83 autofill_profile_syncable_service_(NULL) { | |
84 // WebDataService requires DB thread if instantiated. | |
85 // Set WebDataServiceFactory::GetInstance()->SetTestingFactory(&profile, NULL) | |
86 // if you do not want to instantiate WebDataService in your test. | |
87 DCHECK(BrowserThread::IsWellKnownThread(BrowserThread::DB)); | |
88 } | 67 } |
89 | 68 |
90 // static | 69 // static |
91 void WebDataService::NotifyOfMultipleAutofillChanges( | 70 void WebDataService::NotifyOfMultipleAutofillChanges( |
92 WebDataService* web_data_service) { | 71 WebDataService* web_data_service) { |
93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
94 | 73 |
95 if (!web_data_service) | 74 if (!web_data_service) |
96 return; | 75 return; |
97 | 76 |
98 BrowserThread::PostTask( | 77 BrowserThread::PostTask( |
99 BrowserThread::UI, FROM_HERE, | 78 BrowserThread::UI, FROM_HERE, |
100 Bind(&NotifyOfMultipleAutofillChangesTask, | 79 Bind(&NotifyOfMultipleAutofillChangesTask, |
101 make_scoped_refptr(web_data_service))); | 80 make_scoped_refptr(web_data_service))); |
102 } | 81 } |
103 | 82 |
104 void WebDataService::ShutdownOnUIThread() { | |
105 db_loaded_ = false; | |
106 ShutdownDatabase(); | |
107 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | |
108 Bind(&WebDataService::ShutdownSyncableServices, this)); | |
109 } | |
110 | |
111 void WebDataService::Init(const base::FilePath& path) { | |
112 wdbs_.reset(new WebDatabaseService(path)); | |
113 wdbs_->LoadDatabase(Bind(&WebDataService::DatabaseInitOnDB, this)); | |
114 | |
115 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | |
116 Bind(&WebDataService::InitializeSyncableServices, this)); | |
117 } | |
118 | |
119 void WebDataService::UnloadDatabase() { | |
120 if (!wdbs_) | |
121 return; | |
122 wdbs_->UnloadDatabase(); | |
123 } | |
124 | |
125 void WebDataService::ShutdownDatabase() { | |
126 if (!wdbs_) | |
127 return; | |
128 wdbs_->ShutdownDatabase(); | |
129 } | |
130 | |
131 void WebDataService::CancelRequest(Handle h) { | |
132 if (!wdbs_) | |
133 return; | |
134 wdbs_->CancelRequest(h); | |
135 } | |
136 | |
137 content::NotificationSource WebDataService::GetNotificationSource() { | |
138 return content::Source<WebDataService>(this); | |
139 } | |
140 | |
141 bool WebDataService::IsDatabaseLoaded() { | |
142 return db_loaded_; | |
143 } | |
144 | |
145 WebDatabase* WebDataService::GetDatabase() { | |
146 if (!wdbs_) | |
147 return NULL; | |
148 return wdbs_->GetDatabaseOnDB(); | |
149 } | |
150 | |
151 ////////////////////////////////////////////////////////////////////////////// | 83 ////////////////////////////////////////////////////////////////////////////// |
152 // | 84 // |
153 // Keywords. | 85 // Keywords. |
154 // | 86 // |
155 ////////////////////////////////////////////////////////////////////////////// | 87 ////////////////////////////////////////////////////////////////////////////// |
156 | 88 |
157 void WebDataService::AddKeyword(const TemplateURLData& data) { | 89 void WebDataService::AddKeyword(const TemplateURLData& data) { |
158 wdbs_->ScheduleDBTask( | 90 wdbs_->ScheduleDBTask( |
159 FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, data)); | 91 FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, data)); |
160 } | 92 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 254 } |
323 | 255 |
324 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween( | 256 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween( |
325 const Time& delete_begin, | 257 const Time& delete_begin, |
326 const Time& delete_end) { | 258 const Time& delete_end) { |
327 wdbs_->ScheduleDBTask(FROM_HERE, Bind( | 259 wdbs_->ScheduleDBTask(FROM_HERE, Bind( |
328 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl, | 260 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl, |
329 this, delete_begin, delete_end)); | 261 this, delete_begin, delete_end)); |
330 } | 262 } |
331 | 263 |
| 264 WebDataService::WebDataService() |
| 265 : WebDataServiceBase(ProfileErrorCallback()) { |
| 266 } |
| 267 |
332 WebDataService::~WebDataService() { | 268 WebDataService::~WebDataService() { |
333 wdbs_.reset(); | |
334 DCHECK(!autocomplete_syncable_service_); | |
335 DCHECK(!autofill_profile_syncable_service_); | |
336 } | 269 } |
337 | 270 |
338 //////////////////////////////////////////////////////////////////////////////// | 271 //////////////////////////////////////////////////////////////////////////////// |
339 // | |
340 // The following methods are executed on the DB thread. | |
341 // | |
342 //////////////////////////////////////////////////////////////////////////////// | |
343 | |
344 void WebDataService::DBInitFailed(sql::InitStatus sql_status) { | |
345 ShowProfileErrorDialog( | |
346 (sql_status == sql::INIT_FAILURE) ? | |
347 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR); | |
348 } | |
349 | |
350 void WebDataService::NotifyDatabaseLoadedOnUIThread() { | |
351 db_loaded_ = true; | |
352 // Notify that the database has been initialized. | |
353 content::NotificationService::current()->Notify( | |
354 chrome::NOTIFICATION_WEB_DATABASE_LOADED, | |
355 content::Source<WebDataService>(this), | |
356 content::NotificationService::NoDetails()); | |
357 } | |
358 | |
359 void WebDataService::DatabaseInitOnDB(sql::InitStatus status) { | |
360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
361 if (status == sql::INIT_OK) { | |
362 BrowserThread::PostTask( | |
363 BrowserThread::UI, FROM_HERE, | |
364 base::Bind(&WebDataService::NotifyDatabaseLoadedOnUIThread, this)); | |
365 } else { | |
366 BrowserThread::PostTask( | |
367 BrowserThread::UI, FROM_HERE, | |
368 base::Bind(&WebDataService::DBInitFailed, this, status)); | |
369 } | |
370 } | |
371 | |
372 void WebDataService::InitializeSyncableServices() { | |
373 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
374 DCHECK(!autocomplete_syncable_service_); | |
375 DCHECK(!autofill_profile_syncable_service_); | |
376 | |
377 autocomplete_syncable_service_ = new AutocompleteSyncableService(this); | |
378 autofill_profile_syncable_service_ = new AutofillProfileSyncableService(this); | |
379 } | |
380 | |
381 void WebDataService::ShutdownSyncableServices() { | |
382 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
383 | |
384 delete autocomplete_syncable_service_; | |
385 autocomplete_syncable_service_ = NULL; | |
386 delete autofill_profile_syncable_service_; | |
387 autofill_profile_syncable_service_ = NULL; | |
388 } | |
389 | |
390 //////////////////////////////////////////////////////////////////////////////// | |
391 // | 272 // |
392 // Keywords implementation. | 273 // Keywords implementation. |
393 // | 274 // |
394 //////////////////////////////////////////////////////////////////////////////// | 275 //////////////////////////////////////////////////////////////////////////////// |
395 | 276 |
396 WebDatabase::State WebDataService::AddKeywordImpl( | 277 WebDatabase::State WebDataService::AddKeywordImpl( |
397 const TemplateURLData& data, WebDatabase* db) { | 278 const TemplateURLData& data, WebDatabase* db) { |
398 db->GetKeywordTable()->AddKeyword(data); | 279 KeywordTable::FromWebDatabase(db)->AddKeyword(data); |
399 return WebDatabase::COMMIT_NEEDED; | 280 return WebDatabase::COMMIT_NEEDED; |
400 } | 281 } |
401 | 282 |
402 WebDatabase::State WebDataService::RemoveKeywordImpl( | 283 WebDatabase::State WebDataService::RemoveKeywordImpl( |
403 TemplateURLID id, WebDatabase* db) { | 284 TemplateURLID id, WebDatabase* db) { |
404 DCHECK(id); | 285 DCHECK(id); |
405 db->GetKeywordTable()->RemoveKeyword(id); | 286 KeywordTable::FromWebDatabase(db)->RemoveKeyword(id); |
406 return WebDatabase::COMMIT_NEEDED; | 287 return WebDatabase::COMMIT_NEEDED; |
407 } | 288 } |
408 | 289 |
409 WebDatabase::State WebDataService::UpdateKeywordImpl( | 290 WebDatabase::State WebDataService::UpdateKeywordImpl( |
410 const TemplateURLData& data, WebDatabase* db) { | 291 const TemplateURLData& data, WebDatabase* db) { |
411 if (!db->GetKeywordTable()->UpdateKeyword(data)) { | 292 if (!KeywordTable::FromWebDatabase(db)->UpdateKeyword(data)) { |
412 NOTREACHED(); | 293 NOTREACHED(); |
413 return WebDatabase::COMMIT_NOT_NEEDED; | 294 return WebDatabase::COMMIT_NOT_NEEDED; |
414 } | 295 } |
415 return WebDatabase::COMMIT_NEEDED; | 296 return WebDatabase::COMMIT_NEEDED; |
416 } | 297 } |
417 | 298 |
418 scoped_ptr<WDTypedResult> WebDataService::GetKeywordsImpl(WebDatabase* db) { | 299 scoped_ptr<WDTypedResult> WebDataService::GetKeywordsImpl(WebDatabase* db) { |
419 WDKeywordsResult result; | 300 WDKeywordsResult result; |
420 db->GetKeywordTable()->GetKeywords(&result.keywords); | 301 KeywordTable::FromWebDatabase(db)->GetKeywords(&result.keywords); |
421 result.default_search_provider_id = | 302 result.default_search_provider_id = |
422 db->GetKeywordTable()->GetDefaultSearchProviderID(); | 303 KeywordTable::FromWebDatabase(db)->GetDefaultSearchProviderID(); |
423 result.builtin_keyword_version = | 304 result.builtin_keyword_version = |
424 db->GetKeywordTable()->GetBuiltinKeywordVersion(); | 305 KeywordTable::FromWebDatabase(db)->GetBuiltinKeywordVersion(); |
425 return scoped_ptr<WDTypedResult>( | 306 return scoped_ptr<WDTypedResult>( |
426 new WDResult<WDKeywordsResult>(KEYWORDS_RESULT, result)); | 307 new WDResult<WDKeywordsResult>(KEYWORDS_RESULT, result)); |
427 } | 308 } |
428 | 309 |
429 WebDatabase::State WebDataService::SetDefaultSearchProviderImpl( | 310 WebDatabase::State WebDataService::SetDefaultSearchProviderImpl( |
430 TemplateURLID id, WebDatabase* db) { | 311 TemplateURLID id, WebDatabase* db) { |
431 if (!db->GetKeywordTable()->SetDefaultSearchProviderID(id)) { | 312 if (!KeywordTable::FromWebDatabase(db)->SetDefaultSearchProviderID(id)) { |
432 NOTREACHED(); | 313 NOTREACHED(); |
433 return WebDatabase::COMMIT_NOT_NEEDED; | 314 return WebDatabase::COMMIT_NOT_NEEDED; |
434 } | 315 } |
435 return WebDatabase::COMMIT_NEEDED; | 316 return WebDatabase::COMMIT_NEEDED; |
436 } | 317 } |
437 | 318 |
438 WebDatabase::State WebDataService::SetBuiltinKeywordVersionImpl( | 319 WebDatabase::State WebDataService::SetBuiltinKeywordVersionImpl( |
439 int version, WebDatabase* db) { | 320 int version, WebDatabase* db) { |
440 if (!db->GetKeywordTable()->SetBuiltinKeywordVersion(version)) { | 321 if (!KeywordTable::FromWebDatabase(db)->SetBuiltinKeywordVersion(version)) { |
441 NOTREACHED(); | 322 NOTREACHED(); |
442 return WebDatabase::COMMIT_NOT_NEEDED; | 323 return WebDatabase::COMMIT_NOT_NEEDED; |
443 } | 324 } |
444 return WebDatabase::COMMIT_NEEDED; | 325 return WebDatabase::COMMIT_NEEDED; |
445 } | 326 } |
446 | 327 |
447 //////////////////////////////////////////////////////////////////////////////// | 328 //////////////////////////////////////////////////////////////////////////////// |
448 // | 329 // |
449 // Web Apps implementation. | 330 // Web Apps implementation. |
450 // | 331 // |
451 //////////////////////////////////////////////////////////////////////////////// | 332 //////////////////////////////////////////////////////////////////////////////// |
452 | 333 |
453 WebDatabase::State WebDataService::SetWebAppImageImpl( | 334 WebDatabase::State WebDataService::SetWebAppImageImpl( |
454 const GURL& app_url, const SkBitmap& image, WebDatabase* db) { | 335 const GURL& app_url, const SkBitmap& image, WebDatabase* db) { |
455 db->GetWebAppsTable()->SetWebAppImage(app_url, image); | 336 WebAppsTable::FromWebDatabase(db)->SetWebAppImage(app_url, image); |
456 return WebDatabase::COMMIT_NEEDED; | 337 return WebDatabase::COMMIT_NEEDED; |
457 } | 338 } |
458 | 339 |
459 WebDatabase::State WebDataService::SetWebAppHasAllImagesImpl( | 340 WebDatabase::State WebDataService::SetWebAppHasAllImagesImpl( |
460 const GURL& app_url, bool has_all_images, WebDatabase* db) { | 341 const GURL& app_url, bool has_all_images, WebDatabase* db) { |
461 db->GetWebAppsTable()-> | 342 WebAppsTable::FromWebDatabase(db)->SetWebAppHasAllImages(app_url, |
462 SetWebAppHasAllImages(app_url, has_all_images); | 343 has_all_images); |
463 return WebDatabase::COMMIT_NEEDED; | 344 return WebDatabase::COMMIT_NEEDED; |
464 } | 345 } |
465 | 346 |
466 WebDatabase::State WebDataService::RemoveWebAppImpl( | 347 WebDatabase::State WebDataService::RemoveWebAppImpl( |
467 const GURL& app_url, WebDatabase* db) { | 348 const GURL& app_url, WebDatabase* db) { |
468 db->GetWebAppsTable()->RemoveWebApp(app_url); | 349 WebAppsTable::FromWebDatabase(db)->RemoveWebApp(app_url); |
469 return WebDatabase::COMMIT_NEEDED; | 350 return WebDatabase::COMMIT_NEEDED; |
470 } | 351 } |
471 | 352 |
472 scoped_ptr<WDTypedResult> WebDataService::GetWebAppImagesImpl( | 353 scoped_ptr<WDTypedResult> WebDataService::GetWebAppImagesImpl( |
473 const GURL& app_url, WebDatabase* db) { | 354 const GURL& app_url, WebDatabase* db) { |
474 WDAppImagesResult result; | 355 WDAppImagesResult result; |
475 result.has_all_images = db->GetWebAppsTable()->GetWebAppHasAllImages(app_url); | 356 result.has_all_images = |
476 db->GetWebAppsTable()->GetWebAppImages(app_url, &result.images); | 357 WebAppsTable::FromWebDatabase(db)->GetWebAppHasAllImages(app_url); |
| 358 WebAppsTable::FromWebDatabase(db)->GetWebAppImages(app_url, &result.images); |
477 return scoped_ptr<WDTypedResult>( | 359 return scoped_ptr<WDTypedResult>( |
478 new WDResult<WDAppImagesResult>(WEB_APP_IMAGES, result)); | 360 new WDResult<WDAppImagesResult>(WEB_APP_IMAGES, result)); |
479 } | 361 } |
480 | 362 |
481 //////////////////////////////////////////////////////////////////////////////// | 363 //////////////////////////////////////////////////////////////////////////////// |
482 // | 364 // |
483 // Token Service implementation. | 365 // Token Service implementation. |
484 // | 366 // |
485 //////////////////////////////////////////////////////////////////////////////// | 367 //////////////////////////////////////////////////////////////////////////////// |
486 | 368 |
487 WebDatabase::State WebDataService::RemoveAllTokensImpl(WebDatabase* db) { | 369 WebDatabase::State WebDataService::RemoveAllTokensImpl(WebDatabase* db) { |
488 if (db->GetTokenServiceTable()->RemoveAllTokens()) { | 370 if (TokenServiceTable::FromWebDatabase(db)->RemoveAllTokens()) { |
489 return WebDatabase::COMMIT_NEEDED; | 371 return WebDatabase::COMMIT_NEEDED; |
490 } | 372 } |
491 return WebDatabase::COMMIT_NOT_NEEDED; | 373 return WebDatabase::COMMIT_NOT_NEEDED; |
492 } | 374 } |
493 | 375 |
494 WebDatabase::State WebDataService::SetTokenForServiceImpl( | 376 WebDatabase::State WebDataService::SetTokenForServiceImpl( |
495 const std::string& service, const std::string& token, WebDatabase* db) { | 377 const std::string& service, const std::string& token, WebDatabase* db) { |
496 if (db->GetTokenServiceTable()->SetTokenForService(service, token)) { | 378 if (TokenServiceTable::FromWebDatabase(db)->SetTokenForService(service, |
| 379 token)) { |
497 return WebDatabase::COMMIT_NEEDED; | 380 return WebDatabase::COMMIT_NEEDED; |
498 } | 381 } |
499 return WebDatabase::COMMIT_NOT_NEEDED; | 382 return WebDatabase::COMMIT_NOT_NEEDED; |
500 } | 383 } |
501 | 384 |
502 scoped_ptr<WDTypedResult> WebDataService::GetAllTokensImpl(WebDatabase* db) { | 385 scoped_ptr<WDTypedResult> WebDataService::GetAllTokensImpl(WebDatabase* db) { |
503 std::map<std::string, std::string> map; | 386 std::map<std::string, std::string> map; |
504 db->GetTokenServiceTable()->GetAllTokens(&map); | 387 TokenServiceTable::FromWebDatabase(db)->GetAllTokens(&map); |
505 return scoped_ptr<WDTypedResult>( | 388 return scoped_ptr<WDTypedResult>( |
506 new WDResult<std::map<std::string, std::string> >(TOKEN_RESULT, map)); | 389 new WDResult<std::map<std::string, std::string> >(TOKEN_RESULT, map)); |
507 } | 390 } |
508 | 391 |
509 //////////////////////////////////////////////////////////////////////////////// | 392 //////////////////////////////////////////////////////////////////////////////// |
510 // | 393 // |
511 // Autofill implementation. | 394 // Autofill implementation. |
512 // | 395 // |
513 //////////////////////////////////////////////////////////////////////////////// | 396 //////////////////////////////////////////////////////////////////////////////// |
514 | 397 |
515 WebDatabase::State WebDataService::AddFormElementsImpl( | 398 WebDatabase::State WebDataService::AddFormElementsImpl( |
516 const std::vector<FormFieldData>& fields, WebDatabase* db) { | 399 const std::vector<FormFieldData>& fields, WebDatabase* db) { |
517 AutofillChangeList changes; | 400 AutofillChangeList changes; |
518 if (!db->GetAutofillTable()->AddFormFieldValues(fields, &changes)) { | 401 if (!AutofillTable::FromWebDatabase(db)->AddFormFieldValues( |
| 402 fields, &changes)) { |
519 NOTREACHED(); | 403 NOTREACHED(); |
520 return WebDatabase::COMMIT_NOT_NEEDED; | 404 return WebDatabase::COMMIT_NOT_NEEDED; |
521 } | 405 } |
522 | 406 |
523 // Post the notifications including the list of affected keys. | 407 // Post the notifications including the list of affected keys. |
524 // This is sent here so that work resulting from this notification will be | 408 // This is sent here so that work resulting from this notification will be |
525 // done on the DB thread, and not the UI thread. | 409 // done on the DB thread, and not the UI thread. |
526 content::NotificationService::current()->Notify( | 410 content::NotificationService::current()->Notify( |
527 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 411 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
528 content::Source<WebDataService>(this), | 412 content::Source<WebDataService>(this), |
529 content::Details<AutofillChangeList>(&changes)); | 413 content::Details<AutofillChangeList>(&changes)); |
530 | 414 |
531 return WebDatabase::COMMIT_NEEDED; | 415 return WebDatabase::COMMIT_NEEDED; |
532 } | 416 } |
533 | 417 |
534 scoped_ptr<WDTypedResult> WebDataService::GetFormValuesForElementNameImpl( | 418 scoped_ptr<WDTypedResult> WebDataService::GetFormValuesForElementNameImpl( |
535 const string16& name, const string16& prefix, int limit, WebDatabase* db) { | 419 const string16& name, const string16& prefix, int limit, WebDatabase* db) { |
536 std::vector<string16> values; | 420 std::vector<string16> values; |
537 db->GetAutofillTable()->GetFormValuesForElementName( | 421 AutofillTable::FromWebDatabase(db)->GetFormValuesForElementName( |
538 name, prefix, &values, limit); | 422 name, prefix, &values, limit); |
539 return scoped_ptr<WDTypedResult>( | 423 return scoped_ptr<WDTypedResult>( |
540 new WDResult<std::vector<string16> >(AUTOFILL_VALUE_RESULT, values)); | 424 new WDResult<std::vector<string16> >(AUTOFILL_VALUE_RESULT, values)); |
541 } | 425 } |
542 | 426 |
543 WebDatabase::State WebDataService::RemoveFormElementsAddedBetweenImpl( | 427 WebDatabase::State WebDataService::RemoveFormElementsAddedBetweenImpl( |
544 const base::Time& delete_begin, const base::Time& delete_end, | 428 const base::Time& delete_begin, const base::Time& delete_end, |
545 WebDatabase* db) { | 429 WebDatabase* db) { |
546 AutofillChangeList changes; | 430 AutofillChangeList changes; |
547 | 431 |
548 if (db->GetAutofillTable()->RemoveFormElementsAddedBetween( | 432 if (AutofillTable::FromWebDatabase(db)->RemoveFormElementsAddedBetween( |
549 delete_begin, delete_end, &changes)) { | 433 delete_begin, delete_end, &changes)) { |
550 if (!changes.empty()) { | 434 if (!changes.empty()) { |
551 // Post the notifications including the list of affected keys. | 435 // Post the notifications including the list of affected keys. |
552 // This is sent here so that work resulting from this notification | 436 // This is sent here so that work resulting from this notification |
553 // will be done on the DB thread, and not the UI thread. | 437 // will be done on the DB thread, and not the UI thread. |
554 content::NotificationService::current()->Notify( | 438 content::NotificationService::current()->Notify( |
555 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 439 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
556 content::Source<WebDataService>(this), | 440 content::Source<WebDataService>(this), |
557 content::Details<AutofillChangeList>(&changes)); | 441 content::Details<AutofillChangeList>(&changes)); |
558 } | 442 } |
559 return WebDatabase::COMMIT_NEEDED; | 443 return WebDatabase::COMMIT_NEEDED; |
560 } | 444 } |
561 return WebDatabase::COMMIT_NOT_NEEDED; | 445 return WebDatabase::COMMIT_NOT_NEEDED; |
562 } | 446 } |
563 | 447 |
564 WebDatabase::State WebDataService::RemoveExpiredFormElementsImpl( | 448 WebDatabase::State WebDataService::RemoveExpiredFormElementsImpl( |
565 WebDatabase* db) { | 449 WebDatabase* db) { |
566 AutofillChangeList changes; | 450 AutofillChangeList changes; |
567 | 451 |
568 if (db->GetAutofillTable()->RemoveExpiredFormElements(&changes)) { | 452 if (AutofillTable::FromWebDatabase(db)->RemoveExpiredFormElements(&changes)) { |
569 if (!changes.empty()) { | 453 if (!changes.empty()) { |
570 // Post the notifications including the list of affected keys. | 454 // Post the notifications including the list of affected keys. |
571 // This is sent here so that work resulting from this notification | 455 // This is sent here so that work resulting from this notification |
572 // will be done on the DB thread, and not the UI thread. | 456 // will be done on the DB thread, and not the UI thread. |
573 content::NotificationService::current()->Notify( | 457 content::NotificationService::current()->Notify( |
574 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 458 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
575 content::Source<WebDataService>(this), | 459 content::Source<WebDataService>(this), |
576 content::Details<AutofillChangeList>(&changes)); | 460 content::Details<AutofillChangeList>(&changes)); |
577 } | 461 } |
578 return WebDatabase::COMMIT_NEEDED; | 462 return WebDatabase::COMMIT_NEEDED; |
579 } | 463 } |
580 return WebDatabase::COMMIT_NOT_NEEDED; | 464 return WebDatabase::COMMIT_NOT_NEEDED; |
581 } | 465 } |
582 | 466 |
583 WebDatabase::State WebDataService::RemoveFormValueForElementNameImpl( | 467 WebDatabase::State WebDataService::RemoveFormValueForElementNameImpl( |
584 const string16& name, const string16& value, WebDatabase* db) { | 468 const string16& name, const string16& value, WebDatabase* db) { |
585 | 469 |
586 if (db->GetAutofillTable()->RemoveFormElement(name, value)) { | 470 if (AutofillTable::FromWebDatabase(db)->RemoveFormElement(name, value)) { |
587 AutofillChangeList changes; | 471 AutofillChangeList changes; |
588 changes.push_back(AutofillChange(AutofillChange::REMOVE, | 472 changes.push_back(AutofillChange(AutofillChange::REMOVE, |
589 AutofillKey(name, value))); | 473 AutofillKey(name, value))); |
590 | 474 |
591 // Post the notifications including the list of affected keys. | 475 // Post the notifications including the list of affected keys. |
592 content::NotificationService::current()->Notify( | 476 content::NotificationService::current()->Notify( |
593 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, | 477 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, |
594 content::Source<WebDataService>(this), | 478 content::Source<WebDataService>(this), |
595 content::Details<AutofillChangeList>(&changes)); | 479 content::Details<AutofillChangeList>(&changes)); |
596 | 480 |
597 return WebDatabase::COMMIT_NEEDED; | 481 return WebDatabase::COMMIT_NEEDED; |
598 } | 482 } |
599 return WebDatabase::COMMIT_NOT_NEEDED; | 483 return WebDatabase::COMMIT_NOT_NEEDED; |
600 } | 484 } |
601 | 485 |
602 WebDatabase::State WebDataService::AddAutofillProfileImpl( | 486 WebDatabase::State WebDataService::AddAutofillProfileImpl( |
603 const AutofillProfile& profile, WebDatabase* db) { | 487 const AutofillProfile& profile, WebDatabase* db) { |
604 if (!db->GetAutofillTable()->AddAutofillProfile(profile)) { | 488 if (!AutofillTable::FromWebDatabase(db)->AddAutofillProfile(profile)) { |
605 NOTREACHED(); | 489 NOTREACHED(); |
606 return WebDatabase::COMMIT_NOT_NEEDED; | 490 return WebDatabase::COMMIT_NOT_NEEDED; |
607 } | 491 } |
608 | 492 |
609 // Send GUID-based notification. | 493 // Send GUID-based notification. |
610 AutofillProfileChange change(AutofillProfileChange::ADD, | 494 AutofillProfileChange change(AutofillProfileChange::ADD, |
611 profile.guid(), &profile); | 495 profile.guid(), &profile); |
612 content::NotificationService::current()->Notify( | 496 content::NotificationService::current()->Notify( |
613 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 497 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
614 content::Source<WebDataService>(this), | 498 content::Source<WebDataService>(this), |
615 content::Details<AutofillProfileChange>(&change)); | 499 content::Details<AutofillProfileChange>(&change)); |
616 | 500 |
617 return WebDatabase::COMMIT_NEEDED; | 501 return WebDatabase::COMMIT_NEEDED; |
618 } | 502 } |
619 | 503 |
620 WebDatabase::State WebDataService::UpdateAutofillProfileImpl( | 504 WebDatabase::State WebDataService::UpdateAutofillProfileImpl( |
621 const AutofillProfile& profile, WebDatabase* db) { | 505 const AutofillProfile& profile, WebDatabase* db) { |
622 // Only perform the update if the profile exists. It is currently | 506 // Only perform the update if the profile exists. It is currently |
623 // valid to try to update a missing profile. We simply drop the write and | 507 // valid to try to update a missing profile. We simply drop the write and |
624 // the caller will detect this on the next refresh. | 508 // the caller will detect this on the next refresh. |
625 AutofillProfile* original_profile = NULL; | 509 AutofillProfile* original_profile = NULL; |
626 if (!db->GetAutofillTable()->GetAutofillProfile(profile.guid(), | 510 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(profile.guid(), |
627 &original_profile)) { | 511 &original_profile)) { |
628 return WebDatabase::COMMIT_NOT_NEEDED; | 512 return WebDatabase::COMMIT_NOT_NEEDED; |
629 } | 513 } |
630 scoped_ptr<AutofillProfile> scoped_profile(original_profile); | 514 scoped_ptr<AutofillProfile> scoped_profile(original_profile); |
631 | 515 |
632 if (!db->GetAutofillTable()->UpdateAutofillProfileMulti(profile)) { | 516 if (!AutofillTable::FromWebDatabase(db)->UpdateAutofillProfileMulti( |
| 517 profile)) { |
633 NOTREACHED(); | 518 NOTREACHED(); |
634 return WebDatabase::COMMIT_NEEDED; | 519 return WebDatabase::COMMIT_NEEDED; |
635 } | 520 } |
636 | 521 |
637 // Send GUID-based notification. | 522 // Send GUID-based notification. |
638 AutofillProfileChange change(AutofillProfileChange::UPDATE, | 523 AutofillProfileChange change(AutofillProfileChange::UPDATE, |
639 profile.guid(), &profile); | 524 profile.guid(), &profile); |
640 content::NotificationService::current()->Notify( | 525 content::NotificationService::current()->Notify( |
641 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 526 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
642 content::Source<WebDataService>(this), | 527 content::Source<WebDataService>(this), |
643 content::Details<AutofillProfileChange>(&change)); | 528 content::Details<AutofillProfileChange>(&change)); |
644 | 529 |
645 return WebDatabase::COMMIT_NEEDED; | 530 return WebDatabase::COMMIT_NEEDED; |
646 } | 531 } |
647 | 532 |
648 WebDatabase::State WebDataService::RemoveAutofillProfileImpl( | 533 WebDatabase::State WebDataService::RemoveAutofillProfileImpl( |
649 const std::string& guid, WebDatabase* db) { | 534 const std::string& guid, WebDatabase* db) { |
650 AutofillProfile* profile = NULL; | 535 AutofillProfile* profile = NULL; |
651 if (!db->GetAutofillTable()->GetAutofillProfile(guid, &profile)) { | 536 if (!AutofillTable::FromWebDatabase(db)->GetAutofillProfile(guid, &profile)) { |
652 NOTREACHED(); | 537 NOTREACHED(); |
653 return WebDatabase::COMMIT_NOT_NEEDED; | 538 return WebDatabase::COMMIT_NOT_NEEDED; |
654 } | 539 } |
655 scoped_ptr<AutofillProfile> scoped_profile(profile); | 540 scoped_ptr<AutofillProfile> scoped_profile(profile); |
656 | 541 |
657 if (!db->GetAutofillTable()->RemoveAutofillProfile(guid)) { | 542 if (!AutofillTable::FromWebDatabase(db)->RemoveAutofillProfile(guid)) { |
658 NOTREACHED(); | 543 NOTREACHED(); |
659 return WebDatabase::COMMIT_NOT_NEEDED; | 544 return WebDatabase::COMMIT_NOT_NEEDED; |
660 } | 545 } |
661 | 546 |
662 // Send GUID-based notification. | 547 // Send GUID-based notification. |
663 AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL); | 548 AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL); |
664 content::NotificationService::current()->Notify( | 549 content::NotificationService::current()->Notify( |
665 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 550 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
666 content::Source<WebDataService>(this), | 551 content::Source<WebDataService>(this), |
667 content::Details<AutofillProfileChange>(&change)); | 552 content::Details<AutofillProfileChange>(&change)); |
668 | 553 |
669 return WebDatabase::COMMIT_NEEDED; | 554 return WebDatabase::COMMIT_NEEDED; |
670 } | 555 } |
671 | 556 |
672 scoped_ptr<WDTypedResult> WebDataService::GetAutofillProfilesImpl( | 557 scoped_ptr<WDTypedResult> WebDataService::GetAutofillProfilesImpl( |
673 WebDatabase* db) { | 558 WebDatabase* db) { |
674 std::vector<AutofillProfile*> profiles; | 559 std::vector<AutofillProfile*> profiles; |
675 db->GetAutofillTable()->GetAutofillProfiles(&profiles); | 560 AutofillTable::FromWebDatabase(db)->GetAutofillProfiles(&profiles); |
676 return scoped_ptr<WDTypedResult>( | 561 return scoped_ptr<WDTypedResult>( |
677 new WDDestroyableResult<std::vector<AutofillProfile*> >( | 562 new WDDestroyableResult<std::vector<AutofillProfile*> >( |
678 AUTOFILL_PROFILES_RESULT, | 563 AUTOFILL_PROFILES_RESULT, |
679 profiles, | 564 profiles, |
680 base::Bind(&WebDataService::DestroyAutofillProfileResult, | 565 base::Bind(&WebDataService::DestroyAutofillProfileResult, |
681 base::Unretained(this)))); | 566 base::Unretained(this)))); |
682 } | 567 } |
683 | 568 |
684 WebDatabase::State WebDataService::AddCreditCardImpl( | 569 WebDatabase::State WebDataService::AddCreditCardImpl( |
685 const CreditCard& credit_card, WebDatabase* db) { | 570 const CreditCard& credit_card, WebDatabase* db) { |
686 if (!db->GetAutofillTable()->AddCreditCard(credit_card)) { | 571 if (!AutofillTable::FromWebDatabase(db)->AddCreditCard(credit_card)) { |
687 NOTREACHED(); | 572 NOTREACHED(); |
688 return WebDatabase::COMMIT_NOT_NEEDED; | 573 return WebDatabase::COMMIT_NOT_NEEDED; |
689 } | 574 } |
690 | 575 |
691 return WebDatabase::COMMIT_NEEDED; | 576 return WebDatabase::COMMIT_NEEDED; |
692 } | 577 } |
693 | 578 |
694 WebDatabase::State WebDataService::UpdateCreditCardImpl( | 579 WebDatabase::State WebDataService::UpdateCreditCardImpl( |
695 const CreditCard& credit_card, WebDatabase* db) { | 580 const CreditCard& credit_card, WebDatabase* db) { |
696 // It is currently valid to try to update a missing profile. We simply drop | 581 // It is currently valid to try to update a missing profile. We simply drop |
697 // the write and the caller will detect this on the next refresh. | 582 // the write and the caller will detect this on the next refresh. |
698 CreditCard* original_credit_card = NULL; | 583 CreditCard* original_credit_card = NULL; |
699 if (!db->GetAutofillTable()->GetCreditCard(credit_card.guid(), | 584 if (!AutofillTable::FromWebDatabase(db)->GetCreditCard(credit_card.guid(), |
700 &original_credit_card)) { | 585 &original_credit_card)) { |
701 return WebDatabase::COMMIT_NOT_NEEDED; | 586 return WebDatabase::COMMIT_NOT_NEEDED; |
702 } | 587 } |
703 scoped_ptr<CreditCard> scoped_credit_card(original_credit_card); | 588 scoped_ptr<CreditCard> scoped_credit_card(original_credit_card); |
704 | 589 |
705 if (!db->GetAutofillTable()->UpdateCreditCard(credit_card)) { | 590 if (!AutofillTable::FromWebDatabase(db)->UpdateCreditCard(credit_card)) { |
706 NOTREACHED(); | 591 NOTREACHED(); |
707 return WebDatabase::COMMIT_NOT_NEEDED; | 592 return WebDatabase::COMMIT_NOT_NEEDED; |
708 } | 593 } |
709 return WebDatabase::COMMIT_NEEDED; | 594 return WebDatabase::COMMIT_NEEDED; |
710 } | 595 } |
711 | 596 |
712 WebDatabase::State WebDataService::RemoveCreditCardImpl( | 597 WebDatabase::State WebDataService::RemoveCreditCardImpl( |
713 const std::string& guid, WebDatabase* db) { | 598 const std::string& guid, WebDatabase* db) { |
714 if (!db->GetAutofillTable()->RemoveCreditCard(guid)) { | 599 if (!AutofillTable::FromWebDatabase(db)->RemoveCreditCard(guid)) { |
715 NOTREACHED(); | 600 NOTREACHED(); |
716 return WebDatabase::COMMIT_NOT_NEEDED; | 601 return WebDatabase::COMMIT_NOT_NEEDED; |
717 } | 602 } |
718 return WebDatabase::COMMIT_NEEDED; | 603 return WebDatabase::COMMIT_NEEDED; |
719 } | 604 } |
720 | 605 |
721 scoped_ptr<WDTypedResult> WebDataService::GetCreditCardsImpl(WebDatabase* db) { | 606 scoped_ptr<WDTypedResult> WebDataService::GetCreditCardsImpl(WebDatabase* db) { |
722 std::vector<CreditCard*> credit_cards; | 607 std::vector<CreditCard*> credit_cards; |
723 db->GetAutofillTable()->GetCreditCards(&credit_cards); | 608 AutofillTable::FromWebDatabase(db)->GetCreditCards(&credit_cards); |
724 return scoped_ptr<WDTypedResult>( | 609 return scoped_ptr<WDTypedResult>( |
725 new WDDestroyableResult<std::vector<CreditCard*> >( | 610 new WDDestroyableResult<std::vector<CreditCard*> >( |
726 AUTOFILL_CREDITCARDS_RESULT, | 611 AUTOFILL_CREDITCARDS_RESULT, |
727 credit_cards, | 612 credit_cards, |
728 base::Bind(&WebDataService::DestroyAutofillCreditCardResult, | 613 base::Bind(&WebDataService::DestroyAutofillCreditCardResult, |
729 base::Unretained(this)))); | 614 base::Unretained(this)))); |
730 } | 615 } |
731 | 616 |
732 WebDatabase::State | 617 WebDatabase::State |
733 WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( | 618 WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( |
734 const base::Time& delete_begin, const base::Time& delete_end, | 619 const base::Time& delete_begin, const base::Time& delete_end, |
735 WebDatabase* db) { | 620 WebDatabase* db) { |
736 std::vector<std::string> profile_guids; | 621 std::vector<std::string> profile_guids; |
737 std::vector<std::string> credit_card_guids; | 622 std::vector<std::string> credit_card_guids; |
738 if (db->GetAutofillTable()-> | 623 if (AutofillTable::FromWebDatabase(db)-> |
739 RemoveAutofillProfilesAndCreditCardsModifiedBetween( | 624 RemoveAutofillProfilesAndCreditCardsModifiedBetween( |
740 delete_begin, | 625 delete_begin, |
741 delete_end, | 626 delete_end, |
742 &profile_guids, | 627 &profile_guids, |
743 &credit_card_guids)) { | 628 &credit_card_guids)) { |
744 for (std::vector<std::string>::iterator iter = profile_guids.begin(); | 629 for (std::vector<std::string>::iterator iter = profile_guids.begin(); |
745 iter != profile_guids.end(); ++iter) { | 630 iter != profile_guids.end(); ++iter) { |
746 AutofillProfileChange change(AutofillProfileChange::REMOVE, *iter, | 631 AutofillProfileChange change(AutofillProfileChange::REMOVE, *iter, |
747 NULL); | 632 NULL); |
748 content::NotificationService::current()->Notify( | 633 content::NotificationService::current()->Notify( |
749 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 634 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
750 content::Source<WebDataService>(this), | 635 content::Source<WebDataService>(this), |
751 content::Details<AutofillProfileChange>(&change)); | 636 content::Details<AutofillProfileChange>(&change)); |
752 } | 637 } |
753 // Note: It is the caller's responsibility to post notifications for any | 638 // Note: It is the caller's responsibility to post notifications for any |
754 // changes, e.g. by calling the Refresh() method of PersonalDataManager. | 639 // changes, e.g. by calling the Refresh() method of PersonalDataManager. |
755 return WebDatabase::COMMIT_NEEDED; | 640 return WebDatabase::COMMIT_NEEDED; |
756 } | 641 } |
757 return WebDatabase::COMMIT_NOT_NEEDED; | 642 return WebDatabase::COMMIT_NOT_NEEDED; |
758 } | 643 } |
759 | 644 |
760 AutofillProfileSyncableService* | |
761 WebDataService::GetAutofillProfileSyncableService() const { | |
762 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
763 DCHECK(autofill_profile_syncable_service_); // Make sure we're initialized. | |
764 | |
765 return autofill_profile_syncable_service_; | |
766 } | |
767 | |
768 AutocompleteSyncableService* WebDataService::GetAutocompleteSyncableService() | |
769 const { | |
770 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | |
771 DCHECK(autocomplete_syncable_service_); // Make sure we're initialized. | |
772 | |
773 return autocomplete_syncable_service_; | |
774 } | |
775 | |
776 void WebDataService::DestroyAutofillProfileResult(const WDTypedResult* result) { | 645 void WebDataService::DestroyAutofillProfileResult(const WDTypedResult* result) { |
777 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); | 646 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); |
778 const WDResult<std::vector<AutofillProfile*> >* r = | 647 const WDResult<std::vector<AutofillProfile*> >* r = |
779 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); | 648 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); |
780 std::vector<AutofillProfile*> profiles = r->GetValue(); | 649 std::vector<AutofillProfile*> profiles = r->GetValue(); |
781 STLDeleteElements(&profiles); | 650 STLDeleteElements(&profiles); |
782 } | 651 } |
783 | 652 |
784 void WebDataService::DestroyAutofillCreditCardResult( | 653 void WebDataService::DestroyAutofillCreditCardResult( |
785 const WDTypedResult* result) { | 654 const WDTypedResult* result) { |
786 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); | 655 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); |
787 const WDResult<std::vector<CreditCard*> >* r = | 656 const WDResult<std::vector<CreditCard*> >* r = |
788 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); | 657 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); |
789 | 658 |
790 std::vector<CreditCard*> credit_cards = r->GetValue(); | 659 std::vector<CreditCard*> credit_cards = r->GetValue(); |
791 STLDeleteElements(&credit_cards); | 660 STLDeleteElements(&credit_cards); |
792 } | 661 } |
OLD | NEW |