client_side_detection_service_factory.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2020 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 WEBLAYER_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_FACTORY_H_
  5. #define WEBLAYER_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_FACTORY_H_
  6. #include "base/no_destructor.h"
  7. #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
  8. class KeyedService;
  9. namespace content {
  10. class BrowserContext;
  11. }
  12. namespace safe_browsing {
  13. class ClientSideDetectionService;
  14. }
  15. namespace weblayer {
  16. // Singleton that owns ClientSideDetectionServiceFactory objects and associates
  17. // them them with BrowserContextImpl instances.
  18. class ClientSideDetectionServiceFactory
  19. : public BrowserContextKeyedServiceFactory {
  20. public:
  21. ClientSideDetectionServiceFactory(const ClientSideDetectionServiceFactory&) =
  22. delete;
  23. ClientSideDetectionServiceFactory& operator=(
  24. const ClientSideDetectionServiceFactory&) = delete;
  25. // Creates the service if it doesn't exist already for the given
  26. // |browser_context|. If the service already exists, return its pointer.
  27. static safe_browsing::ClientSideDetectionService* GetForBrowserContext(
  28. content::BrowserContext* browser_context);
  29. // Get the singleton instance.
  30. static ClientSideDetectionServiceFactory* GetInstance();
  31. private:
  32. friend class base::NoDestructor<ClientSideDetectionServiceFactory>;
  33. ClientSideDetectionServiceFactory();
  34. ~ClientSideDetectionServiceFactory() override;
  35. // BrowserContextKeyedServiceFactory:
  36. KeyedService* BuildServiceInstanceFor(
  37. content::BrowserContext* context) const override;
  38. content::BrowserContext* GetBrowserContextToUse(
  39. content::BrowserContext* context) const override;
  40. };
  41. } // namespace weblayer
  42. #endif // WEBLAYER_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_FACTORY_H_