Chromium Code Reviews| Index: chrome/browser/extensions/api/file_system/file_system_api.cc |
| diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc |
| index 871125e0030030d2aab9d8263ef184ef5e896dbb..5b2339741c55253f22b7d99c4dc693a1c5c650bd 100644 |
| --- a/chrome/browser/extensions/api/file_system/file_system_api.cc |
| +++ b/chrome/browser/extensions/api/file_system/file_system_api.cc |
| @@ -372,18 +372,26 @@ bool FileSystemChooseFileFunction::RunImpl() { |
| scoped_ptr<ChooseFile::Params> params(ChooseFile::Params::Create(*args_)); |
| EXTENSION_FUNCTION_VALIDATE(params.get()); |
| + FilePath suggested_path; |
|
benwells
2012/07/12 08:23:33
Nit: suggested_name
thorogood
2012/07/12 08:40:20
Done.
|
| EntryType entry_type = READ_ONLY; |
| SelectFileDialog::Type picker_type = SelectFileDialog::SELECT_OPEN_FILE; |
| + |
| file_system::ChooseFileOptions* options = params->options.get(); |
| - if (options && options->type.get()) { |
| - if (*options->type == kOpenWritableFileOption) { |
| - entry_type = WRITABLE; |
| - } else if (*options->type == kSaveFileOption) { |
| - entry_type = WRITABLE; |
| - picker_type = SelectFileDialog::SELECT_SAVEAS_FILE; |
| - } else if (*options->type != kOpenFileOption) { |
| - error_ = kUnknownChooseFileType; |
| - return false; |
| + if (options) { |
| + if (options->type.get()) { |
| + if (*options->type == kOpenWritableFileOption) { |
| + entry_type = WRITABLE; |
| + } else if (*options->type == kSaveFileOption) { |
| + entry_type = WRITABLE; |
| + picker_type = SelectFileDialog::SELECT_SAVEAS_FILE; |
| + } else if (*options->type != kOpenFileOption) { |
| + error_ = kUnknownChooseFileType; |
| + return false; |
| + } |
| + } |
| + |
| + if (options->suggested_name.get()) { |
| + suggested_path = FilePath::FromUTF8Unsafe(*options->suggested_name.get()) |
|
benwells
2012/07/12 08:23:33
We should just use BaseName, so if an extension tr
thorogood
2012/07/12 08:40:20
Done. BaseName may still return an absolute path i
|
| } |
| } |
| @@ -392,7 +400,7 @@ bool FileSystemChooseFileFunction::RunImpl() { |
| return false; |
| } |
| - return ShowPicker(FilePath(), picker_type, entry_type); |
| + return ShowPicker(suggested_path, picker_type, entry_type); |
| } |
| } // namespace extensions |