Chromium Code Reviews| 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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 using fileapi::FileSystemURL; | 43 using fileapi::FileSystemURL; |
| 44 | 44 |
| 45 namespace extensions { | 45 namespace extensions { |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 // Sets permissions for the Drive mount point so Files.app can access files | 48 // Sets permissions for the Drive mount point so Files.app can access files |
| 49 // in the mount point directory. It's safe to call this function even if | 49 // in the mount point directory. It's safe to call this function even if |
| 50 // Drive is disabled by the setting (i.e. prefs::kDisableDrive is true). | 50 // Drive is disabled by the setting (i.e. prefs::kDisableDrive is true). |
| 51 void SetDriveMountPointPermissions( | 51 void SetDriveMountPointPermissions( |
| 52 Profile* profile, | 52 Profile* profile, |
| 53 const std::string& extension_id, | 53 const std::string& extension_id, |
|
hashimoto
2014/01/28 10:55:13
nit: This is not used.
kinaba
2014/01/28 23:59:49
Done.
| |
| 54 content::RenderViewHost* render_view_host) { | 54 content::RenderViewHost* render_view_host) { |
| 55 if (!render_view_host || | 55 if (!render_view_host || !render_view_host->GetProcess()) |
| 56 !render_view_host->GetSiteInstance() || !render_view_host->GetProcess()) { | |
| 57 return; | 56 return; |
| 58 } | |
| 59 | 57 |
| 60 fileapi::ExternalFileSystemBackend* backend = | 58 fileapi::ExternalFileSystemBackend* backend = |
| 61 file_manager::util::GetFileSystemContextForRenderViewHost( | 59 file_manager::util::GetFileSystemContextForRenderViewHost( |
| 62 profile, render_view_host)->external_backend(); | 60 profile, render_view_host)->external_backend(); |
| 63 if (!backend) | 61 if (!backend) |
|
hashimoto
2014/01/28 10:55:13
nit: This code seems unnecessary because |backend|
kinaba
2014/01/28 23:59:49
Done.
| |
| 64 return; | 62 return; |
| 65 | 63 |
| 66 const base::FilePath mount_point = drive::util::GetDriveMountPointPath(); | 64 const base::FilePath mount_point = drive::util::GetDriveMountPointPath(); |
| 67 // Grant R/W permissions to drive 'folder'. File API layer still | 65 // Grant R/W permissions to drive 'folder'. File API layer still |
|
hashimoto
2014/01/28 10:55:13
nit: What does 'still' mean?
kinaba
2014/01/28 23:59:49
Just my guess but it's even though we grant permis
| |
| 68 // expects this to be satisfied. | 66 // expects this to be satisfied. |
| 69 ChildProcessSecurityPolicy::GetInstance()->GrantCreateReadWriteFile( | 67 ChildProcessSecurityPolicy::GetInstance()->GrantCreateReadWriteFile( |
| 70 render_view_host->GetProcess()->GetID(), mount_point); | 68 render_view_host->GetProcess()->GetID(), mount_point); |
|
kinaba
2014/01/28 23:59:49
Since now this is the only line executed in this f
| |
| 71 | |
| 72 base::FilePath mount_point_virtual; | |
| 73 if (backend->GetVirtualPath(mount_point, &mount_point_virtual)) | |
| 74 backend->GrantFileAccessToExtension(extension_id, mount_point_virtual); | |
| 75 } | 69 } |
| 76 | 70 |
| 77 // Retrieves total and remaining available size on |mount_path|. | 71 // Retrieves total and remaining available size on |mount_path|. |
| 78 void GetSizeStatsOnBlockingPool(const std::string& mount_path, | 72 void GetSizeStatsOnBlockingPool(const std::string& mount_path, |
| 79 uint64* total_size, | 73 uint64* total_size, |
| 80 uint64* remaining_size) { | 74 uint64* remaining_size) { |
| 81 struct statvfs stat = {}; // Zero-clear | 75 struct statvfs stat = {}; // Zero-clear |
| 82 if (HANDLE_EINTR(statvfs(mount_path.c_str(), &stat)) == 0) { | 76 if (HANDLE_EINTR(statvfs(mount_path.c_str(), &stat)) == 0) { |
| 83 *total_size = static_cast<uint64>(stat.f_blocks) * stat.f_frsize; | 77 *total_size = static_cast<uint64>(stat.f_blocks) * stat.f_frsize; |
| 84 *remaining_size = static_cast<uint64>(stat.f_bavail) * stat.f_frsize; | 78 *remaining_size = static_cast<uint64>(stat.f_bavail) * stat.f_frsize; |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 573 // We don't much take care about the result of cancellation. | 567 // We don't much take care about the result of cancellation. |
| 574 BrowserThread::PostTask( | 568 BrowserThread::PostTask( |
| 575 BrowserThread::IO, | 569 BrowserThread::IO, |
| 576 FROM_HERE, | 570 FROM_HERE, |
| 577 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id)); | 571 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id)); |
| 578 SendResponse(true); | 572 SendResponse(true); |
| 579 return true; | 573 return true; |
| 580 } | 574 } |
| 581 | 575 |
| 582 } // namespace extensions | 576 } // namespace extensions |
| OLD | NEW |