captive_portal_service_factory.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #include "weblayer/browser/captive_portal_service_factory.h"
  5. #include "components/captive_portal/content/captive_portal_service.h"
  6. #include "components/keyed_service/content/browser_context_dependency_manager.h"
  7. #include "components/user_prefs/user_prefs.h"
  8. #include "content/public/browser/browser_context.h"
  9. namespace weblayer {
  10. // static
  11. captive_portal::CaptivePortalService*
  12. CaptivePortalServiceFactory::GetForBrowserContext(
  13. content::BrowserContext* browser_context) {
  14. return static_cast<captive_portal::CaptivePortalService*>(
  15. GetInstance()->GetServiceForBrowserContext(browser_context, true));
  16. }
  17. // static
  18. CaptivePortalServiceFactory* CaptivePortalServiceFactory::GetInstance() {
  19. return base::Singleton<CaptivePortalServiceFactory>::get();
  20. }
  21. CaptivePortalServiceFactory::CaptivePortalServiceFactory()
  22. : BrowserContextKeyedServiceFactory(
  23. "captive_portal::CaptivePortalService",
  24. BrowserContextDependencyManager::GetInstance()) {}
  25. CaptivePortalServiceFactory::~CaptivePortalServiceFactory() = default;
  26. KeyedService* CaptivePortalServiceFactory::BuildServiceInstanceFor(
  27. content::BrowserContext* browser_context) const {
  28. return new captive_portal::CaptivePortalService(
  29. browser_context, user_prefs::UserPrefs::Get(browser_context));
  30. }
  31. content::BrowserContext* CaptivePortalServiceFactory::GetBrowserContextToUse(
  32. content::BrowserContext* context) const {
  33. return context;
  34. }
  35. } // namespace weblayer