Index: apps/saved_files_service.cc |
diff --git a/apps/saved_files_service.cc b/apps/saved_files_service.cc |
index aa64af90d62fbdbdea974741708d4477a5122829..f832ffe60c2246dfcead8afaed264cce8e9daa1b 100644 |
--- a/apps/saved_files_service.cc |
+++ b/apps/saved_files_service.cc |
@@ -36,6 +36,9 @@ const char kFileEntries[] = "file_entries"; |
// The path to a file entry that the app had permission to access. |
const char kFileEntryPath[] = "path"; |
+// Whether or not the the entry refers to a directory. |
+const char kFileEntryIsDirectory[] = "is_directory"; |
+ |
// The sequence number in the LRU of the file entry. |
const char kFileEntrySequenceNumber[] = "sequence_number"; |
@@ -59,6 +62,7 @@ void AddSavedFileEntry(ExtensionPrefs* prefs, |
DictionaryValue* file_entry_dict = new DictionaryValue(); |
file_entry_dict->Set(kFileEntryPath, CreateFilePathValue(file_entry.path)); |
+ file_entry_dict->SetBoolean(kFileEntryIsDirectory, file_entry.is_directory); |
file_entry_dict->SetInteger(kFileEntrySequenceNumber, |
file_entry.sequence_number); |
file_entries->SetWithoutPathExpansion(file_entry.id, file_entry_dict); |
@@ -118,25 +122,30 @@ std::vector<SavedFileEntry> GetSavedFileEntries( |
base::FilePath file_path; |
if (!GetValueAsFilePath(*path_value, &file_path)) |
continue; |
+ bool is_directory = false; |
+ file_entry->GetBoolean(kFileEntryIsDirectory, &is_directory); |
int sequence_number = 0; |
if (!file_entry->GetInteger(kFileEntrySequenceNumber, &sequence_number)) |
continue; |
if (!sequence_number) |
continue; |
- result.push_back(SavedFileEntry(it.key(), file_path, sequence_number)); |
+ result.push_back( |
+ SavedFileEntry(it.key(), file_path, is_directory, sequence_number)); |
} |
return result; |
} |
} // namespace |
-SavedFileEntry::SavedFileEntry() : sequence_number(0) {} |
+SavedFileEntry::SavedFileEntry() : is_directory(false), sequence_number(0) {} |
SavedFileEntry::SavedFileEntry(const std::string& id, |
const base::FilePath& path, |
+ bool is_directory, |
int sequence_number) |
: id(id), |
path(path), |
+ is_directory(is_directory), |
sequence_number(sequence_number) {} |
class SavedFilesService::SavedFiles { |
@@ -145,7 +154,8 @@ class SavedFilesService::SavedFiles { |
~SavedFiles(); |
void RegisterFileEntry(const std::string& id, |
- const base::FilePath& file_path); |
+ const base::FilePath& file_path, |
+ bool is_directory); |
void EnqueueFileEntry(const std::string& id); |
bool IsRegistered(const std::string& id) const; |
const SavedFileEntry* GetFileEntry(const std::string& id) const; |
@@ -219,8 +229,9 @@ void SavedFilesService::Observe(int type, |
void SavedFilesService::RegisterFileEntry(const std::string& extension_id, |
const std::string& id, |
- const base::FilePath& file_path) { |
- GetOrInsert(extension_id)->RegisterFileEntry(id, file_path); |
+ const base::FilePath& file_path, |
+ bool is_directory) { |
+ GetOrInsert(extension_id)->RegisterFileEntry(id, file_path, is_directory); |
} |
void SavedFilesService::EnqueueFileEntry(const std::string& extension_id, |
@@ -303,12 +314,13 @@ SavedFilesService::SavedFiles::~SavedFiles() {} |
void SavedFilesService::SavedFiles::RegisterFileEntry( |
const std::string& id, |
- const base::FilePath& file_path) { |
+ const base::FilePath& file_path, |
+ bool is_directory) { |
if (ContainsKey(registered_file_entries_, id)) |
return; |
registered_file_entries_.insert( |
- std::make_pair(id, new SavedFileEntry(id, file_path, 0))); |
+ std::make_pair(id, new SavedFileEntry(id, file_path, is_directory, 0))); |
} |
void SavedFilesService::SavedFiles::EnqueueFileEntry(const std::string& id) { |