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_restore_service_factory.h" | 7 #include "apps/app_restore_service_factory.h" |
8 #include "apps/saved_files_service.h" | 8 #include "apps/saved_files_service.h" |
9 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" | 9 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
10 #include "chrome/browser/extensions/event_router.h" | 10 #include "chrome/browser/extensions/event_router.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 void AppRestoreService::HandleStartup(bool should_restore_apps) { | 64 void AppRestoreService::HandleStartup(bool should_restore_apps) { |
65 ExtensionService* extension_service = | 65 ExtensionService* extension_service = |
66 ExtensionSystem::Get(profile_)->extension_service(); | 66 ExtensionSystem::Get(profile_)->extension_service(); |
67 const ExtensionSet* extensions = extension_service->extensions(); | 67 const ExtensionSet* extensions = extension_service->extensions(); |
68 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); | 68 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); |
69 | 69 |
70 for (ExtensionSet::const_iterator it = extensions->begin(); | 70 for (ExtensionSet::const_iterator it = extensions->begin(); |
71 it != extensions->end(); ++it) { | 71 it != extensions->end(); ++it) { |
72 const Extension* extension = *it; | 72 const Extension* extension = it->get(); |
73 if (extension_prefs->IsExtensionRunning(extension->id())) { | 73 if (extension_prefs->IsExtensionRunning(extension->id())) { |
74 RecordAppStop(extension->id()); | 74 RecordAppStop(extension->id()); |
75 // If we are not restoring apps (e.g., because it is a clean restart), and | 75 // If we are not restoring apps (e.g., because it is a clean restart), and |
76 // the app does not have retain permission, explicitly clear the retained | 76 // the app does not have retain permission, explicitly clear the retained |
77 // entries queue. | 77 // entries queue. |
78 if (should_restore_apps) { | 78 if (should_restore_apps) { |
79 RestoreApp(*it); | 79 RestoreApp(it->get()); |
80 } else { | 80 } else { |
81 SavedFilesService::Get(profile_)->ClearQueueIfNoRetainPermission( | 81 SavedFilesService::Get(profile_)->ClearQueueIfNoRetainPermission( |
82 extension); | 82 extension); |
83 } | 83 } |
84 } | 84 } |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 bool AppRestoreService::IsAppRestorable(const std::string& extension_id) { | 88 bool AppRestoreService::IsAppRestorable(const std::string& extension_id) { |
89 return extensions::ExtensionPrefs::Get(profile_) ->IsExtensionRunning( | 89 return extensions::ExtensionPrefs::Get(profile_) ->IsExtensionRunning( |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 void AppRestoreService::StopObservingShellWindows() { | 189 void AppRestoreService::StopObservingShellWindows() { |
190 extensions::ShellWindowRegistry* shell_window_registry = | 190 extensions::ShellWindowRegistry* shell_window_registry = |
191 extensions::ShellWindowRegistry::Factory::GetForProfile( | 191 extensions::ShellWindowRegistry::Factory::GetForProfile( |
192 profile_, false /* create */); | 192 profile_, false /* create */); |
193 if (shell_window_registry) | 193 if (shell_window_registry) |
194 shell_window_registry->RemoveObserver(this); | 194 shell_window_registry->RemoveObserver(this); |
195 } | 195 } |
196 | 196 |
197 } // namespace apps | 197 } // namespace apps |
OLD | NEW |