Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2079)

Unified Diff: apps/saved_files_service.cc

Issue 23146016: Add support for directory access to the file system API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@simpler-write-permissions
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/saved_files_service.h ('k') | apps/saved_files_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « apps/saved_files_service.h ('k') | apps/saved_files_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698