| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_manager/private_api_dialog.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_dialog.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 7 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
| 8 #include "chrome/browser/ui/views/select_file_dialog_extension.h" | 8 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "ui/shell_dialogs/selected_file_info.h" | 10 #include "ui/shell_dialogs/selected_file_info.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 bool SelectFileFunction::RunImpl() { | 35 bool SelectFileFunction::RunImpl() { |
| 36 if (args_->GetSize() != 4) { | 36 if (args_->GetSize() != 4) { |
| 37 return false; | 37 return false; |
| 38 } | 38 } |
| 39 std::string file_url; | 39 std::string file_url; |
| 40 args_->GetString(0, &file_url); | 40 args_->GetString(0, &file_url); |
| 41 std::vector<GURL> file_paths; | 41 std::vector<GURL> file_paths; |
| 42 file_paths.push_back(GURL(file_url)); | 42 file_paths.push_back(GURL(file_url)); |
| 43 bool for_opening = false; | 43 bool for_opening = false; |
| 44 args_->GetBoolean(2, &for_opening); | 44 args_->GetBoolean(2, &for_opening); |
| 45 bool need_local_path = false; |
| 46 args_->GetBoolean(3, &need_local_path); |
| 47 |
| 48 util::GetSelectedFileInfoLocalPathOption option = |
| 49 util::NO_LOCAL_PATH_RESOLUTION; |
| 50 if (need_local_path) { |
| 51 option = for_opening ? |
| 52 util::NEED_LOCAL_PATH_FOR_OPENING : util::NEED_LOCAL_PATH_FOR_SAVING; |
| 53 } |
| 45 | 54 |
| 46 util::GetSelectedFileInfo( | 55 util::GetSelectedFileInfo( |
| 47 render_view_host(), | 56 render_view_host(), |
| 48 profile(), | 57 profile(), |
| 49 file_paths, | 58 file_paths, |
| 50 for_opening, | 59 option, |
| 51 base::Bind(&SelectFileFunction::GetSelectedFileInfoResponse, this)); | 60 base::Bind(&SelectFileFunction::GetSelectedFileInfoResponse, this)); |
| 52 return true; | 61 return true; |
| 53 } | 62 } |
| 54 | 63 |
| 55 void SelectFileFunction::GetSelectedFileInfoResponse( | 64 void SelectFileFunction::GetSelectedFileInfoResponse( |
| 56 const std::vector<ui::SelectedFileInfo>& files) { | 65 const std::vector<ui::SelectedFileInfo>& files) { |
| 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 58 if (files.size() != 1) { | 67 if (files.size() != 1) { |
| 59 SendResponse(false); | 68 SendResponse(false); |
| 60 return; | 69 return; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 83 | 92 |
| 84 std::string virtual_path; | 93 std::string virtual_path; |
| 85 size_t len = path_list->GetSize(); | 94 size_t len = path_list->GetSize(); |
| 86 std::vector<GURL> file_urls; | 95 std::vector<GURL> file_urls; |
| 87 file_urls.reserve(len); | 96 file_urls.reserve(len); |
| 88 for (size_t i = 0; i < len; ++i) { | 97 for (size_t i = 0; i < len; ++i) { |
| 89 path_list->GetString(i, &virtual_path); | 98 path_list->GetString(i, &virtual_path); |
| 90 file_urls.push_back(GURL(virtual_path)); | 99 file_urls.push_back(GURL(virtual_path)); |
| 91 } | 100 } |
| 92 | 101 |
| 102 bool need_local_path = false; |
| 103 args_->GetBoolean(1, &need_local_path); |
| 104 |
| 93 util::GetSelectedFileInfo( | 105 util::GetSelectedFileInfo( |
| 94 render_view_host(), | 106 render_view_host(), |
| 95 profile(), | 107 profile(), |
| 96 file_urls, | 108 file_urls, |
| 97 true, // for_opening | 109 need_local_path ? |
| 110 util::NEED_LOCAL_PATH_FOR_OPENING : util::NO_LOCAL_PATH_RESOLUTION, |
| 98 base::Bind(&SelectFilesFunction::GetSelectedFileInfoResponse, this)); | 111 base::Bind(&SelectFilesFunction::GetSelectedFileInfoResponse, this)); |
| 99 return true; | 112 return true; |
| 100 } | 113 } |
| 101 | 114 |
| 102 void SelectFilesFunction::GetSelectedFileInfoResponse( | 115 void SelectFilesFunction::GetSelectedFileInfoResponse( |
| 103 const std::vector<ui::SelectedFileInfo>& files) { | 116 const std::vector<ui::SelectedFileInfo>& files) { |
| 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 105 int32 tab_id = util::GetTabId(dispatcher()); | 118 int32 tab_id = util::GetTabId(dispatcher()); |
| 106 SelectFileDialogExtension::OnMultiFilesSelected(tab_id, files); | 119 SelectFileDialogExtension::OnMultiFilesSelected(tab_id, files); |
| 107 SendResponse(true); | 120 SendResponse(true); |
| 108 } | 121 } |
| 109 | 122 |
| 110 } // namespace file_manager | 123 } // namespace file_manager |
| OLD | NEW |