help_app_manager_factory.cc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 "ash/webui/help_app_ui/help_app_manager_factory.h"
  5. #include "ash/webui/help_app_ui/help_app_manager.h"
  6. #include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy_factory.h"
  7. #include "components/keyed_service/content/browser_context_dependency_manager.h"
  8. namespace ash {
  9. namespace help_app {
  10. // static
  11. HelpAppManager* HelpAppManagerFactory::GetForBrowserContext(
  12. content::BrowserContext* context) {
  13. return static_cast<HelpAppManager*>(
  14. HelpAppManagerFactory::GetInstance()->GetServiceForBrowserContext(
  15. context, /*create=*/true));
  16. }
  17. // static
  18. HelpAppManagerFactory* HelpAppManagerFactory::GetInstance() {
  19. return base::Singleton<HelpAppManagerFactory>::get();
  20. }
  21. HelpAppManagerFactory::HelpAppManagerFactory()
  22. : BrowserContextKeyedServiceFactory(
  23. "HelpAppManager",
  24. BrowserContextDependencyManager::GetInstance()) {
  25. DependsOn(
  26. local_search_service::LocalSearchServiceProxyFactory::GetInstance());
  27. }
  28. HelpAppManagerFactory::~HelpAppManagerFactory() = default;
  29. content::BrowserContext* HelpAppManagerFactory::GetBrowserContextToUse(
  30. content::BrowserContext* context) const {
  31. // The service should exist in incognito mode.
  32. return context;
  33. }
  34. KeyedService* HelpAppManagerFactory::BuildServiceInstanceFor(
  35. content::BrowserContext* context) const {
  36. return new HelpAppManager(
  37. local_search_service::LocalSearchServiceProxyFactory::
  38. GetForBrowserContext(context));
  39. }
  40. bool HelpAppManagerFactory::ServiceIsNULLWhileTesting() const {
  41. return true;
  42. }
  43. } // namespace help_app
  44. } // namespace ash