Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: apps/app_lifetime_monitor.h

Issue 344543006: Disable ephemeral apps after they stop running (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments and refactoring Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/apps/ephemeral_app_browsertest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 24
25 // Observes startup of apps and their windows and notifies observers of these 25 // Observes startup of apps and their windows and notifies observers of these
26 // events. 26 // events.
27 class AppLifetimeMonitor : public KeyedService, 27 class AppLifetimeMonitor : public KeyedService,
28 public content::NotificationObserver, 28 public content::NotificationObserver,
29 public AppWindowRegistry::Observer { 29 public AppWindowRegistry::Observer {
30 public: 30 public:
31 class Observer { 31 class Observer {
32 public: 32 public:
33 // Called when the app starts running. 33 // Called when the app starts running.
34 virtual void OnAppStart(Profile* profile, const std::string& app_id) = 0; 34 virtual void OnAppStart(Profile* profile, const std::string& app_id) {}
35 // Called when the app becomes active to the user, i.e. it opens a window. 35 // Called when the app becomes active to the user, i.e. it opens a window.
36 virtual void OnAppActivated(Profile* profile, 36 virtual void OnAppActivated(Profile* profile, const std::string& app_id) {}
37 const std::string& app_id) = 0;
38 // Called when the app becomes inactive to the user. 37 // Called when the app becomes inactive to the user.
39 virtual void OnAppDeactivated(Profile* profile, 38 virtual void OnAppDeactivated(Profile* profile, const std::string& app_id) {
40 const std::string& app_id) = 0; 39 }
41 // Called when the app stops running. 40 // Called when the app stops running.
42 virtual void OnAppStop(Profile* profile, const std::string& app_id) = 0; 41 virtual void OnAppStop(Profile* profile, const std::string& app_id) {}
43 // Called when chrome is about to terminate. This gives observers a chance 42 // Called when chrome is about to terminate. This gives observers a chance
44 // to do something before the apps shut down. This is a system-wide event 43 // to do something before the apps shut down. This is a system-wide event
45 // so there is no associated profile and app id. 44 // so there is no associated profile and app id.
46 virtual void OnChromeTerminating() = 0; 45 virtual void OnChromeTerminating() {}
47 46
48 protected: 47 protected:
49 virtual ~Observer() {} 48 virtual ~Observer() {}
50 }; 49 };
51 50
52 explicit AppLifetimeMonitor(Profile* profile); 51 explicit AppLifetimeMonitor(Profile* profile);
53 virtual ~AppLifetimeMonitor(); 52 virtual ~AppLifetimeMonitor();
54 53
55 void AddObserver(Observer* observer); 54 void AddObserver(Observer* observer);
56 void RemoveObserver(Observer* observer); 55 void RemoveObserver(Observer* observer);
(...skipping 23 matching lines...) Expand all
80 content::NotificationRegistrar registrar_; 79 content::NotificationRegistrar registrar_;
81 Profile* profile_; 80 Profile* profile_;
82 ObserverList<Observer> observers_; 81 ObserverList<Observer> observers_;
83 82
84 DISALLOW_COPY_AND_ASSIGN(AppLifetimeMonitor); 83 DISALLOW_COPY_AND_ASSIGN(AppLifetimeMonitor);
85 }; 84 };
86 85
87 } // namespace apps 86 } // namespace apps
88 87
89 #endif // APPS_APP_LIFETIME_MONITOR_H_ 88 #endif // APPS_APP_LIFETIME_MONITOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/apps/ephemeral_app_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698