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 // Chromium settings and storage represent user-selected preferences and | 5 // Chromium settings and storage represent user-selected preferences and |
6 // information and MUST not be extracted, overwritten or modified except | 6 // information and MUST not be extracted, overwritten or modified except |
7 // through Chromium defined APIs. | 7 // through Chromium defined APIs. |
8 | 8 |
9 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | 9 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ |
10 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | 10 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 | 64 |
65 //////////////////////////////////////////////////////////////////////////////// | 65 //////////////////////////////////////////////////////////////////////////////// |
66 // | 66 // |
67 // WebDataService results | 67 // WebDataService results |
68 // | 68 // |
69 //////////////////////////////////////////////////////////////////////////////// | 69 //////////////////////////////////////////////////////////////////////////////// |
70 | 70 |
71 typedef std::vector<AutofillChange> AutofillChangeList; | 71 typedef std::vector<AutofillChange> AutofillChangeList; |
72 | 72 |
| 73 typedef base::Callback<scoped_ptr<WDTypedResult>(void)> ResultTask; |
| 74 |
73 // Result from GetWebAppImages. | 75 // Result from GetWebAppImages. |
74 struct WDAppImagesResult { | 76 struct WDAppImagesResult { |
75 WDAppImagesResult(); | 77 WDAppImagesResult(); |
76 ~WDAppImagesResult(); | 78 ~WDAppImagesResult(); |
77 | 79 |
78 // True if SetWebAppHasAllImages(true) was invoked. | 80 // True if SetWebAppHasAllImages(true) was invoked. |
79 bool has_all_images; | 81 bool has_all_images; |
80 | 82 |
81 // The images, may be empty. | 83 // The images, may be empty. |
82 std::vector<SkBitmap> images; | 84 std::vector<SkBitmap> images; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 ////////////////////////////////////////////////////////////////////////////// | 333 ////////////////////////////////////////////////////////////////////////////// |
332 // | 334 // |
333 // The following methods are only invoked in the web data service thread. | 335 // The following methods are only invoked in the web data service thread. |
334 // | 336 // |
335 ////////////////////////////////////////////////////////////////////////////// | 337 ////////////////////////////////////////////////////////////////////////////// |
336 private: | 338 private: |
337 friend struct content::BrowserThread::DeleteOnThread< | 339 friend struct content::BrowserThread::DeleteOnThread< |
338 content::BrowserThread::UI>; | 340 content::BrowserThread::UI>; |
339 friend class base::DeleteHelper<WebDataService>; | 341 friend class base::DeleteHelper<WebDataService>; |
340 | 342 |
341 typedef GenericRequest2<std::vector<const TemplateURLData*>, | |
342 KeywordTable::Keywords> SetKeywordsRequest; | |
343 | |
344 // Invoked on the main thread if initializing the db fails. | 343 // Invoked on the main thread if initializing the db fails. |
345 void DBInitFailed(sql::InitStatus init_status); | 344 void DBInitFailed(sql::InitStatus init_status); |
346 | 345 |
347 // Initialize the database, if it hasn't already been initialized. | 346 // Initialize the database, if it hasn't already been initialized. |
348 void InitializeDatabaseIfNecessary(); | 347 void InitializeDatabaseIfNecessary(); |
349 | 348 |
350 // Initialize any syncable services. | 349 // Initialize any syncable services. |
351 void InitializeSyncableServices(); | 350 void InitializeSyncableServices(); |
352 | 351 |
353 // The notification method. | 352 // The notification method. |
354 void NotifyDatabaseLoadedOnUIThread(); | 353 void NotifyDatabaseLoadedOnUIThread(); |
355 | 354 |
356 // Commit any pending transaction and deletes the database. | 355 // Commit any pending transaction and deletes the database. |
357 void ShutdownDatabase(); | 356 void ShutdownDatabase(); |
358 | 357 |
359 // Deletes the syncable services. | 358 // Deletes the syncable services. |
360 void ShutdownSyncableServices(); | 359 void ShutdownSyncableServices(); |
361 | 360 |
362 // Commit the current transaction and creates a new one. | 361 // Commit the current transaction and creates a new one. |
363 void Commit(); | 362 void Commit(); |
364 | 363 |
365 // Schedule a task on our worker thread. | 364 // Schedule a task on our worker thread. |
366 void ScheduleTask(const tracked_objects::Location& from_here, | 365 void ScheduleTask(const tracked_objects::Location& from_here, |
367 const base::Closure& task); | 366 const base::Closure& task); |
368 | 367 |
| 368 void ScheduleDBTask(const tracked_objects::Location& from_here, |
| 369 const base::Closure& task); |
| 370 |
| 371 WebDataService::Handle ScheduleDBTaskWithResult( |
| 372 const tracked_objects::Location& from_here, |
| 373 const ResultTask& task, |
| 374 WebDataServiceConsumer* consumer); |
| 375 |
| 376 void DBTaskWrapper(const base::Closure& task, |
| 377 WebDataRequest* request); |
| 378 |
| 379 void DBResultTaskWrapper(const ResultTask& task, |
| 380 WebDataRequest* request); |
| 381 |
369 // Schedule a commit if one is not already pending. | 382 // Schedule a commit if one is not already pending. |
370 void ScheduleCommit(); | 383 void ScheduleCommit(); |
371 | 384 |
372 ////////////////////////////////////////////////////////////////////////////// | 385 ////////////////////////////////////////////////////////////////////////////// |
373 // | 386 // |
374 // Keywords. | 387 // Keywords. |
375 // | 388 // |
376 ////////////////////////////////////////////////////////////////////////////// | 389 ////////////////////////////////////////////////////////////////////////////// |
377 void AddKeywordImpl(GenericRequest<TemplateURLData>* request); | 390 void AddKeywordImpl(const TemplateURLData& data); |
378 void RemoveKeywordImpl(GenericRequest<TemplateURLID>* request); | 391 void RemoveKeywordImpl(TemplateURLID id); |
379 void UpdateKeywordImpl(GenericRequest<TemplateURLData>* request); | 392 void UpdateKeywordImpl(const TemplateURLData& data); |
380 void GetKeywordsImpl(WebDataRequest* request); | 393 scoped_ptr<WDTypedResult> GetKeywordsImpl(); |
381 void SetDefaultSearchProviderImpl(GenericRequest<TemplateURLID>* r); | 394 void SetDefaultSearchProviderImpl(TemplateURLID r); |
382 void SetBuiltinKeywordVersionImpl(GenericRequest<int>* r); | 395 void SetBuiltinKeywordVersionImpl(int version); |
383 | 396 |
384 ////////////////////////////////////////////////////////////////////////////// | 397 ////////////////////////////////////////////////////////////////////////////// |
385 // | 398 // |
386 // Web Apps. | 399 // Web Apps. |
387 // | 400 // |
388 ////////////////////////////////////////////////////////////////////////////// | 401 ////////////////////////////////////////////////////////////////////////////// |
389 void SetWebAppImageImpl(GenericRequest2<GURL, SkBitmap>* request); | 402 |
390 void SetWebAppHasAllImagesImpl(GenericRequest2<GURL, bool>* request); | 403 void SetWebAppImageImpl(const GURL& app_url, const SkBitmap& image); |
391 void RemoveWebAppImpl(GenericRequest<GURL>* request); | 404 void SetWebAppHasAllImagesImpl(const GURL& app_url, bool has_all_images); |
392 void GetWebAppImagesImpl(GenericRequest<GURL>* request); | 405 void RemoveWebAppImpl(const GURL& app_url); |
| 406 scoped_ptr<WDTypedResult> GetWebAppImagesImpl(const GURL& app_url); |
393 | 407 |
394 ////////////////////////////////////////////////////////////////////////////// | 408 ////////////////////////////////////////////////////////////////////////////// |
395 // | 409 // |
396 // Web Intents. | 410 // Web Intents. |
397 // | 411 // |
398 ////////////////////////////////////////////////////////////////////////////// | 412 ////////////////////////////////////////////////////////////////////////////// |
399 void AddWebIntentServiceImpl( | 413 void AddWebIntentServiceImpl( |
400 GenericRequest<webkit_glue::WebIntentServiceData>* request); | 414 const webkit_glue::WebIntentServiceData& service); |
401 void RemoveWebIntentServiceImpl( | 415 void RemoveWebIntentServiceImpl( |
402 GenericRequest<webkit_glue::WebIntentServiceData>* request); | 416 const webkit_glue::WebIntentServiceData& service); |
403 void GetWebIntentServicesImpl(GenericRequest<string16>* request); | 417 scoped_ptr<WDTypedResult> GetWebIntentServicesImpl(const string16& action); |
404 void GetWebIntentServicesForURLImpl(GenericRequest<string16>* request); | 418 scoped_ptr<WDTypedResult> GetWebIntentServicesForURLImpl( |
405 void GetAllWebIntentServicesImpl(GenericRequest<std::string>* request); | 419 const string16& service_url); |
406 void AddDefaultWebIntentServiceImpl( | 420 scoped_ptr<WDTypedResult> GetAllWebIntentServicesImpl(); |
407 GenericRequest<DefaultWebIntentService>* request); | 421 void AddDefaultWebIntentServiceImpl(const DefaultWebIntentService& service); |
408 void RemoveDefaultWebIntentServiceImpl( | 422 void RemoveDefaultWebIntentServiceImpl( |
409 GenericRequest<DefaultWebIntentService>* request); | 423 const DefaultWebIntentService& service); |
410 void RemoveWebIntentServiceDefaultsImpl(GenericRequest<GURL>* request); | 424 void RemoveWebIntentServiceDefaultsImpl(const GURL& service_url); |
411 void GetDefaultWebIntentServicesForActionImpl( | 425 scoped_ptr<WDTypedResult> GetDefaultWebIntentServicesForActionImpl( |
412 GenericRequest<string16>* request); | 426 const string16& action); |
413 void GetAllDefaultWebIntentServicesImpl(GenericRequest<std::string>* request); | 427 scoped_ptr<WDTypedResult> GetAllDefaultWebIntentServicesImpl(); |
414 | 428 |
415 ////////////////////////////////////////////////////////////////////////////// | 429 ////////////////////////////////////////////////////////////////////////////// |
416 // | 430 // |
417 // Token Service. | 431 // Token Service. |
418 // | 432 // |
419 ////////////////////////////////////////////////////////////////////////////// | 433 ////////////////////////////////////////////////////////////////////////////// |
420 | 434 |
421 void RemoveAllTokensImpl(GenericRequest<std::string>* request); | 435 void RemoveAllTokensImpl(); |
422 void SetTokenForServiceImpl( | 436 void SetTokenForServiceImpl(const std::string& service, |
423 GenericRequest2<std::string, std::string>* request); | 437 const std::string& token); |
424 void GetAllTokensImpl(GenericRequest<std::string>* request); | 438 scoped_ptr<WDTypedResult> GetAllTokensImpl(); |
425 | 439 |
426 #if defined(OS_WIN) | 440 #if defined(OS_WIN) |
427 ////////////////////////////////////////////////////////////////////////////// | 441 ////////////////////////////////////////////////////////////////////////////// |
428 // | 442 // |
429 // Password manager. | 443 // Password manager. |
430 // | 444 // |
431 ////////////////////////////////////////////////////////////////////////////// | 445 ////////////////////////////////////////////////////////////////////////////// |
432 void AddIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); | 446 void AddIE7LoginImpl(const IE7PasswordInfo& info); |
433 void RemoveIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); | 447 void RemoveIE7LoginImpl(const IE7PasswordInfo& info); |
434 void GetIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); | 448 scoped_ptr<WDTypedResult> GetIE7LoginImpl(const IE7PasswordInfo& info); |
435 #endif // defined(OS_WIN) | 449 #endif // defined(OS_WIN) |
436 | 450 |
437 ////////////////////////////////////////////////////////////////////////////// | 451 ////////////////////////////////////////////////////////////////////////////// |
438 // | 452 // |
439 // Autofill. | 453 // Autofill. |
440 // | 454 // |
441 ////////////////////////////////////////////////////////////////////////////// | 455 ////////////////////////////////////////////////////////////////////////////// |
442 void AddFormElementsImpl( | 456 void AddFormElementsImpl(const std::vector<FormFieldData>& fields); |
443 GenericRequest<std::vector<FormFieldData> >* request); | 457 scoped_ptr<WDTypedResult> GetFormValuesForElementNameImpl( |
444 void GetFormValuesForElementNameImpl(WebDataRequest* request, | |
445 const string16& name, const string16& prefix, int limit); | 458 const string16& name, const string16& prefix, int limit); |
446 void RemoveFormElementsAddedBetweenImpl( | 459 void RemoveFormElementsAddedBetweenImpl( |
447 GenericRequest2<base::Time, base::Time>* request); | 460 const base::Time& delete_begin, const base::Time& delete_end); |
448 void RemoveExpiredFormElementsImpl(WebDataRequest* request); | 461 void RemoveExpiredFormElementsImpl(); |
449 void RemoveFormValueForElementNameImpl( | 462 void RemoveFormValueForElementNameImpl(const string16& name, |
450 GenericRequest2<string16, string16>* request); | 463 const string16& value); |
451 void AddAutofillProfileImpl(GenericRequest<AutofillProfile>* request); | 464 void AddAutofillProfileImpl(const AutofillProfile& profile); |
452 void UpdateAutofillProfileImpl(GenericRequest<AutofillProfile>* request); | 465 void UpdateAutofillProfileImpl(const AutofillProfile& profile); |
453 void RemoveAutofillProfileImpl(GenericRequest<std::string>* request); | 466 void RemoveAutofillProfileImpl(const std::string& guid); |
454 void GetAutofillProfilesImpl(WebDataRequest* request); | 467 scoped_ptr<WDTypedResult> GetAutofillProfilesImpl(); |
455 void EmptyMigrationTrashImpl(GenericRequest<bool>* request); | 468 void EmptyMigrationTrashImpl(bool notify_sync); |
456 void AddCreditCardImpl(GenericRequest<CreditCard>* request); | 469 void AddCreditCardImpl(const CreditCard& credit_card); |
457 void UpdateCreditCardImpl(GenericRequest<CreditCard>* request); | 470 void UpdateCreditCardImpl(const CreditCard& credit_card); |
458 void RemoveCreditCardImpl(GenericRequest<std::string>* request); | 471 void RemoveCreditCardImpl(const std::string& guid); |
459 void GetCreditCardsImpl(WebDataRequest* request); | 472 scoped_ptr<WDTypedResult> GetCreditCardsImpl(); |
460 void RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( | 473 void RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( |
461 GenericRequest2<base::Time, base::Time>* request); | 474 const base::Time& delete_begin, const base::Time& delete_end); |
462 | 475 |
463 // Callbacks to ensure that sensitive info is destroyed if request is | 476 // Callbacks to ensure that sensitive info is destroyed if request is |
464 // cancelled. | 477 // cancelled. |
465 void DestroyAutofillProfileResult(const WDTypedResult* result); | 478 void DestroyAutofillProfileResult(const WDTypedResult* result); |
466 void DestroyAutofillCreditCardResult(const WDTypedResult* result); | 479 void DestroyAutofillCreditCardResult(const WDTypedResult* result); |
467 | 480 |
468 // True once initialization has started. | 481 // True once initialization has started. |
469 bool is_running_; | 482 bool is_running_; |
470 | 483 |
471 // The path with which to initialize the database. | 484 // The path with which to initialize the database. |
(...skipping 26 matching lines...) Expand all Loading... |
498 // Whether we should commit the database. | 511 // Whether we should commit the database. |
499 bool should_commit_; | 512 bool should_commit_; |
500 | 513 |
501 // MessageLoop the WebDataService is created on. | 514 // MessageLoop the WebDataService is created on. |
502 MessageLoop* main_loop_; | 515 MessageLoop* main_loop_; |
503 | 516 |
504 DISALLOW_COPY_AND_ASSIGN(WebDataService); | 517 DISALLOW_COPY_AND_ASSIGN(WebDataService); |
505 }; | 518 }; |
506 | 519 |
507 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | 520 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ |
OLD | NEW |