1 // Copyright 2013 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.
5 #include "apps/app_lifetime_monitor_factory.h"
7 #include "apps/app_lifetime_monitor.h"
8 #include "components/keyed_service/content/browser_context_dependency_manager.h"
9 #include "content/public/browser/browser_context.h"
10 #include "extensions/browser/app_window/app_window_registry.h"
11 #include "extensions/browser/extensions_browser_client.h"
16 AppLifetimeMonitor* AppLifetimeMonitorFactory::GetForBrowserContext(
17 content::BrowserContext* context) {
18 return static_cast<AppLifetimeMonitor*>(
19 GetInstance()->GetServiceForBrowserContext(context, false));
22 AppLifetimeMonitorFactory* AppLifetimeMonitorFactory::GetInstance() {
23 return base::Singleton<AppLifetimeMonitorFactory>::get();
26 AppLifetimeMonitorFactory::AppLifetimeMonitorFactory()
27 : BrowserContextKeyedServiceFactory(
29 BrowserContextDependencyManager::GetInstance()) {
30 DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
33 AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() = default;
35 KeyedService* AppLifetimeMonitorFactory::BuildServiceInstanceFor(
36 content::BrowserContext* context) const {
37 return new AppLifetimeMonitor(context);
40 bool AppLifetimeMonitorFactory::ServiceIsCreatedWithBrowserContext() const {
44 content::BrowserContext* AppLifetimeMonitorFactory::GetBrowserContextToUse(
45 content::BrowserContext* context) const {
46 return extensions::ExtensionsBrowserClient::Get()->
47 GetOriginalContext(context);