Chromium Code Reviews| Index: chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc |
| diff --git a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc |
| index 64c81728b2520a0694dba4b772d2ed684739db2a..becb9d925fe0f28c5497f61a431f3acbe5d92353 100644 |
| --- a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc |
| +++ b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc |
| @@ -64,6 +64,9 @@ bool DoCheckWritableFile(const base::FilePath& path) { |
| if (base::PathExists(path) && file_util::IsLink(path)) |
| return false; |
| + if (base::DirectoryExists(path)) |
| + return base::PathIsWritable(path); |
|
Matt Giuca
2013/08/27 04:30:53
Do you handle the case of trying to write to a fil
Sam McNally
2013/08/27 05:16:37
That would cause getFile/getDirectory to fail in t
|
| + |
| // Create the file if it doesn't already exist. |
| base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| int creation_flags = base::PLATFORM_FILE_CREATE | |
| @@ -290,7 +293,8 @@ GrantedFileEntry CreateFileEntry( |
| Profile* profile, |
| const Extension* extension, |
| int renderer_id, |
| - const base::FilePath& path) { |
| + const base::FilePath& path, |
| + bool is_directory) { |
| GrantedFileEntry result; |
| fileapi::IsolatedContext* isolated_context = |
| fileapi::IsolatedContext::GetInstance(); |
| @@ -303,8 +307,11 @@ GrantedFileEntry CreateFileEntry( |
| content::ChildProcessSecurityPolicy* policy = |
| content::ChildProcessSecurityPolicy::GetInstance(); |
| policy->GrantReadFileSystem(renderer_id, result.filesystem_id); |
| - if (HasFileSystemWritePermission(extension)) |
| + if (HasFileSystemWritePermission(extension)) { |
| policy->GrantWriteFileSystem(renderer_id, result.filesystem_id); |
| + if (is_directory) |
| + policy->GrantCreateFileForFileSystem(renderer_id, result.filesystem_id); |
| + } |
| result.id = result.filesystem_id + ":" + result.registered_name; |
| return result; |
| @@ -320,6 +327,8 @@ void CheckWritableFiles( |
| checker->Check(); |
| } |
| +GrantedFileEntry::GrantedFileEntry() {} |
| + |
| bool HasFileSystemWritePermission(const Extension* extension) { |
| return extension->HasAPIPermission(APIPermission::kFileSystemWrite); |
| } |