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/chromeos/extensions/file_browser_handler_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_handler_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 "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/chromeos/extensions/file_handler_util.h" | 13 #include "chrome/browser/chromeos/extensions/file_handler_util.h" |
14 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 14 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/chrome_select_file_policy.h" |
18 #include "chrome/browser/ui/select_file_dialog.h" | 19 #include "chrome/browser/ui/select_file_dialog.h" |
19 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
20 #include "chrome/common/extensions/api/file_browser_handler_internal.h" | 21 #include "chrome/common/extensions/api/file_browser_handler_internal.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/child_process_security_policy.h" | 23 #include "content/public/browser/child_process_security_policy.h" |
23 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
24 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
25 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
26 #include "webkit/fileapi/file_system_context.h" | 27 #include "webkit/fileapi/file_system_context.h" |
27 #include "webkit/fileapi/file_system_mount_point_provider.h" | 28 #include "webkit/fileapi/file_system_mount_point_provider.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 DCHECK(!dialog_.get()); | 117 DCHECK(!dialog_.get()); |
117 DCHECK(browser); | 118 DCHECK(browser); |
118 | 119 |
119 if (!browser->window()) | 120 if (!browser->window()) |
120 return false; | 121 return false; |
121 | 122 |
122 TabContents* tab_contents = browser->GetActiveTabContents(); | 123 TabContents* tab_contents = browser->GetActiveTabContents(); |
123 if (!tab_contents) | 124 if (!tab_contents) |
124 return false; | 125 return false; |
125 | 126 |
126 dialog_ = SelectFileDialog::Create(this); | 127 dialog_ = SelectFileDialog::Create( |
| 128 this, new ChromeSelectFilePolicy(tab_contents->web_contents())); |
| 129 |
127 dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, | 130 dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, |
128 string16() /* dialog title*/, suggested_name, | 131 string16() /* dialog title*/, suggested_name, |
129 NULL /* allowed file types */, 0 /* file type index */, | 132 NULL /* allowed file types */, 0 /* file type index */, |
130 std::string() /* default file extension */, tab_contents->web_contents(), | 133 std::string() /* default file extension */, |
131 browser->window()->GetNativeWindow(), NULL /* params */); | 134 browser->window()->GetNativeWindow(), NULL /* params */); |
132 | 135 |
133 return dialog_->IsRunning(browser->window()->GetNativeWindow()); | 136 return dialog_->IsRunning(browser->window()->GetNativeWindow()); |
134 } | 137 } |
135 | 138 |
136 void FileSelectorImpl::FileSelected( | 139 void FileSelectorImpl::FileSelected( |
137 const FilePath& path, int index, void* params) { | 140 const FilePath& path, int index, void* params) { |
138 SendResponse(true, path); | 141 SendResponse(true, path); |
139 delete this; | 142 delete this; |
140 } | 143 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 result->set_function_for_test(this); | 318 result->set_function_for_test(this); |
316 return result; | 319 return result; |
317 } | 320 } |
318 return new FileSelectorImpl(this); | 321 return new FileSelectorImpl(this); |
319 } | 322 } |
320 | 323 |
321 FileSelector* FileHandlerSelectFileFunction::file_selector_for_test_ = NULL; | 324 FileSelector* FileHandlerSelectFileFunction::file_selector_for_test_ = NULL; |
322 | 325 |
323 bool FileHandlerSelectFileFunction::gesture_check_disabled_for_test_ = false; | 326 bool FileHandlerSelectFileFunction::gesture_check_disabled_for_test_ = false; |
324 | 327 |
OLD | NEW |