OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "chrome/browser/chrome_select_file_policy.h" |
10 #include "chrome/browser/extensions/shell_window_registry.h" | 11 #include "chrome/browser/extensions/shell_window_registry.h" |
11 #include "chrome/browser/platform_util.h" | 12 #include "chrome/browser/platform_util.h" |
12 #include "chrome/browser/ui/extensions/shell_window.h" | 13 #include "chrome/browser/ui/extensions/shell_window.h" |
13 #include "chrome/browser/ui/select_file_dialog.h" | 14 #include "chrome/browser/ui/select_file_dialog.h" |
14 #include "chrome/common/extensions/api/file_system.h" | 15 #include "chrome/common/extensions/api/file_system.h" |
15 #include "content/public/browser/child_process_security_policy.h" | 16 #include "content/public/browser/child_process_security_policy.h" |
16 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 #include "webkit/fileapi/file_system_util.h" | 20 #include "webkit/fileapi/file_system_util.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 FilePath::StringType extension = suggested_path.Extension(); | 120 FilePath::StringType extension = suggested_path.Extension(); |
120 if (!extension.empty()) { | 121 if (!extension.empty()) { |
121 extension.erase(extension.begin()); // drop the . | 122 extension.erase(extension.begin()); // drop the . |
122 file_type_info.extensions.resize(1); | 123 file_type_info.extensions.resize(1); |
123 file_type_info.extensions[0].push_back(extension); | 124 file_type_info.extensions[0].push_back(extension); |
124 } | 125 } |
125 file_type_info.include_all_files = true; | 126 file_type_info.include_all_files = true; |
126 gfx::NativeWindow owning_window = web_contents ? | 127 gfx::NativeWindow owning_window = web_contents ? |
127 platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; | 128 platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; |
128 | 129 |
129 select_file_dialog_->SelectFile(for_save ? | 130 select_file_dialog_->SelectFile( |
130 SelectFileDialog::SELECT_SAVEAS_FILE : | 131 for_save ? |
131 SelectFileDialog::SELECT_OPEN_FILE, | 132 SelectFileDialog::SELECT_SAVEAS_FILE : |
132 string16(), | 133 SelectFileDialog::SELECT_OPEN_FILE, |
133 suggested_path, | 134 string16(), |
134 &file_type_info, 0, FILE_PATH_LITERAL(""), | 135 suggested_path, |
135 web_contents, owning_window, NULL); | 136 &file_type_info, 0, FILE_PATH_LITERAL(""), |
| 137 ChromeSelectFilePolicy::DisplayInfobarCallback(web_contents), |
| 138 owning_window, |
| 139 NULL); |
136 } | 140 } |
137 | 141 |
138 virtual ~FilePicker() {} | 142 virtual ~FilePicker() {} |
139 | 143 |
140 private: | 144 private: |
141 // SelectFileDialog::Listener implementation. | 145 // SelectFileDialog::Listener implementation. |
142 virtual void FileSelected(const FilePath& path, | 146 virtual void FileSelected(const FilePath& path, |
143 int index, | 147 int index, |
144 void* params) OVERRIDE { | 148 void* params) OVERRIDE { |
145 function_->FileSelected(path, for_save_); | 149 function_->FileSelected(path, for_save_); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 file_system::ChooseFileOptions* options = params->options.get(); | 279 file_system::ChooseFileOptions* options = params->options.get(); |
276 if (options) { | 280 if (options) { |
277 if (options->type.get() && *options->type == kSaveFileOption) | 281 if (options->type.get() && *options->type == kSaveFileOption) |
278 for_save = true; | 282 for_save = true; |
279 } | 283 } |
280 | 284 |
281 return ShowPicker(FilePath(), for_save); | 285 return ShowPicker(FilePath(), for_save); |
282 } | 286 } |
283 | 287 |
284 } // namespace extensions | 288 } // namespace extensions |
OLD | NEW |