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 // The file contains the implementation of | 5 // The file contains the implementation of |
6 // fileBrowserHandlerInternal.selectFile extension function. | 6 // fileBrowserHandlerInternal.selectFile extension function. |
7 // When invoked, the function does the following: | 7 // When invoked, the function does the following: |
8 // - Verifies that the extension function was invoked as a result of user | 8 // - Verifies that the extension function was invoked as a result of user |
9 // gesture. | 9 // gesture. |
10 // - Display 'save as' dialog using FileSelectorImpl which waits for the user | 10 // - Display 'save as' dialog using FileSelectorImpl which waits for the user |
(...skipping 15 matching lines...) Expand all Loading... |
26 // selected file's full filesystem path (e.g. | 26 // selected file's full filesystem path (e.g. |
27 // /home/chronos/user/Downloads/foo) in ChildProcessSecurityPolicy. | 27 // /home/chronos/user/Downloads/foo) in ChildProcessSecurityPolicy. |
28 // - After the required file access permissions are granted, result object is | 28 // - After the required file access permissions are granted, result object is |
29 // created and returned back. | 29 // created and returned back. |
30 | 30 |
31 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handler_a
pi.h" | 31 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handler_a
pi.h" |
32 | 32 |
33 #include "base/bind.h" | 33 #include "base/bind.h" |
34 #include "base/files/file_path.h" | 34 #include "base/files/file_path.h" |
35 #include "base/memory/scoped_ptr.h" | 35 #include "base/memory/scoped_ptr.h" |
36 #include "base/message_loop/message_loop_proxy.h" | 36 #include "base/thread_task_runner_handle.h" |
37 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 37 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
38 #include "chrome/browser/ui/browser.h" | 38 #include "chrome/browser/ui/browser.h" |
39 #include "chrome/browser/ui/browser_window.h" | 39 #include "chrome/browser/ui/browser_window.h" |
40 #include "chrome/browser/ui/chrome_select_file_policy.h" | 40 #include "chrome/browser/ui/chrome_select_file_policy.h" |
41 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
42 #include "chrome/common/extensions/api/file_browser_handler_internal.h" | 42 #include "chrome/common/extensions/api/file_browser_handler_internal.h" |
43 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
44 #include "content/public/browser/child_process_security_policy.h" | 44 #include "content/public/browser/child_process_security_policy.h" |
45 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
46 #include "content/public/browser/render_view_host.h" | 46 #include "content/public/browser/render_view_host.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 const std::vector<std::string>& allowed_extensions, | 171 const std::vector<std::string>& allowed_extensions, |
172 Browser* browser, | 172 Browser* browser, |
173 FileBrowserHandlerInternalSelectFileFunction* function) { | 173 FileBrowserHandlerInternalSelectFileFunction* function) { |
174 // We will hold reference to the function until it is notified of selection | 174 // We will hold reference to the function until it is notified of selection |
175 // result. | 175 // result. |
176 function_ = function; | 176 function_ = function; |
177 | 177 |
178 if (!StartSelectFile(suggested_name, allowed_extensions, browser)) { | 178 if (!StartSelectFile(suggested_name, allowed_extensions, browser)) { |
179 // If the dialog wasn't launched, let's asynchronously report failure to the | 179 // If the dialog wasn't launched, let's asynchronously report failure to the |
180 // function. | 180 // function. |
181 base::MessageLoopProxy::current()->PostTask(FROM_HERE, | 181 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 182 FROM_HERE, |
182 base::Bind(&FileSelectorImpl::FileSelectionCanceled, | 183 base::Bind(&FileSelectorImpl::FileSelectionCanceled, |
183 base::Unretained(this), static_cast<void*>(NULL))); | 184 base::Unretained(this), static_cast<void*>(NULL))); |
184 } | 185 } |
185 } | 186 } |
186 | 187 |
187 bool FileSelectorImpl::StartSelectFile( | 188 bool FileSelectorImpl::StartSelectFile( |
188 const base::FilePath& suggested_name, | 189 const base::FilePath& suggested_name, |
189 const std::vector<std::string>& allowed_extensions, | 190 const std::vector<std::string>& allowed_extensions, |
190 Browser* browser) { | 191 Browser* browser) { |
191 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 192 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 result->entry->file_system_name = entry_definition.file_system_name; | 366 result->entry->file_system_name = entry_definition.file_system_name; |
366 result->entry->file_system_root = entry_definition.file_system_root_url; | 367 result->entry->file_system_root = entry_definition.file_system_root_url; |
367 result->entry->file_full_path = | 368 result->entry->file_full_path = |
368 "/" + entry_definition.full_path.AsUTF8Unsafe(); | 369 "/" + entry_definition.full_path.AsUTF8Unsafe(); |
369 result->entry->file_is_directory = entry_definition.is_directory; | 370 result->entry->file_is_directory = entry_definition.is_directory; |
370 } | 371 } |
371 | 372 |
372 results_ = SelectFile::Results::Create(*result); | 373 results_ = SelectFile::Results::Create(*result); |
373 SendResponse(true); | 374 SendResponse(true); |
374 } | 375 } |
OLD | NEW |