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 37460db1aef09c2b98b80a19ac311f13bc8a0729..1d8de171c5180d15b6ce7a035bd68dd6057c6ccb 100644 |
--- a/chrome/browser/extensions/api/file_system/file_system_api.cc |
+++ b/chrome/browser/extensions/api/file_system/file_system_api.cc |
@@ -32,6 +32,9 @@ namespace ChooseFile = file_system::ChooseFile; |
namespace { |
+bool g_skip_picker = false; |
+FilePath* g_path_to_be_picked; |
+ |
bool GetFilePathOfFileEntry(const std::string& filesystem_name, |
const std::string& filesystem_path, |
const content::RenderViewHost* render_view_host, |
@@ -126,6 +129,21 @@ class FileSystemPickerFunction::FilePicker : public SelectFileDialog::Listener { |
gfx::NativeWindow owning_window = web_contents ? |
platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; |
+ if (g_skip_picker) { |
+ if (g_path_to_be_picked) { |
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
+ base::Bind(&FileSystemPickerFunction::FilePicker::FileSelected, |
+ base::Unretained(this), *g_path_to_be_picked, 1, |
+ static_cast<void*>(NULL))); |
+ } else { |
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
+ base::Bind( |
+ &FileSystemPickerFunction::FilePicker::FileSelectionCanceled, |
+ base::Unretained(this), static_cast<void*>(NULL))); |
+ } |
+ return; |
+ } |
+ |
select_file_dialog_->SelectFile(for_save ? |
SelectFileDialog::SELECT_SAVEAS_FILE : |
SelectFileDialog::SELECT_OPEN_FILE, |
@@ -183,6 +201,23 @@ bool FileSystemPickerFunction::ShowPicker(const FilePath& suggested_path, |
return true; |
} |
+// static |
+void FileSystemPickerFunction::SkipPickerAndAlwaysSelectPath(FilePath* path) { |
+ g_skip_picker = true; |
+ g_path_to_be_picked = path; |
+} |
+ |
+// static |
+void FileSystemPickerFunction::SkipPickerAndAlwaysCancel() { |
+ g_skip_picker = true; |
+ g_path_to_be_picked = NULL; |
+} |
+ |
+// static |
+void FileSystemPickerFunction::StopSkippingPicker() { |
+ g_skip_picker = false; |
+} |
+ |
void FileSystemPickerFunction::FileSelected(const FilePath& path, |
bool for_save) { |
if (for_save) { |