| 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 "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" | 7 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
| 8 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" | |
| 9 #include "chrome/browser/extensions/event_router.h" | 8 #include "chrome/browser/extensions/event_router.h" |
| 10 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
| 13 #include "chrome/browser/extensions/platform_app_launcher.h" | 12 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/extensions/extension_set.h" | 15 #include "chrome/common/extensions/extension_set.h" |
| 17 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void AppRestoreService::HandleStartup(bool should_restore_apps) { | 59 void AppRestoreService::HandleStartup(bool should_restore_apps) { |
| 61 ExtensionService* extension_service = | 60 ExtensionService* extension_service = |
| 62 ExtensionSystem::Get(profile_)->extension_service(); | 61 ExtensionSystem::Get(profile_)->extension_service(); |
| 63 const ExtensionSet* extensions = extension_service->extensions(); | 62 const ExtensionSet* extensions = extension_service->extensions(); |
| 64 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); | 63 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); |
| 65 | 64 |
| 66 for (ExtensionSet::const_iterator it = extensions->begin(); | 65 for (ExtensionSet::const_iterator it = extensions->begin(); |
| 67 it != extensions->end(); ++it) { | 66 it != extensions->end(); ++it) { |
| 68 const Extension* extension = *it; | 67 const Extension* extension = *it; |
| 69 if (extension_prefs->IsExtensionRunning(extension->id())) { | 68 if (extension_prefs->IsExtensionRunning(extension->id())) { |
| 70 std::vector<SavedFileEntry> file_entries; | |
| 71 extensions::app_file_handler_util::GetSavedFileEntries(extension_prefs, | |
| 72 extension->id(), | |
| 73 &file_entries); | |
| 74 RecordAppStop(extension->id()); | 69 RecordAppStop(extension->id()); |
| 75 if (should_restore_apps) | 70 if (should_restore_apps) |
| 76 RestoreApp(*it, file_entries); | 71 RestoreApp(*it); |
| 77 } | 72 } |
| 78 } | 73 } |
| 79 } | 74 } |
| 80 | 75 |
| 81 void AppRestoreService::Observe(int type, | 76 void AppRestoreService::Observe(int type, |
| 82 const content::NotificationSource& source, | 77 const content::NotificationSource& source, |
| 83 const content::NotificationDetails& details) { | 78 const content::NotificationDetails& details) { |
| 84 switch (type) { | 79 switch (type) { |
| 85 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { | 80 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { |
| 86 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); | 81 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 111 void AppRestoreService::RecordAppStart(const std::string& extension_id) { | 106 void AppRestoreService::RecordAppStart(const std::string& extension_id) { |
| 112 ExtensionPrefs* extension_prefs = | 107 ExtensionPrefs* extension_prefs = |
| 113 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); | 108 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); |
| 114 extension_prefs->SetExtensionRunning(extension_id, true); | 109 extension_prefs->SetExtensionRunning(extension_id, true); |
| 115 } | 110 } |
| 116 | 111 |
| 117 void AppRestoreService::RecordAppStop(const std::string& extension_id) { | 112 void AppRestoreService::RecordAppStop(const std::string& extension_id) { |
| 118 ExtensionPrefs* extension_prefs = | 113 ExtensionPrefs* extension_prefs = |
| 119 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); | 114 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); |
| 120 extension_prefs->SetExtensionRunning(extension_id, false); | 115 extension_prefs->SetExtensionRunning(extension_id, false); |
| 121 extensions::app_file_handler_util::ClearSavedFileEntries( | |
| 122 extension_prefs, extension_id); | |
| 123 } | 116 } |
| 124 | 117 |
| 125 void AppRestoreService::RestoreApp( | 118 void AppRestoreService::RestoreApp(const Extension* extension) { |
| 126 const Extension* extension, | 119 extensions::RestartPlatformApp(profile_, extension); |
| 127 const std::vector<SavedFileEntry>& file_entries) { | |
| 128 extensions::RestartPlatformAppWithFileEntries(profile_, | |
| 129 extension, | |
| 130 file_entries); | |
| 131 } | 120 } |
| 132 | 121 |
| 133 } // namespace apps | 122 } // namespace apps |
| OLD | NEW |