[M120 Migration][XWalkExtension] Support IME in xwalk exension
[platform/framework/web/chromium-efl.git] / apps / app_lifetime_monitor_factory.cc
1 // Copyright 2013 The Chromium Authors
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/extension_host_registry.h"
12 #include "extensions/browser/extensions_browser_client.h"
13
14 namespace apps {
15
16 // static
17 AppLifetimeMonitor* AppLifetimeMonitorFactory::GetForBrowserContext(
18     content::BrowserContext* context) {
19   return static_cast<AppLifetimeMonitor*>(
20       GetInstance()->GetServiceForBrowserContext(context, false));
21 }
22
23 AppLifetimeMonitorFactory* AppLifetimeMonitorFactory::GetInstance() {
24   return base::Singleton<AppLifetimeMonitorFactory>::get();
25 }
26
27 AppLifetimeMonitorFactory::AppLifetimeMonitorFactory()
28     : BrowserContextKeyedServiceFactory(
29         "AppLifetimeMonitor",
30         BrowserContextDependencyManager::GetInstance()) {
31   DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
32   DependsOn(extensions::ExtensionHostRegistry::GetFactory());
33 }
34
35 AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() = default;
36
37 KeyedService* AppLifetimeMonitorFactory::BuildServiceInstanceFor(
38     content::BrowserContext* context) const {
39   return new AppLifetimeMonitor(context);
40 }
41
42 bool AppLifetimeMonitorFactory::ServiceIsCreatedWithBrowserContext() const {
43   return true;
44 }
45
46 content::BrowserContext* AppLifetimeMonitorFactory::GetBrowserContextToUse(
47     content::BrowserContext* context) const {
48   return extensions::ExtensionsBrowserClient::Get()
49       ->GetContextRedirectedToOriginal(context, /*force_guest_profile=*/true);
50 }
51
52 }  // namespace apps