Upload upstream chromium 67.0.3396
[platform/framework/web/chromium-efl.git] / apps / app_lifetime_monitor_factory.cc
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"
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"
12
13 namespace apps {
14
15 // static
16 AppLifetimeMonitor* AppLifetimeMonitorFactory::GetForBrowserContext(
17     content::BrowserContext* context) {
18   return static_cast<AppLifetimeMonitor*>(
19       GetInstance()->GetServiceForBrowserContext(context, false));
20 }
21
22 AppLifetimeMonitorFactory* AppLifetimeMonitorFactory::GetInstance() {
23   return base::Singleton<AppLifetimeMonitorFactory>::get();
24 }
25
26 AppLifetimeMonitorFactory::AppLifetimeMonitorFactory()
27     : BrowserContextKeyedServiceFactory(
28         "AppLifetimeMonitor",
29         BrowserContextDependencyManager::GetInstance()) {
30   DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
31 }
32
33 AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() = default;
34
35 KeyedService* AppLifetimeMonitorFactory::BuildServiceInstanceFor(
36     content::BrowserContext* context) const {
37   return new AppLifetimeMonitor(context);
38 }
39
40 bool AppLifetimeMonitorFactory::ServiceIsCreatedWithBrowserContext() const {
41   return true;
42 }
43
44 content::BrowserContext* AppLifetimeMonitorFactory::GetBrowserContextToUse(
45     content::BrowserContext* context) const {
46   return extensions::ExtensionsBrowserClient::Get()->
47       GetOriginalContext(context);
48 }
49
50 }  // namespace apps