[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] | b8816a4 | 2013-02-27 07:59:00 | [diff] [blame] | 14 | namespace extensions { |
15 | class Extension; | ||||
[email protected] | b897ff87 | 2013-02-27 19:50:13 | [diff] [blame^] | 16 | |
17 | namespace app_file_handler_util { | ||||
18 | struct SavedFileEntry; | ||||
[email protected] | b8816a4 | 2013-02-27 07:59:00 | [diff] [blame] | 19 | } |
[email protected] | 4fe61bc | 2013-02-27 05:17:08 | [diff] [blame] | 20 | |
[email protected] | b897ff87 | 2013-02-27 19:50:13 | [diff] [blame^] | 21 | } |
22 | |||||
23 | class Profile; | ||||
24 | |||||
25 | using extensions::app_file_handler_util::SavedFileEntry; | ||||
26 | |||||
[email protected] | c2e2b6d | 2013-01-22 02:23:29 | [diff] [blame] | 27 | namespace apps { |
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 28 | |
29 | // Tracks what apps need to be restarted when the browser restarts. | ||||
30 | class AppRestoreService : public ProfileKeyedService, | ||||
31 | public content::NotificationObserver { | ||||
32 | public: | ||||
33 | explicit AppRestoreService(Profile* profile); | ||||
34 | |||||
[email protected] | 11945462 | 2012-10-18 09:48:32 | [diff] [blame] | 35 | // Restart apps that need to be restarted and clear the "running" preference |
36 | // from apps to prevent them being restarted in subsequent restarts. | ||||
[email protected] | 300ba0c4 | 2012-12-06 06:57:17 | [diff] [blame] | 37 | void HandleStartup(bool should_restore_apps); |
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 38 | |
39 | private: | ||||
40 | // content::NotificationObserver. | ||||
41 | virtual void Observe(int type, | ||||
42 | const content::NotificationSource& source, | ||||
43 | const content::NotificationDetails& details) OVERRIDE; | ||||
44 | |||||
45 | void RecordAppStart(const std::string& extension_id); | ||||
46 | void RecordAppStop(const std::string& extension_id); | ||||
[email protected] | b897ff87 | 2013-02-27 19:50:13 | [diff] [blame^] | 47 | void RestoreApp( |
48 | const extensions::Extension* extension, | ||||
49 | const std::vector<SavedFileEntry>& file_entries); | ||||
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 50 | |
51 | content::NotificationRegistrar registrar_; | ||||
52 | Profile* profile_; | ||||
53 | }; | ||||
54 | |||||
[email protected] | c2e2b6d | 2013-01-22 02:23:29 | [diff] [blame] | 55 | } // namespace apps |
[email protected] | 28c3eeb | 2012-10-15 05:47:53 | [diff] [blame] | 56 | |
57 | #endif // CHROME_BROWSER_EXTENSIONS_APP_RESTORE_SERVICE_H_ |