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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 converted.is_default = task.is_default(); | 209 converted.is_default = task.is_default(); |
210 converted.is_generic_file_handler = task.is_generic_file_handler(); | 210 converted.is_generic_file_handler = task.is_generic_file_handler(); |
211 results.push_back(std::move(converted)); | 211 results.push_back(std::move(converted)); |
212 } | 212 } |
213 | 213 |
214 results_ = extensions::api::file_manager_private_internal::GetFileTasks:: | 214 results_ = extensions::api::file_manager_private_internal::GetFileTasks:: |
215 Results::Create(results); | 215 Results::Create(results); |
216 SendResponse(true); | 216 SendResponse(true); |
217 } | 217 } |
218 | 218 |
219 bool FileManagerPrivateInternalSetDefaultTaskFunction::RunSync() { | 219 ExtensionFunction::ResponseAction |
| 220 FileManagerPrivateInternalSetDefaultTaskFunction::Run() { |
220 using extensions::api::file_manager_private_internal::SetDefaultTask::Params; | 221 using extensions::api::file_manager_private_internal::SetDefaultTask::Params; |
221 const std::unique_ptr<Params> params(Params::Create(*args_)); | 222 const std::unique_ptr<Params> params(Params::Create(*args_)); |
222 EXTENSION_FUNCTION_VALIDATE(params); | 223 EXTENSION_FUNCTION_VALIDATE(params); |
223 | 224 |
| 225 Profile* profile = Profile::FromBrowserContext(browser_context()); |
224 const scoped_refptr<storage::FileSystemContext> file_system_context = | 226 const scoped_refptr<storage::FileSystemContext> file_system_context = |
225 file_manager::util::GetFileSystemContextForRenderFrameHost( | 227 file_manager::util::GetFileSystemContextForRenderFrameHost( |
226 GetProfile(), render_frame_host()); | 228 profile, render_frame_host()); |
227 | 229 |
228 const std::set<std::string> suffixes = | 230 const std::set<std::string> suffixes = |
229 GetUniqueSuffixes(params->urls, file_system_context.get()); | 231 GetUniqueSuffixes(params->urls, file_system_context.get()); |
230 const std::set<std::string> mime_types = | 232 const std::set<std::string> mime_types = |
231 GetUniqueMimeTypes(params->mime_types); | 233 GetUniqueMimeTypes(params->mime_types); |
232 | 234 |
233 // If there weren't any mime_types, and all the suffixes were blank, | 235 // If there weren't any mime_types, and all the suffixes were blank, |
234 // then we "succeed", but don't actually associate with anything. | 236 // then we "succeed", but don't actually associate with anything. |
235 // Otherwise, any time we set the default on a file with no extension | 237 // Otherwise, any time we set the default on a file with no extension |
236 // on the local drive, we'd fail. | 238 // on the local drive, we'd fail. |
237 // TODO(gspencer): Fix file manager so that it never tries to set default in | 239 // TODO(gspencer): Fix file manager so that it never tries to set default in |
238 // cases where extensionless local files are part of the selection. | 240 // cases where extensionless local files are part of the selection. |
239 if (suffixes.empty() && mime_types.empty()) { | 241 if (suffixes.empty() && mime_types.empty()) { |
240 SetResult(base::MakeUnique<base::FundamentalValue>(true)); | 242 return RespondNow( |
241 return true; | 243 OneArgument(base::MakeUnique<base::FundamentalValue>(true))); |
242 } | 244 } |
243 | 245 |
244 file_manager::file_tasks::UpdateDefaultTask( | 246 file_manager::file_tasks::UpdateDefaultTask( |
245 GetProfile()->GetPrefs(), params->task_id, suffixes, mime_types); | 247 profile->GetPrefs(), params->task_id, suffixes, mime_types); |
246 return true; | 248 return RespondNow(NoArguments()); |
247 } | 249 } |
248 | 250 |
249 } // namespace extensions | 251 } // namespace extensions |
OLD | NEW |