| 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 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" | 5 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/i18n/case_conversion.h" | 15 #include "base/i18n/case_conversion.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/task_scheduler/post_task.h" |
| 19 #include "chrome/browser/chromeos/drive/file_system_util.h" | 20 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 20 #include "chrome/browser/chromeos/file_manager/app_id.h" | 21 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 22 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
| 22 #include "chrome/browser/chromeos/file_manager/open_with_browser.h" | 23 #include "chrome/browser/chromeos/file_manager/open_with_browser.h" |
| 23 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 24 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 24 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
| 27 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" | 28 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" |
| 28 #include "chrome/common/extensions/api/file_manager_private.h" | 29 #include "chrome/common/extensions/api/file_manager_private.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 212 |
| 212 DISALLOW_COPY_AND_ASSIGN(FileBrowserHandlerExecutor); | 213 DISALLOW_COPY_AND_ASSIGN(FileBrowserHandlerExecutor); |
| 213 }; | 214 }; |
| 214 | 215 |
| 215 // static | 216 // static |
| 216 std::unique_ptr<FileDefinitionList> | 217 std::unique_ptr<FileDefinitionList> |
| 217 FileBrowserHandlerExecutor::SetupFileAccessPermissions( | 218 FileBrowserHandlerExecutor::SetupFileAccessPermissions( |
| 218 scoped_refptr<storage::FileSystemContext> file_system_context_handler, | 219 scoped_refptr<storage::FileSystemContext> file_system_context_handler, |
| 219 const scoped_refptr<const Extension>& handler_extension, | 220 const scoped_refptr<const Extension>& handler_extension, |
| 220 const std::vector<FileSystemURL>& file_urls) { | 221 const std::vector<FileSystemURL>& file_urls) { |
| 221 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 222 DCHECK(handler_extension.get()); | 222 DCHECK(handler_extension.get()); |
| 223 | 223 |
| 224 storage::ExternalFileSystemBackend* backend = | 224 storage::ExternalFileSystemBackend* backend = |
| 225 file_system_context_handler->external_backend(); | 225 file_system_context_handler->external_backend(); |
| 226 | 226 |
| 227 std::unique_ptr<FileDefinitionList> file_definition_list( | 227 std::unique_ptr<FileDefinitionList> file_definition_list( |
| 228 new FileDefinitionList); | 228 new FileDefinitionList); |
| 229 for (size_t i = 0; i < file_urls.size(); ++i) { | 229 for (size_t i = 0; i < file_urls.size(); ++i) { |
| 230 const FileSystemURL& url = file_urls[i]; | 230 const FileSystemURL& url = file_urls[i]; |
| 231 | 231 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 const std::vector<FileSystemURL>& file_urls, | 283 const std::vector<FileSystemURL>& file_urls, |
| 284 const file_tasks::FileTaskFinishedCallback& done) { | 284 const file_tasks::FileTaskFinishedCallback& done) { |
| 285 done_ = done; | 285 done_ = done; |
| 286 | 286 |
| 287 // Get file system context for the extension to which onExecute event will be | 287 // Get file system context for the extension to which onExecute event will be |
| 288 // sent. The file access permissions will be granted to the extension in the | 288 // sent. The file access permissions will be granted to the extension in the |
| 289 // file system context for the files in |file_urls|. | 289 // file system context for the files in |file_urls|. |
| 290 scoped_refptr<storage::FileSystemContext> file_system_context( | 290 scoped_refptr<storage::FileSystemContext> file_system_context( |
| 291 util::GetFileSystemContextForExtensionId(profile_, extension_->id())); | 291 util::GetFileSystemContextForExtensionId(profile_, extension_->id())); |
| 292 | 292 |
| 293 BrowserThread::PostTaskAndReplyWithResult( | 293 base::PostTaskWithTraitsAndReplyWithResult( |
| 294 BrowserThread::FILE, | 294 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING}, |
| 295 FROM_HERE, | 295 base::Bind(&SetupFileAccessPermissions, file_system_context, extension_, |
| 296 base::Bind(&SetupFileAccessPermissions, | |
| 297 file_system_context, | |
| 298 extension_, | |
| 299 file_urls), | 296 file_urls), |
| 300 base::Bind(&FileBrowserHandlerExecutor::ExecuteAfterSetupFileAccess, | 297 base::Bind(&FileBrowserHandlerExecutor::ExecuteAfterSetupFileAccess, |
| 301 weak_ptr_factory_.GetWeakPtr())); | 298 weak_ptr_factory_.GetWeakPtr())); |
| 302 } | 299 } |
| 303 | 300 |
| 304 void FileBrowserHandlerExecutor::ExecuteAfterSetupFileAccess( | 301 void FileBrowserHandlerExecutor::ExecuteAfterSetupFileAccess( |
| 305 std::unique_ptr<FileDefinitionList> file_definition_list) { | 302 std::unique_ptr<FileDefinitionList> file_definition_list) { |
| 306 // Outlives the conversion process, since bound to the callback. | 303 // Outlives the conversion process, since bound to the callback. |
| 307 const FileDefinitionList& file_definition_list_ref = | 304 const FileDefinitionList& file_definition_list_ref = |
| 308 *file_definition_list.get(); | 305 *file_definition_list.get(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 if (common_handlers.empty()) | 524 if (common_handlers.empty()) |
| 528 return FileBrowserHandlerList(); | 525 return FileBrowserHandlerList(); |
| 529 } | 526 } |
| 530 } | 527 } |
| 531 | 528 |
| 532 return common_handlers; | 529 return common_handlers; |
| 533 } | 530 } |
| 534 | 531 |
| 535 } // namespace file_browser_handlers | 532 } // namespace file_browser_handlers |
| 536 } // namespace file_manager | 533 } // namespace file_manager |
| OLD | NEW |