captive_portal_service_factory.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_CAPTIVE_PORTAL_SERVICE_FACTORY_H_
  5. #define WEBLAYER_BROWSER_CAPTIVE_PORTAL_SERVICE_FACTORY_H_
  6. #include "base/compiler_specific.h"
  7. #include "base/memory/singleton.h"
  8. #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
  9. namespace captive_portal {
  10. class CaptivePortalService;
  11. }
  12. namespace weblayer {
  13. // Singleton that owns all captive_portal::CaptivePortalServices and associates
  14. // them with BrowserContextImpl instances.
  15. class CaptivePortalServiceFactory : public BrowserContextKeyedServiceFactory {
  16. public:
  17. // Returns the captive_portal::CaptivePortalService for |browser_context|.
  18. static captive_portal::CaptivePortalService* GetForBrowserContext(
  19. content::BrowserContext* browser_context);
  20. static CaptivePortalServiceFactory* GetInstance();
  21. private:
  22. friend struct base::DefaultSingletonTraits<CaptivePortalServiceFactory>;
  23. CaptivePortalServiceFactory();
  24. ~CaptivePortalServiceFactory() override;
  25. CaptivePortalServiceFactory(const CaptivePortalServiceFactory&) = delete;
  26. CaptivePortalServiceFactory& operator=(const CaptivePortalServiceFactory&) =
  27. delete;
  28. // BrowserContextKeyedServiceFactory:
  29. KeyedService* BuildServiceInstanceFor(
  30. content::BrowserContext* profile) const override;
  31. // Incognito profiles have their own instance of
  32. // captive_portal::CaptivePortalService rather than the default behavior of
  33. // the service being null if the profile is incognito.
  34. content::BrowserContext* GetBrowserContextToUse(
  35. content::BrowserContext* context) const override;
  36. };
  37. } // namespace weblayer
  38. #endif // WEBLAYER_BROWSER_CAPTIVE_PORTAL_SERVICE_FACTORY_H_