shell_extension_system_factory.cc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2014 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 "extensions/shell/browser/shell_extension_system_factory.h"
  5. #include "apps/app_lifetime_monitor_factory.h"
  6. #include "components/keyed_service/content/browser_context_dependency_manager.h"
  7. #include "extensions/browser/extension_prefs_factory.h"
  8. #include "extensions/browser/extension_registry_factory.h"
  9. #include "extensions/shell/browser/shell_extension_system.h"
  10. using content::BrowserContext;
  11. namespace extensions {
  12. ExtensionSystem* ShellExtensionSystemFactory::GetForBrowserContext(
  13. BrowserContext* context) {
  14. return static_cast<ShellExtensionSystem*>(
  15. GetInstance()->GetServiceForBrowserContext(context, true));
  16. }
  17. // static
  18. ShellExtensionSystemFactory* ShellExtensionSystemFactory::GetInstance() {
  19. return base::Singleton<ShellExtensionSystemFactory>::get();
  20. }
  21. ShellExtensionSystemFactory::ShellExtensionSystemFactory()
  22. : ExtensionSystemProvider("ShellExtensionSystem",
  23. BrowserContextDependencyManager::GetInstance()) {
  24. DependsOn(ExtensionPrefsFactory::GetInstance());
  25. DependsOn(ExtensionRegistryFactory::GetInstance());
  26. DependsOn(apps::AppLifetimeMonitorFactory::GetInstance());
  27. }
  28. ShellExtensionSystemFactory::~ShellExtensionSystemFactory() {
  29. }
  30. KeyedService* ShellExtensionSystemFactory::BuildServiceInstanceFor(
  31. BrowserContext* context) const {
  32. return new ShellExtensionSystem(context);
  33. }
  34. BrowserContext* ShellExtensionSystemFactory::GetBrowserContextToUse(
  35. BrowserContext* context) const {
  36. // Use a separate instance for incognito.
  37. return context;
  38. }
  39. bool ShellExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {
  40. return true;
  41. }
  42. } // namespace extensions