safe_browsing_navigation_observer_manager_factory.cc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2021 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/safe_browsing/safe_browsing_navigation_observer_manager_factory.h"
  5. #include "base/no_destructor.h"
  6. #include "components/keyed_service/content/browser_context_dependency_manager.h"
  7. #include "components/safe_browsing/content/browser/safe_browsing_navigation_observer_manager.h"
  8. #include "weblayer/browser/browser_context_impl.h"
  9. namespace weblayer {
  10. // static
  11. safe_browsing::SafeBrowsingNavigationObserverManager*
  12. SafeBrowsingNavigationObserverManagerFactory::GetForBrowserContext(
  13. content::BrowserContext* browser_context) {
  14. return static_cast<safe_browsing::SafeBrowsingNavigationObserverManager*>(
  15. GetInstance()->GetServiceForBrowserContext(browser_context,
  16. /*create=*/true));
  17. }
  18. // static
  19. SafeBrowsingNavigationObserverManagerFactory*
  20. SafeBrowsingNavigationObserverManagerFactory::GetInstance() {
  21. static base::NoDestructor<SafeBrowsingNavigationObserverManagerFactory>
  22. factory;
  23. return factory.get();
  24. }
  25. SafeBrowsingNavigationObserverManagerFactory::
  26. SafeBrowsingNavigationObserverManagerFactory()
  27. : BrowserContextKeyedServiceFactory(
  28. "SafeBrowsingNavigationObserverManager",
  29. BrowserContextDependencyManager::GetInstance()) {}
  30. KeyedService*
  31. SafeBrowsingNavigationObserverManagerFactory::BuildServiceInstanceFor(
  32. content::BrowserContext* context) const {
  33. BrowserContextImpl* context_impl = static_cast<BrowserContextImpl*>(context);
  34. return new safe_browsing::SafeBrowsingNavigationObserverManager(
  35. context_impl->pref_service());
  36. }
  37. content::BrowserContext*
  38. SafeBrowsingNavigationObserverManagerFactory::GetBrowserContextToUse(
  39. content::BrowserContext* context) const {
  40. return context;
  41. }
  42. } // namespace weblayer