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

Unified Diff: chrome/renderer/resources/extensions/file_system_custom_bindings.js

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
Index: chrome/renderer/resources/extensions/file_system_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/file_system_custom_bindings.js b/chrome/renderer/resources/extensions/file_system_custom_bindings.js
index 921ff23ca563db98c9148d2f1a83c3663cc8926f..6fdf89dbcff9a99386d780730e495362cea127bf 100644
--- a/chrome/renderer/resources/extensions/file_system_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/file_system_custom_bindings.js
@@ -33,6 +33,17 @@ if (window == backgroundPage) {
var entries = [];
var hasError = false;
+ var getEntryError = function(fileError) {
+ if (!hasError) {
+ hasError = true;
+ lastError.run(
+ 'fileSystem.' + functionName,
+ 'Error getting fileEntry, code: ' + fileError.code,
+ request.stack,
+ callback);
+ }
+ }
+
// Loop through the response entries and asynchronously get the
// FileEntry for each. We use hasError to ensure that only the first
// error is reported. Note that an error can occur either during the
@@ -46,10 +57,7 @@ if (window == backgroundPage) {
var fs = GetIsolatedFileSystem(fileSystemId);
try {
- // TODO(koz): fs.root.getFile() makes a trip to the browser process,
- // but it might be possible avoid that by calling
- // WebFrame::createFileEntry().
- fs.root.getFile(baseName, {}, function(fileEntry) {
+ var getEntryCallback = function(fileEntry) {
if (hasError)
return;
entryIdManager.registerEntry(id, fileEntry);
@@ -64,16 +72,16 @@ if (window == backgroundPage) {
callback(entries[0]);
}
}
- }, function(fileError) {
- if (!hasError) {
- hasError = true;
- lastError.run(
- 'fileSystem.' + functionName,
- 'Error getting fileEntry, code: ' + fileError.code,
- request.stack,
- callback);
- }
- });
+ }
+ // TODO(koz): fs.root.getFile() makes a trip to the browser process,
+ // but it might be possible avoid that by calling
+ // WebFrame::createFileEntry().
+ if (entry.isDirectory) {
+ fs.root.getDirectory(baseName, {}, getEntryCallback,
+ getEntryError);
+ } else {
+ fs.root.getFile(baseName, {}, getEntryCallback, getEntryError);
+ }
} catch (e) {
if (!hasError) {
hasError = true;

Powered by Google App Engine
This is Rietveld 408576698