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_file_syste
m.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste
m.h" |
6 | 6 |
7 #include <sys/statvfs.h> | 7 #include <sys/statvfs.h> |
8 | 8 |
9 #include "base/posix/eintr_wrapper.h" | 9 #include "base/posix/eintr_wrapper.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chromeos/drive/drive.pb.h" | 15 #include "chrome/browser/chromeos/drive/drive.pb.h" |
16 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 16 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
17 #include "chrome/browser/chromeos/drive/file_system_util.h" | 17 #include "chrome/browser/chromeos/drive/file_system_util.h" |
18 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" | 18 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" |
19 #include "chrome/browser/chromeos/extensions/file_manager/event_router_factory.h
" | 19 #include "chrome/browser/chromeos/extensions/file_manager/event_router_factory.h
" |
20 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 20 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
22 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 22 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
23 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 23 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 24 #include "chrome/browser/drive/drive_api_util.h" |
24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
26 #include "chrome/common/extensions/api/file_manager_private.h" | 27 #include "chrome/common/extensions/api/file_manager_private.h" |
27 #include "chrome/common/extensions/api/file_manager_private_internal.h" | 28 #include "chrome/common/extensions/api/file_manager_private_internal.h" |
28 #include "chromeos/disks/disk_mount_manager.h" | 29 #include "chromeos/disks/disk_mount_manager.h" |
29 #include "content/public/browser/child_process_security_policy.h" | 30 #include "content/public/browser/child_process_security_policy.h" |
30 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
31 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
32 #include "content/public/common/url_constants.h" | 33 #include "content/public/common/url_constants.h" |
33 #include "net/base/escape.h" | 34 #include "net/base/escape.h" |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 entry->file_full_path = | 703 entry->file_full_path = |
703 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe(); | 704 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe(); |
704 entry->file_is_directory = entry_definition_list->at(i).is_directory; | 705 entry->file_is_directory = entry_definition_list->at(i).is_directory; |
705 entries.push_back(entry); | 706 entries.push_back(entry); |
706 } | 707 } |
707 | 708 |
708 results_ = extensions::api::file_manager_private_internal:: | 709 results_ = extensions::api::file_manager_private_internal:: |
709 ResolveIsolatedEntries::Results::Create(entries); | 710 ResolveIsolatedEntries::Results::Create(entries); |
710 SendResponse(true); | 711 SendResponse(true); |
711 } | 712 } |
| 713 |
| 714 bool FileManagerPrivateComputeChecksumFunction::RunAsync() { |
| 715 using extensions::api::file_manager_private::ComputeChecksum::Params; |
| 716 const scoped_ptr<Params> params(Params::Create(*args_)); |
| 717 EXTENSION_FUNCTION_VALIDATE(params); |
| 718 |
| 719 if (params->file_url.empty()) { |
| 720 // TODO(kenobi): call SetError() |
| 721 return false; |
| 722 } |
| 723 |
| 724 scoped_refptr<storage::FileSystemContext> file_system_context = |
| 725 file_manager::util::GetFileSystemContextForRenderViewHost( |
| 726 GetProfile(), render_view_host()); |
| 727 |
| 728 storage::FileSystemURL file_url( |
| 729 file_system_context->CrackURL(GURL(params->file_url))); |
| 730 if (!file_url.is_valid()) { |
| 731 // TODO(kenobi): Call SetError() |
| 732 return false; |
| 733 } |
| 734 |
| 735 BrowserThread::PostTaskAndReplyWithResult( |
| 736 BrowserThread::FILE, FROM_HERE, |
| 737 base::Bind(&drive::util::GetMd5Digest, file_url.path()), |
| 738 base::Bind(&FileManagerPrivateComputeChecksumFunction::Respond, this)); |
| 739 |
| 740 return true; |
| 741 } |
| 742 |
| 743 void FileManagerPrivateComputeChecksumFunction::Respond( |
| 744 const std::string& hash) { |
| 745 SetResult(new base::StringValue(hash)); |
| 746 SendResponse(true); |
| 747 } |
| 748 |
712 } // namespace extensions | 749 } // namespace extensions |
OLD | NEW |