diff options
author | sammc@chromium.org <sammc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-25 14:09:24 +0000 |
---|---|---|
committer | sammc@chromium.org <sammc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-25 14:09:24 +0000 |
commit | 961745f2cca727fe6144a28fd16ca536dbd94768 (patch) | |
tree | 0437c54836347b13227b0a45824cdbadefc0f063 /apps/app_restore_service.cc | |
parent | 1b6a233a4f2af1a5c02c99f0c8958b14d3efafbb (diff) | |
download | chromium_src-961745f2cca727fe6144a28fd16ca536dbd94768.zip chromium_src-961745f2cca727fe6144a28fd16ca536dbd94768.tar.gz chromium_src-961745f2cca727fe6144a28fd16ca536dbd94768.tar.bz2 |
Add support for persistent file access in apps.
This replaces chrome.fileSystem.getEntry(By)Id with retainEntry,
restoreEntry and isRestorable, which enable restoring file access after
an app is closed for apps with the fileSystem.retainFiles permission.
Retained files are evicted by LRU, with a maximum of 500 retained files.
BUG=224684
Review URL: https://chromiumcodereview.appspot.com/14607023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202276 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps/app_restore_service.cc')
-rw-r--r-- | apps/app_restore_service.cc | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/apps/app_restore_service.cc b/apps/app_restore_service.cc index a567811..88ac811 100644 --- a/apps/app_restore_service.cc +++ b/apps/app_restore_service.cc @@ -4,8 +4,8 @@ #include "apps/app_restore_service.h" +#include "apps/saved_files_service.h" #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" -#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_prefs.h" @@ -70,13 +70,16 @@ void AppRestoreService::HandleStartup(bool should_restore_apps) { it != extensions->end(); ++it) { const Extension* extension = *it; if (extension_prefs->IsExtensionRunning(extension->id())) { - std::vector<SavedFileEntry> file_entries; - extensions::app_file_handler_util::GetSavedFileEntries(extension_prefs, - extension->id(), - &file_entries); RecordAppStop(extension->id()); - if (should_restore_apps) - RestoreApp(*it, file_entries); + // If we are not restoring apps (e.g., because it is a clean restart), and + // the app does not have retain permission, explicitly clear the retained + // entries queue. + if (should_restore_apps) { + RestoreApp(*it); + } else { + SavedFilesService::Get(profile_)->ClearQueueIfNoRetainPermission( + extension); + } } } } @@ -138,8 +141,6 @@ void AppRestoreService::RecordAppStop(const std::string& extension_id) { ExtensionPrefs* extension_prefs = ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); extension_prefs->SetExtensionRunning(extension_id, false); - extensions::app_file_handler_util::ClearSavedFileEntries( - extension_prefs, extension_id); } void AppRestoreService::RecordIfAppHasWindows( @@ -162,12 +163,8 @@ void AppRestoreService::RecordIfAppHasWindows( extension_prefs->SetHasWindows(id, has_windows); } -void AppRestoreService::RestoreApp( - const Extension* extension, - const std::vector<SavedFileEntry>& file_entries) { - extensions::RestartPlatformAppWithFileEntries(profile_, - extension, - file_entries); +void AppRestoreService::RestoreApp(const Extension* extension) { + extensions::RestartPlatformApp(profile_, extension); } void AppRestoreService::StartObservingShellWindows() { |