From d54b3f490de80c708e335714872e44eba322342b Mon Sep 17 00:00:00 2001 From: "jackhou@chromium.org" Date: Thu, 6 Jun 2013 13:38:37 +0000 Subject: 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 --- apps/app_restore_service.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'apps/app_restore_service.h') diff --git a/apps/app_restore_service.h b/apps/app_restore_service.h index 65d3de2..d4e605f 100644 --- a/apps/app_restore_service.h +++ b/apps/app_restore_service.h @@ -8,6 +8,7 @@ #include #include +#include "apps/app_lifetime_monitor.h" #include "chrome/browser/extensions/shell_window_registry.h" #include "components/browser_context_keyed_service/browser_context_keyed_service.h" #include "content/public/browser/notification_observer.h" @@ -24,7 +25,7 @@ namespace apps { // Tracks what apps need to be restarted when the browser restarts. class AppRestoreService : public BrowserContextKeyedService, public content::NotificationObserver, - public extensions::ShellWindowRegistry::Observer { + public AppLifetimeMonitor::Observer { public: // Returns true if apps should be restored on the current platform, given // whether this new browser process launched due to a restart. @@ -42,22 +43,25 @@ class AppRestoreService : public BrowserContextKeyedService, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; - // extensions::ShellWindowRegistry::Observer. - virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE; - virtual void OnShellWindowIconChanged(ShellWindow* shell_window) OVERRIDE; - virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE; + // AppLifetimeMonitor::Observer. + virtual void OnAppStart(Profile* profile, const std::string& app_id) OVERRIDE; + virtual void OnAppActivated(Profile* profile, + const std::string& app_id) OVERRIDE; + virtual void OnAppDeactivated(Profile* profile, + const std::string& app_id) OVERRIDE; + virtual void OnAppStop(Profile* profile, const std::string& app_id) OVERRIDE; // BrowserContextKeyedService. virtual void Shutdown() OVERRIDE; void RecordAppStart(const std::string& extension_id); void RecordAppStop(const std::string& extension_id); - void RecordIfAppHasWindows(const std::string& id); + void RecordAppActiveState(const std::string& id, bool is_active); void RestoreApp(const extensions::Extension* extension); - void StartObservingShellWindows(); - void StopObservingShellWindows(); + void StartObservingAppLifetime(); + void StopObservingAppLifetime(); content::NotificationRegistrar registrar_; Profile* profile_; -- cgit v1.1