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..3230eae36bc712c1e8a1acc933fb7706929ecbc4 100644 |
--- a/chrome/browser/extensions/api/file_system/file_system_api.cc |
+++ b/chrome/browser/extensions/api/file_system/file_system_api.cc |
@@ -242,21 +242,23 @@ class FileSystemChooseFileFunction::FilePicker |
FilePicker(FileSystemChooseFileFunction* function, |
content::WebContents* web_contents, |
const FilePath& suggested_path, |
+ const SelectFileDialog::FileTypeInfo& file_type_info, |
SelectFileDialog::Type picker_type, |
EntryType entry_type) |
: suggested_path_(suggested_path), |
+ file_type_info_(file_type_info), |
entry_type_(entry_type), |
function_(function) { |
select_file_dialog_ = SelectFileDialog::Create( |
this, new ChromeSelectFilePolicy(web_contents)); |
- SelectFileDialog::FileTypeInfo file_type_info; |
+/* SelectFileDialog::FileTypeInfo file_type_info; |
FilePath::StringType extension = suggested_path.Extension(); |
if (!extension.empty()) { |
extension.erase(extension.begin()); // drop the . |
file_type_info.extensions.resize(1); |
file_type_info.extensions[0].push_back(extension); |
} |
- file_type_info.include_all_files = true; |
+ file_type_info.include_all_files = true;*/ |
gfx::NativeWindow owning_window = web_contents ? |
platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; |
@@ -280,7 +282,7 @@ class FileSystemChooseFileFunction::FilePicker |
select_file_dialog_->SelectFile(picker_type, |
string16(), |
suggested_path, |
- &file_type_info, 0, FILE_PATH_LITERAL(""), |
+ &file_type_info_, 0, FILE_PATH_LITERAL(""), |
owning_window, NULL); |
} |
@@ -302,6 +304,8 @@ class FileSystemChooseFileFunction::FilePicker |
FilePath suggested_path_; |
+ SelectFileDialog::FileTypeInfo file_type_info_; |
+ |
EntryType entry_type_; |
scoped_refptr<SelectFileDialog> select_file_dialog_; |
@@ -312,6 +316,7 @@ class FileSystemChooseFileFunction::FilePicker |
bool FileSystemChooseFileFunction::ShowPicker( |
const FilePath& suggested_path, |
+ const SelectFileDialog::FileTypeInfo& file_type_info, |
SelectFileDialog::Type picker_type, |
EntryType entry_type) { |
ShellWindowRegistry* registry = ShellWindowRegistry::Get(profile()); |
@@ -328,7 +333,7 @@ bool FileSystemChooseFileFunction::ShowPicker( |
// user has selected a file or cancelled the picker. At that point, the picker |
// will delete itself, which will also free the function instance. |
new FilePicker(this, shell_window->web_contents(), suggested_path, |
- picker_type, entry_type); |
+ file_type_info, picker_type, entry_type); |
return true; |
} |
@@ -392,7 +397,25 @@ bool FileSystemChooseFileFunction::RunImpl() { |
return false; |
} |
- return ShowPicker(FilePath(), picker_type, entry_type); |
+ FilePath suggested_path; |
+ scoped_ptr<SelectFileDialog::FileTypeInfo> file_type_info( |
+ new SelectFileDialog::FileTypeInfo()); |
+ |
+ if (options) { |
+ FilePath::StringType suggested_extension; |
+ |
+ if (options->suggested_path.get()) { |
+ suggested_path = FilePath::FromUTF8Unsafe(*options->suggested_path.get()); |
+ } |
+ |
+ file_type_info->include_all_files = options->accepts_all_types.get(); |
+ if (file_type_info->extensions.empty() && !file_type_info->include_all_files) { |
+ // TODO: log warning |
+ file_type_info->include_all_files = true; |
+ } |
+ } |
+ |
+ return ShowPicker(FilePath(), *file_type_info, picker_type, entry_type); |
} |
} // namespace extensions |