aw_form_database_service.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2013 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. #ifndef ANDROID_WEBVIEW_BROWSER_AW_FORM_DATABASE_SERVICE_H_
  5. #define ANDROID_WEBVIEW_BROWSER_AW_FORM_DATABASE_SERVICE_H_
  6. #include "base/files/file_path.h"
  7. #include "base/synchronization/waitable_event.h"
  8. #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
  9. #include "components/webdata/common/web_data_service_consumer.h"
  10. #include "components/webdata/common/web_database_service.h"
  11. namespace android_webview {
  12. // Handles the database operations necessary to implement the autocomplete
  13. // functionality. This includes creating and initializing the components that
  14. // handle the database backend, and providing a synchronous interface when
  15. // needed (the chromium database components have an async. interface).
  16. class AwFormDatabaseService : public WebDataServiceConsumer {
  17. public:
  18. AwFormDatabaseService(const base::FilePath path);
  19. AwFormDatabaseService(const AwFormDatabaseService&) = delete;
  20. AwFormDatabaseService& operator=(const AwFormDatabaseService&) = delete;
  21. ~AwFormDatabaseService() override;
  22. void Shutdown();
  23. // Returns whether the database has any data stored. May do
  24. // IO access and block.
  25. bool HasFormData();
  26. // Clear any saved form data. Executes asynchronously.
  27. void ClearFormData();
  28. scoped_refptr<autofill::AutofillWebDataService>
  29. get_autofill_webdata_service();
  30. // WebDataServiceConsumer implementation.
  31. void OnWebDataServiceRequestDone(
  32. WebDataServiceBase::Handle h,
  33. std::unique_ptr<WDTypedResult> result) override;
  34. private:
  35. bool has_form_data_result_;
  36. base::WaitableEvent has_form_data_completion_;
  37. scoped_refptr<autofill::AutofillWebDataService> autofill_data_;
  38. scoped_refptr<WebDatabaseService> web_database_;
  39. };
  40. } // namespace android_webview
  41. #endif // ANDROID_WEBVIEW_BROWSER_AW_FORM_DATABASE_SERVICE_H_