[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_EXTENSIONS_APP_RESTORE_SERVICE_H_ | ||||
6 | #define CHROME_BROWSER_EXTENSIONS_APP_RESTORE_SERVICE_H_ | ||||
7 | |||||
[email protected] | c2e2b6d | 2013-01-22 02:23:29 | [diff] [blame^] | 8 | #include <string> |
9 | |||||
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 10 | #include "chrome/browser/profiles/profile_keyed_service.h" |
11 | #include "content/public/browser/notification_observer.h" | ||||
12 | #include "content/public/browser/notification_registrar.h" | ||||
13 | |||||
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 14 | class Profile; |
15 | |||||
16 | namespace extensions { | ||||
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 17 | class Extension; |
[email protected] | c2e2b6d | 2013-01-22 02:23:29 | [diff] [blame^] | 18 | } |
19 | |||||
20 | namespace apps { | ||||
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 21 | |
22 | // Tracks what apps need to be restarted when the browser restarts. | ||||
23 | class AppRestoreService : public ProfileKeyedService, | ||||
24 | public content::NotificationObserver { | ||||
25 | public: | ||||
26 | explicit AppRestoreService(Profile* profile); | ||||
27 | |||||
[email protected] | 11945462 | 2012-10-18 09:48:32 | [diff] [blame] | 28 | // Restart apps that need to be restarted and clear the "running" preference |
29 | // from apps to prevent them being restarted in subsequent restarts. | ||||
[email protected] | 300ba0c4 | 2012-12-06 06:57:17 | [diff] [blame] | 30 | void HandleStartup(bool should_restore_apps); |
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 31 | |
32 | private: | ||||
33 | // content::NotificationObserver. | ||||
34 | virtual void Observe(int type, | ||||
35 | const content::NotificationSource& source, | ||||
36 | const content::NotificationDetails& details) OVERRIDE; | ||||
37 | |||||
38 | void RecordAppStart(const std::string& extension_id); | ||||
39 | void RecordAppStop(const std::string& extension_id); | ||||
[email protected] | c2e2b6d | 2013-01-22 02:23:29 | [diff] [blame^] | 40 | void RestoreApp(const extensions::Extension* extension); |
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 41 | |
42 | content::NotificationRegistrar registrar_; | ||||
43 | Profile* profile_; | ||||
44 | }; | ||||
45 | |||||
[email protected] | c2e2b6d | 2013-01-22 02:23:29 | [diff] [blame^] | 46 | } // namespace apps |
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 47 | |
48 | #endif // CHROME_BROWSER_EXTENSIONS_APP_RESTORE_SERVICE_H_ |