| 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 16 matching lines...) Expand all Loading... |
| 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/message_loop/message_loop_proxy.h" |
| 37 #include "base/platform_file.h" | |
| 38 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 37 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
| 39 #include "chrome/browser/profiles/profile.h" | |
| 40 #include "chrome/browser/ui/browser.h" | 38 #include "chrome/browser/ui/browser.h" |
| 41 #include "chrome/browser/ui/browser_window.h" | 39 #include "chrome/browser/ui/browser_window.h" |
| 42 #include "chrome/browser/ui/chrome_select_file_policy.h" | 40 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 43 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 44 #include "chrome/common/extensions/api/file_browser_handler_internal.h" | 42 #include "chrome/common/extensions/api/file_browser_handler_internal.h" |
| 45 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
| 46 #include "content/public/browser/child_process_security_policy.h" | 44 #include "content/public/browser/child_process_security_policy.h" |
| 47 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
| 48 #include "content/public/browser/render_view_host.h" | 46 #include "content/public/browser/render_view_host.h" |
| 49 #include "content/public/browser/storage_partition.h" | |
| 50 #include "ui/shell_dialogs/select_file_dialog.h" | 47 #include "ui/shell_dialogs/select_file_dialog.h" |
| 51 #include "webkit/browser/fileapi/file_system_backend.h" | 48 #include "webkit/browser/fileapi/file_system_backend.h" |
| 52 #include "webkit/browser/fileapi/file_system_context.h" | 49 #include "webkit/browser/fileapi/file_system_context.h" |
| 53 #include "webkit/common/fileapi/file_system_info.h" | 50 #include "webkit/common/fileapi/file_system_info.h" |
| 54 #include "webkit/common/fileapi/file_system_util.h" | 51 #include "webkit/common/fileapi/file_system_util.h" |
| 55 | 52 |
| 56 using content::BrowserContext; | |
| 57 using content::BrowserThread; | 53 using content::BrowserThread; |
| 58 using extensions::api::file_browser_handler_internal::FileEntryInfo; | 54 using extensions::api::file_browser_handler_internal::FileEntryInfo; |
| 59 using file_manager::FileSelector; | 55 using file_manager::FileSelector; |
| 60 using file_manager::FileSelectorFactory; | 56 using file_manager::FileSelectorFactory; |
| 61 | 57 |
| 62 namespace SelectFile = | 58 namespace SelectFile = |
| 63 extensions::api::file_browser_handler_internal::SelectFile; | 59 extensions::api::file_browser_handler_internal::SelectFile; |
| 64 | 60 |
| 65 namespace { | 61 namespace { |
| 66 | 62 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 284 |
| 289 bool FileBrowserHandlerInternalSelectFileFunction::RunImpl() { | 285 bool FileBrowserHandlerInternalSelectFileFunction::RunImpl() { |
| 290 scoped_ptr<SelectFile::Params> params(SelectFile::Params::Create(*args_)); | 286 scoped_ptr<SelectFile::Params> params(SelectFile::Params::Create(*args_)); |
| 291 | 287 |
| 292 base::FilePath suggested_name(params->selection_params.suggested_name); | 288 base::FilePath suggested_name(params->selection_params.suggested_name); |
| 293 std::vector<std::string> allowed_extensions; | 289 std::vector<std::string> allowed_extensions; |
| 294 if (params->selection_params.allowed_file_extensions.get()) | 290 if (params->selection_params.allowed_file_extensions.get()) |
| 295 allowed_extensions = *params->selection_params.allowed_file_extensions; | 291 allowed_extensions = *params->selection_params.allowed_file_extensions; |
| 296 | 292 |
| 297 if (!user_gesture() && user_gesture_check_enabled_) { | 293 if (!user_gesture() && user_gesture_check_enabled_) { |
| 298 error_ = kNoUserGestureError; | 294 SetError(kNoUserGestureError); |
| 299 return false; | 295 return false; |
| 300 } | 296 } |
| 301 | 297 |
| 302 FileSelector* file_selector = file_selector_factory_->CreateFileSelector(); | 298 FileSelector* file_selector = file_selector_factory_->CreateFileSelector(); |
| 303 file_selector->SelectFile(suggested_name.BaseName(), | 299 file_selector->SelectFile(suggested_name.BaseName(), |
| 304 allowed_extensions, | 300 allowed_extensions, |
| 305 GetCurrentBrowser(), | 301 GetCurrentBrowser(), |
| 306 this); | 302 this); |
| 307 return true; | 303 return true; |
| 308 } | 304 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 result->entry.reset(new FileEntryInfo()); | 355 result->entry.reset(new FileEntryInfo()); |
| 360 result->entry->file_system_name = file_system_name_; | 356 result->entry->file_system_name = file_system_name_; |
| 361 result->entry->file_system_root = file_system_root_.spec(); | 357 result->entry->file_system_root = file_system_root_.spec(); |
| 362 result->entry->file_full_path = "/" + virtual_path_.AsUTF8Unsafe(); | 358 result->entry->file_full_path = "/" + virtual_path_.AsUTF8Unsafe(); |
| 363 result->entry->file_is_directory = false; | 359 result->entry->file_is_directory = false; |
| 364 } | 360 } |
| 365 | 361 |
| 366 results_ = SelectFile::Results::Create(*result); | 362 results_ = SelectFile::Results::Create(*result); |
| 367 SendResponse(true); | 363 SendResponse(true); |
| 368 } | 364 } |
| OLD | NEW |