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