/ios/chrome/browser/webdata_services/web_data_service_factory.h

https://github.com/chromium/chromium · C Header · 79 lines · 50 code · 17 blank · 12 comment · 0 complexity · ffe516e57ef5bc45afeef5af094d6951 MD5 · raw file

  1. // Copyright 2015 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 IOS_CHROME_BROWSER_WEBDATA_SERVICES_WEB_DATA_SERVICE_FACTORY_H_
  5. #define IOS_CHROME_BROWSER_WEBDATA_SERVICES_WEB_DATA_SERVICE_FACTORY_H_
  6. #include <memory>
  7. #include "base/memory/ref_counted.h"
  8. #include "base/no_destructor.h"
  9. #include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
  10. class ChromeBrowserState;
  11. class KeywordWebDataService;
  12. class TokenWebData;
  13. class WebDataServiceWrapper;
  14. enum class ServiceAccessType;
  15. namespace autofill {
  16. class AutofillWebDataService;
  17. }
  18. namespace ios {
  19. // Singleton that owns all WebDataServiceWrappers and associates them with
  20. // ChromeBrowserState.
  21. class WebDataServiceFactory : public BrowserStateKeyedServiceFactory {
  22. public:
  23. // Returns the AutofillWebDataService associated with |browser_state|.
  24. static WebDataServiceWrapper* GetForBrowserState(
  25. ChromeBrowserState* browser_state,
  26. ServiceAccessType access_type);
  27. static WebDataServiceWrapper* GetForBrowserStateIfExists(
  28. ChromeBrowserState* browser_state,
  29. ServiceAccessType access_type);
  30. // Returns the AutofillWebDataService associated with |browser_state|.
  31. static scoped_refptr<autofill::AutofillWebDataService>
  32. GetAutofillWebDataForBrowserState(ChromeBrowserState* browser_state,
  33. ServiceAccessType access_type);
  34. // Returns the account-scoped AutofillWebDataService associated with the
  35. // |browser_state|.
  36. static scoped_refptr<autofill::AutofillWebDataService>
  37. GetAutofillWebDataForAccount(ChromeBrowserState* browser_state,
  38. ServiceAccessType access_type);
  39. // Returns the KeywordWebDataService associated with |browser_state|.
  40. static scoped_refptr<KeywordWebDataService> GetKeywordWebDataForBrowserState(
  41. ChromeBrowserState* browser_state,
  42. ServiceAccessType access_type);
  43. // Returns the TokenWebData associated with |browser_state|.
  44. static scoped_refptr<TokenWebData> GetTokenWebDataForBrowserState(
  45. ChromeBrowserState* browser_state,
  46. ServiceAccessType access_type);
  47. static WebDataServiceFactory* GetInstance();
  48. WebDataServiceFactory(const WebDataServiceFactory&) = delete;
  49. WebDataServiceFactory& operator=(const WebDataServiceFactory&) = delete;
  50. private:
  51. friend class base::NoDestructor<WebDataServiceFactory>;
  52. WebDataServiceFactory();
  53. ~WebDataServiceFactory() override;
  54. // BrowserStateKeyedServiceFactory implementation.
  55. std::unique_ptr<KeyedService> BuildServiceInstanceFor(
  56. web::BrowserState* context) const override;
  57. web::BrowserState* GetBrowserStateToUse(
  58. web::BrowserState* context) const override;
  59. bool ServiceIsNULLWhileTesting() const override;
  60. };
  61. } // namespace ios
  62. #endif // IOS_CHROME_BROWSER_WEBDATA_SERVICES_WEB_DATA_SERVICE_FACTORY_H_