| 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_tasks.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_tasks.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/extensions/file_manager/file_tasks.h" | 7 #include "chrome/browser/chromeos/extensions/file_manager/file_tasks.h" |
| 8 #include "chrome/browser/chromeos/extensions/file_manager/fileapi_util.h" | 8 #include "chrome/browser/chromeos/extensions/file_manager/fileapi_util.h" |
| 9 #include "chrome/browser/chromeos/extensions/file_manager/mime_util.h" | 9 #include "chrome/browser/chromeos/extensions/file_manager/mime_util.h" |
| 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 return std::set<std::string>(); | 51 return std::set<std::string>(); |
| 52 // We'll skip empty MIME types. | 52 // We'll skip empty MIME types. |
| 53 if (!mime_type.empty()) | 53 if (!mime_type.empty()) |
| 54 mime_types.insert(mime_type); | 54 mime_types.insert(mime_type); |
| 55 } | 55 } |
| 56 return mime_types; | 56 return mime_types; |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 ExecuteTaskFunction::ExecuteTaskFunction() { | 61 FileBrowserPrivateExecuteTaskFunction::FileBrowserPrivateExecuteTaskFunction() { |
| 62 } | 62 } |
| 63 | 63 |
| 64 ExecuteTaskFunction::~ExecuteTaskFunction() { | 64 FileBrowserPrivateExecuteTaskFunction:: |
| 65 ~FileBrowserPrivateExecuteTaskFunction() { |
| 65 } | 66 } |
| 66 | 67 |
| 67 bool ExecuteTaskFunction::RunImpl() { | 68 bool FileBrowserPrivateExecuteTaskFunction::RunImpl() { |
| 68 // First param is task id that was to the extension with getFileTasks call. | 69 // First param is task id that was to the extension with getFileTasks call. |
| 69 std::string task_id; | 70 std::string task_id; |
| 70 if (!args_->GetString(0, &task_id) || !task_id.size()) | 71 if (!args_->GetString(0, &task_id) || !task_id.size()) |
| 71 return false; | 72 return false; |
| 72 | 73 |
| 73 // TODO(kaznacheev): Crack the task_id here, store it in the Executor | 74 // TODO(kaznacheev): Crack the task_id here, store it in the Executor |
| 74 // and avoid passing it around. | 75 // and avoid passing it around. |
| 75 | 76 |
| 76 // The second param is the list of files that need to be executed with this | 77 // The second param is the list of files that need to be executed with this |
| 77 // task. | 78 // task. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 108 } | 109 } |
| 109 | 110 |
| 110 int32 tab_id = file_manager::util::GetTabId(dispatcher()); | 111 int32 tab_id = file_manager::util::GetTabId(dispatcher()); |
| 111 return file_manager::file_tasks::ExecuteFileTask( | 112 return file_manager::file_tasks::ExecuteFileTask( |
| 112 profile(), | 113 profile(), |
| 113 source_url(), | 114 source_url(), |
| 114 extension_->id(), | 115 extension_->id(), |
| 115 tab_id, | 116 tab_id, |
| 116 task, | 117 task, |
| 117 file_urls, | 118 file_urls, |
| 118 base::Bind(&ExecuteTaskFunction::OnTaskExecuted, this)); | 119 base::Bind(&FileBrowserPrivateExecuteTaskFunction::OnTaskExecuted, this)); |
| 119 } | 120 } |
| 120 | 121 |
| 121 void ExecuteTaskFunction::OnTaskExecuted(bool success) { | 122 void FileBrowserPrivateExecuteTaskFunction::OnTaskExecuted(bool success) { |
| 122 SetResult(new base::FundamentalValue(success)); | 123 SetResult(new base::FundamentalValue(success)); |
| 123 SendResponse(true); | 124 SendResponse(true); |
| 124 } | 125 } |
| 125 | 126 |
| 126 GetFileTasksFunction::GetFileTasksFunction() { | 127 FileBrowserPrivateGetFileTasksFunction:: |
| 128 FileBrowserPrivateGetFileTasksFunction() { |
| 127 } | 129 } |
| 128 | 130 |
| 129 GetFileTasksFunction::~GetFileTasksFunction() { | 131 FileBrowserPrivateGetFileTasksFunction:: |
| 132 ~FileBrowserPrivateGetFileTasksFunction() { |
| 130 } | 133 } |
| 131 | 134 |
| 132 bool GetFileTasksFunction::RunImpl() { | 135 bool FileBrowserPrivateGetFileTasksFunction::RunImpl() { |
| 133 // First argument is the list of files to get tasks for. | 136 // First argument is the list of files to get tasks for. |
| 134 ListValue* files_list = NULL; | 137 ListValue* files_list = NULL; |
| 135 if (!args_->GetList(0, &files_list)) | 138 if (!args_->GetList(0, &files_list)) |
| 136 return false; | 139 return false; |
| 137 | 140 |
| 138 if (files_list->GetSize() == 0) | 141 if (files_list->GetSize() == 0) |
| 139 return false; | 142 return false; |
| 140 | 143 |
| 141 // Second argument is the list of mime types of each of the files in the list. | 144 // Second argument is the list of mime types of each of the files in the list. |
| 142 ListValue* mime_types_list = NULL; | 145 ListValue* mime_types_list = NULL; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 192 |
| 190 file_manager::file_tasks::FindAllTypesOfTasks(profile_, | 193 file_manager::file_tasks::FindAllTypesOfTasks(profile_, |
| 191 path_mime_set, | 194 path_mime_set, |
| 192 file_urls, | 195 file_urls, |
| 193 file_paths, | 196 file_paths, |
| 194 result_list); | 197 result_list); |
| 195 SendResponse(true); | 198 SendResponse(true); |
| 196 return true; | 199 return true; |
| 197 } | 200 } |
| 198 | 201 |
| 199 SetDefaultTaskFunction::SetDefaultTaskFunction() { | 202 FileBrowserPrivateSetDefaultTaskFunction:: |
| 203 FileBrowserPrivateSetDefaultTaskFunction() { |
| 200 } | 204 } |
| 201 | 205 |
| 202 SetDefaultTaskFunction::~SetDefaultTaskFunction() { | 206 FileBrowserPrivateSetDefaultTaskFunction:: |
| 207 ~FileBrowserPrivateSetDefaultTaskFunction() { |
| 203 } | 208 } |
| 204 | 209 |
| 205 bool SetDefaultTaskFunction::RunImpl() { | 210 bool FileBrowserPrivateSetDefaultTaskFunction::RunImpl() { |
| 206 // First param is task id that was to the extension with setDefaultTask call. | 211 // First param is task id that was to the extension with setDefaultTask call. |
| 207 std::string task_id; | 212 std::string task_id; |
| 208 if (!args_->GetString(0, &task_id) || !task_id.size()) | 213 if (!args_->GetString(0, &task_id) || !task_id.size()) |
| 209 return false; | 214 return false; |
| 210 | 215 |
| 211 base::ListValue* file_url_list; | 216 base::ListValue* file_url_list; |
| 212 if (!args_->GetList(1, &file_url_list)) | 217 if (!args_->GetList(1, &file_url_list)) |
| 213 return false; | 218 return false; |
| 214 | 219 |
| 215 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 220 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 240 } | 245 } |
| 241 | 246 |
| 242 file_manager::file_tasks::UpdateDefaultTask(profile_->GetPrefs(), | 247 file_manager::file_tasks::UpdateDefaultTask(profile_->GetPrefs(), |
| 243 task_id, | 248 task_id, |
| 244 suffixes, | 249 suffixes, |
| 245 mime_types); | 250 mime_types); |
| 246 return true; | 251 return true; |
| 247 } | 252 } |
| 248 | 253 |
| 249 } // namespace extensions | 254 } // namespace extensions |
| OLD | NEW |