| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef APPS_APP_LIFETIME_MONITOR_H_ | 5 #ifndef APPS_APP_LIFETIME_MONITOR_H_ |
| 6 #define APPS_APP_LIFETIME_MONITOR_H_ | 6 #define APPS_APP_LIFETIME_MONITOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 virtual void OnAppStart(Profile* profile, const std::string& app_id) {} | 30 virtual void OnAppStart(Profile* profile, const std::string& app_id) {} |
| 31 // Called when the app becomes active to the user, i.e. the first window | 31 // Called when the app becomes active to the user, i.e. the first window |
| 32 // becomes visible. | 32 // becomes visible. |
| 33 virtual void OnAppActivated(Profile* profile, const std::string& app_id) {} | 33 virtual void OnAppActivated(Profile* profile, const std::string& app_id) {} |
| 34 // Called when the app becomes inactive to the user, i.e. the last window is | 34 // Called when the app becomes inactive to the user, i.e. the last window is |
| 35 // hidden or closed. | 35 // hidden or closed. |
| 36 virtual void OnAppDeactivated(Profile* profile, const std::string& app_id) { | 36 virtual void OnAppDeactivated(Profile* profile, const std::string& app_id) { |
| 37 } | 37 } |
| 38 // Called when the app stops running. | 38 // Called when the app stops running. |
| 39 virtual void OnAppStop(Profile* profile, const std::string& app_id) {} | 39 virtual void OnAppStop(Profile* profile, const std::string& app_id) {} |
| 40 // Called when chrome is about to terminate. This gives observers a chance | |
| 41 // to do something before the apps shut down. This is a system-wide event | |
| 42 // so there is no associated profile and app id. | |
| 43 virtual void OnChromeTerminating() {} | |
| 44 | 40 |
| 45 protected: | 41 protected: |
| 46 virtual ~Observer() {} | 42 virtual ~Observer() {} |
| 47 }; | 43 }; |
| 48 | 44 |
| 49 explicit AppLifetimeMonitor(Profile* profile); | 45 explicit AppLifetimeMonitor(Profile* profile); |
| 50 ~AppLifetimeMonitor() override; | 46 ~AppLifetimeMonitor() override; |
| 51 | 47 |
| 52 void AddObserver(Observer* observer); | 48 void AddObserver(Observer* observer); |
| 53 void RemoveObserver(Observer* observer); | 49 void RemoveObserver(Observer* observer); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 66 | 62 |
| 67 // KeyedService overrides: | 63 // KeyedService overrides: |
| 68 void Shutdown() override; | 64 void Shutdown() override; |
| 69 | 65 |
| 70 bool HasOtherVisibleAppWindows(extensions::AppWindow* app_window) const; | 66 bool HasOtherVisibleAppWindows(extensions::AppWindow* app_window) const; |
| 71 | 67 |
| 72 void NotifyAppStart(const std::string& app_id); | 68 void NotifyAppStart(const std::string& app_id); |
| 73 void NotifyAppActivated(const std::string& app_id); | 69 void NotifyAppActivated(const std::string& app_id); |
| 74 void NotifyAppDeactivated(const std::string& app_id); | 70 void NotifyAppDeactivated(const std::string& app_id); |
| 75 void NotifyAppStop(const std::string& app_id); | 71 void NotifyAppStop(const std::string& app_id); |
| 76 void NotifyChromeTerminating(); | |
| 77 | 72 |
| 78 content::NotificationRegistrar registrar_; | 73 content::NotificationRegistrar registrar_; |
| 79 Profile* profile_; | 74 Profile* profile_; |
| 80 base::ObserverList<Observer> observers_; | 75 base::ObserverList<Observer> observers_; |
| 81 | 76 |
| 82 DISALLOW_COPY_AND_ASSIGN(AppLifetimeMonitor); | 77 DISALLOW_COPY_AND_ASSIGN(AppLifetimeMonitor); |
| 83 }; | 78 }; |
| 84 | 79 |
| 85 } // namespace apps | 80 } // namespace apps |
| 86 | 81 |
| 87 #endif // APPS_APP_LIFETIME_MONITOR_H_ | 82 #endif // APPS_APP_LIFETIME_MONITOR_H_ |
| OLD | NEW |