[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 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. | ||||
4 | |||||
5 | #include "apps/app_lifetime_monitor_factory.h" | ||||
6 | |||||
7 | #include "apps/app_lifetime_monitor.h" | ||||
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 8 | #include "components/keyed_service/content/browser_context_dependency_manager.h" |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 9 | #include "content/public/browser/browser_context.h" |
hashimoto | ad3c687 | 2014-08-29 09:46:57 | [diff] [blame] | 10 | #include "extensions/browser/app_window/app_window_registry.h" |
[email protected] | 175a74d | 2014-02-08 02:06:20 | [diff] [blame] | 11 | #include "extensions/browser/extensions_browser_client.h" |
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 12 | |
13 | namespace apps { | ||||
14 | |||||
15 | // static | ||||
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 16 | AppLifetimeMonitor* AppLifetimeMonitorFactory::GetForBrowserContext( |
17 | content::BrowserContext* context) { | ||||
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 18 | return static_cast<AppLifetimeMonitor*>( |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 19 | GetInstance()->GetServiceForBrowserContext(context, false)); |
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 20 | } |
21 | |||||
22 | AppLifetimeMonitorFactory* AppLifetimeMonitorFactory::GetInstance() { | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 23 | return base::Singleton<AppLifetimeMonitorFactory>::get(); |
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 24 | } |
25 | |||||
26 | AppLifetimeMonitorFactory::AppLifetimeMonitorFactory() | ||||
27 | : BrowserContextKeyedServiceFactory( | ||||
28 | "AppLifetimeMonitor", | ||||
29 | BrowserContextDependencyManager::GetInstance()) { | ||||
hashimoto | ad3c687 | 2014-08-29 09:46:57 | [diff] [blame] | 30 | DependsOn(extensions::AppWindowRegistry::Factory::GetInstance()); |
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 31 | } |
32 | |||||
Chris Watkins | ee8488b | 2017-11-27 04:06:56 | [diff] [blame] | 33 | AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() = default; |
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 34 | |
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 35 | KeyedService* AppLifetimeMonitorFactory::BuildServiceInstanceFor( |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 36 | content::BrowserContext* context) const { |
37 | return new AppLifetimeMonitor(context); | ||||
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 38 | } |
39 | |||||
40 | bool AppLifetimeMonitorFactory::ServiceIsCreatedWithBrowserContext() const { | ||||
41 | return true; | ||||
42 | } | ||||
43 | |||||
44 | content::BrowserContext* AppLifetimeMonitorFactory::GetBrowserContextToUse( | ||||
45 | content::BrowserContext* context) const { | ||||
[email protected] | 175a74d | 2014-02-08 02:06:20 | [diff] [blame] | 46 | return extensions::ExtensionsBrowserClient::Get()-> |
47 | GetOriginalContext(context); | ||||
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 48 | } |
49 | |||||
50 | } // namespace apps |