diff options
author | jackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-06 13:38:37 +0000 |
---|---|---|
committer | jackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-06 13:38:37 +0000 |
commit | d54b3f490de80c708e335714872e44eba322342b (patch) | |
tree | 08b3bb2e4312da05091229947ca82b1e1655c94f /apps/app_lifetime_monitor_factory.cc | |
parent | e34d51130d3026bf2fb6501264b1c761cfa48a18 (diff) | |
download | chromium_src-d54b3f490de80c708e335714872e44eba322342b.zip chromium_src-d54b3f490de80c708e335714872e44eba322342b.tar.gz chromium_src-d54b3f490de80c708e335714872e44eba322342b.tar.bz2 |
Factor out AppLifetimeMonitor.
AppLifetimeMonitor listens to extension host notifications and observes
ShellWindowRegistry. It sends out notifications when:
- an app starts
- the first shell window opens
- the last shell window closes
- the app stops
BUG=
Review URL: https://chromiumcodereview.appspot.com/16412002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps/app_lifetime_monitor_factory.cc')
-rw-r--r-- | apps/app_lifetime_monitor_factory.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/apps/app_lifetime_monitor_factory.cc b/apps/app_lifetime_monitor_factory.cc new file mode 100644 index 0000000..66cfdf4 --- /dev/null +++ b/apps/app_lifetime_monitor_factory.cc @@ -0,0 +1,48 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "apps/app_lifetime_monitor_factory.h" + +#include "apps/app_lifetime_monitor.h" +#include "chrome/browser/extensions/shell_window_registry.h" +#include "chrome/browser/profiles/incognito_helpers.h" +#include "chrome/browser/profiles/profile.h" +#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" + +namespace apps { + +// static +AppLifetimeMonitor* AppLifetimeMonitorFactory::GetForProfile(Profile* profile) { + return static_cast<AppLifetimeMonitor*>( + GetInstance()->GetServiceForBrowserContext(profile, true)); +} + +AppLifetimeMonitorFactory* AppLifetimeMonitorFactory::GetInstance() { + return Singleton<AppLifetimeMonitorFactory>::get(); +} + +AppLifetimeMonitorFactory::AppLifetimeMonitorFactory() + : BrowserContextKeyedServiceFactory( + "AppLifetimeMonitor", + BrowserContextDependencyManager::GetInstance()) { + DependsOn(extensions::ShellWindowRegistry::Factory::GetInstance()); +} + +AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() {} + +BrowserContextKeyedService* AppLifetimeMonitorFactory::BuildServiceInstanceFor( + content::BrowserContext* profile) const { + return new AppLifetimeMonitor(static_cast<Profile*>(profile)); +} + +bool AppLifetimeMonitorFactory::ServiceIsCreatedWithBrowserContext() const { + return false; +} + +content::BrowserContext* AppLifetimeMonitorFactory::GetBrowserContextToUse( + content::BrowserContext* context) const { + return chrome::GetBrowserContextRedirectedInIncognito(context); +} + +} // namespace apps |