blob: 41be0978120d3d10ee43c046c670e3eddca6e7b3 [file] [log] [blame]
[email protected]4b7111f22013-06-18 14:22:121// 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.
4
5#include "apps/app_lifetime_monitor_factory.h"
6
7#include "apps/app_lifetime_monitor.h"
[email protected]12b7af32014-03-13 05:28:208#include "components/keyed_service/content/browser_context_dependency_manager.h"
michaelpg4d80e562017-04-04 01:48:149#include "content/public/browser/browser_context.h"
hashimotoad3c6872014-08-29 09:46:5710#include "extensions/browser/app_window/app_window_registry.h"
[email protected]175a74d2014-02-08 02:06:2011#include "extensions/browser/extensions_browser_client.h"
[email protected]4b7111f22013-06-18 14:22:1212
13namespace apps {
14
15// static
michaelpg4d80e562017-04-04 01:48:1416AppLifetimeMonitor* AppLifetimeMonitorFactory::GetForBrowserContext(
17 content::BrowserContext* context) {
[email protected]4b7111f22013-06-18 14:22:1218 return static_cast<AppLifetimeMonitor*>(
michaelpg4d80e562017-04-04 01:48:1419 GetInstance()->GetServiceForBrowserContext(context, false));
[email protected]4b7111f22013-06-18 14:22:1220}
21
22AppLifetimeMonitorFactory* AppLifetimeMonitorFactory::GetInstance() {
olli.raula36aa8be2015-09-10 11:14:2223 return base::Singleton<AppLifetimeMonitorFactory>::get();
[email protected]4b7111f22013-06-18 14:22:1224}
25
26AppLifetimeMonitorFactory::AppLifetimeMonitorFactory()
27 : BrowserContextKeyedServiceFactory(
28 "AppLifetimeMonitor",
29 BrowserContextDependencyManager::GetInstance()) {
hashimotoad3c6872014-08-29 09:46:5730 DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
[email protected]4b7111f22013-06-18 14:22:1231}
32
Chris Watkinsee8488b2017-11-27 04:06:5633AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() = default;
[email protected]4b7111f22013-06-18 14:22:1234
[email protected]12b7af32014-03-13 05:28:2035KeyedService* AppLifetimeMonitorFactory::BuildServiceInstanceFor(
michaelpg4d80e562017-04-04 01:48:1436 content::BrowserContext* context) const {
37 return new AppLifetimeMonitor(context);
[email protected]4b7111f22013-06-18 14:22:1238}
39
40bool AppLifetimeMonitorFactory::ServiceIsCreatedWithBrowserContext() const {
41 return true;
42}
43
44content::BrowserContext* AppLifetimeMonitorFactory::GetBrowserContextToUse(
45 content::BrowserContext* context) const {
[email protected]175a74d2014-02-08 02:06:2046 return extensions::ExtensionsBrowserClient::Get()->
47 GetOriginalContext(context);
[email protected]4b7111f22013-06-18 14:22:1248}
49
50} // namespace apps