heavy_ad_service_factory.cc 1.4 KB

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