Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 10667026: Start consolidating cross-port file selection code into ui/base/dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempt to fix win Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/shell_window_registry.h" 10 #include "chrome/browser/extensions/shell_window_registry.h"
11 #include "chrome/browser/platform_util.h" 11 #include "chrome/browser/platform_util.h"
12 #include "chrome/browser/ui/chrome_select_file_policy.h"
12 #include "chrome/browser/ui/extensions/shell_window.h" 13 #include "chrome/browser/ui/extensions/shell_window.h"
13 #include "chrome/common/extensions/api/file_system.h" 14 #include "chrome/common/extensions/api/file_system.h"
14 #include "chrome/common/extensions/permissions/api_permission.h" 15 #include "chrome/common/extensions/permissions/api_permission.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"
20 #include "webkit/fileapi/isolated_context.h" 21 #include "webkit/fileapi/isolated_context.h"
21 22
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 : public SelectFileDialog::Listener { 199 : public SelectFileDialog::Listener {
199 public: 200 public:
200 FilePicker(FileSystemChooseFileFunction* function, 201 FilePicker(FileSystemChooseFileFunction* function,
201 content::WebContents* web_contents, 202 content::WebContents* web_contents,
202 const FilePath& suggested_path, 203 const FilePath& suggested_path,
203 SelectFileDialog::Type picker_type, 204 SelectFileDialog::Type picker_type,
204 EntryType entry_type) 205 EntryType entry_type)
205 : suggested_path_(suggested_path), 206 : suggested_path_(suggested_path),
206 entry_type_(entry_type), 207 entry_type_(entry_type),
207 function_(function) { 208 function_(function) {
208 select_file_dialog_ = SelectFileDialog::Create(this); 209 select_file_dialog_ = SelectFileDialog::Create(
210 this, new ChromeSelectFilePolicy(web_contents));
209 SelectFileDialog::FileTypeInfo file_type_info; 211 SelectFileDialog::FileTypeInfo file_type_info;
210 FilePath::StringType extension = suggested_path.Extension(); 212 FilePath::StringType extension = suggested_path.Extension();
211 if (!extension.empty()) { 213 if (!extension.empty()) {
212 extension.erase(extension.begin()); // drop the . 214 extension.erase(extension.begin()); // drop the .
213 file_type_info.extensions.resize(1); 215 file_type_info.extensions.resize(1);
214 file_type_info.extensions[0].push_back(extension); 216 file_type_info.extensions[0].push_back(extension);
215 } 217 }
216 file_type_info.include_all_files = true; 218 file_type_info.include_all_files = true;
217 gfx::NativeWindow owning_window = web_contents ? 219 gfx::NativeWindow owning_window = web_contents ?
218 platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; 220 platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL;
(...skipping 12 matching lines...) Expand all
231 FileSelectionCanceled, 233 FileSelectionCanceled,
232 base::Unretained(this), static_cast<void*>(NULL))); 234 base::Unretained(this), static_cast<void*>(NULL)));
233 } 235 }
234 return; 236 return;
235 } 237 }
236 238
237 select_file_dialog_->SelectFile(picker_type, 239 select_file_dialog_->SelectFile(picker_type,
238 string16(), 240 string16(),
239 suggested_path, 241 suggested_path,
240 &file_type_info, 0, FILE_PATH_LITERAL(""), 242 &file_type_info, 0, FILE_PATH_LITERAL(""),
241 web_contents, owning_window, NULL); 243 owning_window, NULL);
242 } 244 }
243 245
244 virtual ~FilePicker() {} 246 virtual ~FilePicker() {}
245 247
246 private: 248 private:
247 // SelectFileDialog::Listener implementation. 249 // SelectFileDialog::Listener implementation.
248 virtual void FileSelected(const FilePath& path, 250 virtual void FileSelected(const FilePath& path,
249 int index, 251 int index,
250 void* params) OVERRIDE { 252 void* params) OVERRIDE {
251 function_->FileSelected(path, entry_type_); 253 function_->FileSelected(path, entry_type_);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 348
347 if (entry_type == WRITABLE && !HasFileSystemWritePermission()) { 349 if (entry_type == WRITABLE && !HasFileSystemWritePermission()) {
348 error_ = kRequiresFileSystemWriteError; 350 error_ = kRequiresFileSystemWriteError;
349 return false; 351 return false;
350 } 352 }
351 353
352 return ShowPicker(FilePath(), picker_type, entry_type); 354 return ShowPicker(FilePath(), picker_type, entry_type);
353 } 355 }
354 356
355 } // namespace extensions 357 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/download/save_package_file_picker_chromeos.cc ('k') | chrome/browser/file_select_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698