| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_RESTORE_SERVICE_H_ | 5 #ifndef APPS_APP_RESTORE_SERVICE_H_ |
| 6 #define APPS_APP_RESTORE_SERVICE_H_ | 6 #define APPS_APP_RESTORE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 } | 23 } |
| 24 | 24 |
| 25 class Profile; | 25 class Profile; |
| 26 | 26 |
| 27 using extensions::app_file_handler_util::SavedFileEntry; | 27 using extensions::app_file_handler_util::SavedFileEntry; |
| 28 | 28 |
| 29 namespace apps { | 29 namespace apps { |
| 30 | 30 |
| 31 // Tracks what apps need to be restarted when the browser restarts. | 31 // Tracks what apps need to be restarted when the browser restarts. |
| 32 class AppRestoreService : public ProfileKeyedService, | 32 class AppRestoreService : public BrowserContextKeyedService, |
| 33 public content::NotificationObserver, | 33 public content::NotificationObserver, |
| 34 public extensions::ShellWindowRegistry::Observer { | 34 public extensions::ShellWindowRegistry::Observer { |
| 35 public: | 35 public: |
| 36 // Returns true if apps should be restored on the current platform, given | 36 // Returns true if apps should be restored on the current platform, given |
| 37 // whether this new browser process launched due to a restart. | 37 // whether this new browser process launched due to a restart. |
| 38 static bool ShouldRestoreApps(bool is_browser_restart); | 38 static bool ShouldRestoreApps(bool is_browser_restart); |
| 39 | 39 |
| 40 explicit AppRestoreService(Profile* profile); | 40 explicit AppRestoreService(Profile* profile); |
| 41 | 41 |
| 42 // Restart apps that need to be restarted and clear the "running" preference | 42 // Restart apps that need to be restarted and clear the "running" preference |
| 43 // from apps to prevent them being restarted in subsequent restarts. | 43 // from apps to prevent them being restarted in subsequent restarts. |
| 44 void HandleStartup(bool should_restore_apps); | 44 void HandleStartup(bool should_restore_apps); |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 // content::NotificationObserver. | 47 // content::NotificationObserver. |
| 48 virtual void Observe(int type, | 48 virtual void Observe(int type, |
| 49 const content::NotificationSource& source, | 49 const content::NotificationSource& source, |
| 50 const content::NotificationDetails& details) OVERRIDE; | 50 const content::NotificationDetails& details) OVERRIDE; |
| 51 | 51 |
| 52 // extensions::ShellWindowRegistry::Observer. | 52 // extensions::ShellWindowRegistry::Observer. |
| 53 virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE; | 53 virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE; |
| 54 virtual void OnShellWindowIconChanged(ShellWindow* shell_window) OVERRIDE; | 54 virtual void OnShellWindowIconChanged(ShellWindow* shell_window) OVERRIDE; |
| 55 virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE; | 55 virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE; |
| 56 | 56 |
| 57 // ProfileKeyedService. | 57 // BrowserContextKeyedService. |
| 58 virtual void Shutdown() OVERRIDE; | 58 virtual void Shutdown() OVERRIDE; |
| 59 | 59 |
| 60 void RecordAppStart(const std::string& extension_id); | 60 void RecordAppStart(const std::string& extension_id); |
| 61 void RecordAppStop(const std::string& extension_id); | 61 void RecordAppStop(const std::string& extension_id); |
| 62 void RecordIfAppHasWindows(const std::string& id); | 62 void RecordIfAppHasWindows(const std::string& id); |
| 63 | 63 |
| 64 void RestoreApp( | 64 void RestoreApp( |
| 65 const extensions::Extension* extension, | 65 const extensions::Extension* extension, |
| 66 const std::vector<SavedFileEntry>& file_entries); | 66 const std::vector<SavedFileEntry>& file_entries); |
| 67 | 67 |
| 68 void StartObservingShellWindows(); | 68 void StartObservingShellWindows(); |
| 69 void StopObservingShellWindows(); | 69 void StopObservingShellWindows(); |
| 70 | 70 |
| 71 content::NotificationRegistrar registrar_; | 71 content::NotificationRegistrar registrar_; |
| 72 Profile* profile_; | 72 Profile* profile_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(AppRestoreService); | 74 DISALLOW_COPY_AND_ASSIGN(AppRestoreService); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 } // namespace apps | 77 } // namespace apps |
| 78 | 78 |
| 79 #endif // APPS_APP_RESTORE_SERVICE_H_ | 79 #endif // APPS_APP_RESTORE_SERVICE_H_ |
| OLD | NEW |