blob: 03624a7b8a8a11ef68c18db9cc9ca0277fbfdaa2 [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]4b7111f22013-06-18 14:22:128#include "chrome/browser/profiles/profile.h"
[email protected]12b7af32014-03-13 05:28:209#include "components/keyed_service/content/browser_context_dependency_manager.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
16AppLifetimeMonitor* AppLifetimeMonitorFactory::GetForProfile(Profile* profile) {
17 return static_cast<AppLifetimeMonitor*>(
18 GetInstance()->GetServiceForBrowserContext(profile, false));
19}
20
21AppLifetimeMonitorFactory* AppLifetimeMonitorFactory::GetInstance() {
olli.raula36aa8be2015-09-10 11:14:2222 return base::Singleton<AppLifetimeMonitorFactory>::get();
[email protected]4b7111f22013-06-18 14:22:1223}
24
25AppLifetimeMonitorFactory::AppLifetimeMonitorFactory()
26 : BrowserContextKeyedServiceFactory(
27 "AppLifetimeMonitor",
28 BrowserContextDependencyManager::GetInstance()) {
hashimotoad3c6872014-08-29 09:46:5729 DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
[email protected]4b7111f22013-06-18 14:22:1230}
31
32AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() {}
33
[email protected]12b7af32014-03-13 05:28:2034KeyedService* AppLifetimeMonitorFactory::BuildServiceInstanceFor(
[email protected]4b7111f22013-06-18 14:22:1235 content::BrowserContext* profile) const {
36 return new AppLifetimeMonitor(static_cast<Profile*>(profile));
37}
38
39bool AppLifetimeMonitorFactory::ServiceIsCreatedWithBrowserContext() const {
40 return true;
41}
42
43content::BrowserContext* AppLifetimeMonitorFactory::GetBrowserContextToUse(
44 content::BrowserContext* context) const {
[email protected]175a74d2014-02-08 02:06:2045 return extensions::ExtensionsBrowserClient::Get()->
46 GetOriginalContext(context);
[email protected]4b7111f22013-06-18 14:22:1247}
48
49} // namespace apps