| 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 #include "apps/app_restore_service.h" | 5 #include "apps/app_restore_service.h" |
| 6 | 6 |
| 7 #include "apps/app_lifetime_monitor_factory.h" | 7 #include "apps/app_lifetime_monitor_factory.h" |
| 8 #include "apps/app_restore_service_factory.h" | 8 #include "apps/app_restore_service_factory.h" |
| 9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
| 10 #include "apps/saved_files_service.h" | 10 #include "apps/saved_files_service.h" |
| 11 #include "apps/shell_window.h" | 11 #include "apps/shell_window.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" | 13 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
| 14 #include "chrome/browser/extensions/extension_host.h" | 14 #include "chrome/browser/extensions/extension_host.h" |
| 15 #include "chrome/browser/extensions/extension_prefs.h" | 15 #include "chrome/browser/extensions/extension_prefs.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_system.h" | 17 #include "chrome/browser/extensions/extension_system.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/extensions/extension_set.h" | |
| 20 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 20 #include "extensions/common/extension_set.h" |
| 21 | 21 |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 23 #include "win8/util/win8_util.h" | 23 #include "win8/util/win8_util.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 using extensions::Extension; | 26 using extensions::Extension; |
| 27 using extensions::ExtensionHost; | 27 using extensions::ExtensionHost; |
| 28 using extensions::ExtensionPrefs; | 28 using extensions::ExtensionPrefs; |
| 29 using extensions::ExtensionSystem; | 29 using extensions::ExtensionSystem; |
| 30 | 30 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 AppRestoreService::AppRestoreService(Profile* profile) | 47 AppRestoreService::AppRestoreService(Profile* profile) |
| 48 : profile_(profile) { | 48 : profile_(profile) { |
| 49 StartObservingAppLifetime(); | 49 StartObservingAppLifetime(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void AppRestoreService::HandleStartup(bool should_restore_apps) { | 52 void AppRestoreService::HandleStartup(bool should_restore_apps) { |
| 53 ExtensionService* extension_service = | 53 ExtensionService* extension_service = |
| 54 ExtensionSystem::Get(profile_)->extension_service(); | 54 ExtensionSystem::Get(profile_)->extension_service(); |
| 55 const ExtensionSet* extensions = extension_service->extensions(); | 55 const extensions::ExtensionSet* extensions = extension_service->extensions(); |
| 56 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); | 56 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); |
| 57 | 57 |
| 58 for (ExtensionSet::const_iterator it = extensions->begin(); | 58 for (extensions::ExtensionSet::const_iterator it = extensions->begin(); |
| 59 it != extensions->end(); ++it) { | 59 it != extensions->end(); ++it) { |
| 60 const Extension* extension = it->get(); | 60 const Extension* extension = it->get(); |
| 61 if (extension_prefs->IsExtensionRunning(extension->id())) { | 61 if (extension_prefs->IsExtensionRunning(extension->id())) { |
| 62 RecordAppStop(extension->id()); | 62 RecordAppStop(extension->id()); |
| 63 // If we are not restoring apps (e.g., because it is a clean restart), and | 63 // If we are not restoring apps (e.g., because it is a clean restart), and |
| 64 // the app does not have retain permission, explicitly clear the retained | 64 // the app does not have retain permission, explicitly clear the retained |
| 65 // entries queue. | 65 // entries queue. |
| 66 if (should_restore_apps) { | 66 if (should_restore_apps) { |
| 67 RestoreApp(it->get()); | 67 RestoreApp(it->get()); |
| 68 } else { | 68 } else { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 void AppRestoreService::StopObservingAppLifetime() { | 152 void AppRestoreService::StopObservingAppLifetime() { |
| 153 AppLifetimeMonitor* app_lifetime_monitor = | 153 AppLifetimeMonitor* app_lifetime_monitor = |
| 154 AppLifetimeMonitorFactory::GetForProfile(profile_); | 154 AppLifetimeMonitorFactory::GetForProfile(profile_); |
| 155 // This might be NULL in tests. | 155 // This might be NULL in tests. |
| 156 if (app_lifetime_monitor) | 156 if (app_lifetime_monitor) |
| 157 app_lifetime_monitor->RemoveObserver(this); | 157 app_lifetime_monitor->RemoveObserver(this); |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace apps | 160 } // namespace apps |
| OLD | NEW |