Chromium Code Reviews| 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/extensions/file_browser_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1010 this, | 1010 this, |
| 1011 mount_type_str)); | 1011 mount_type_str)); |
| 1012 break; | 1012 break; |
| 1013 } | 1013 } |
| 1014 } | 1014 } |
| 1015 #endif // defined(OS_CHROMEOS) | 1015 #endif // defined(OS_CHROMEOS) |
| 1016 | 1016 |
| 1017 return true; | 1017 return true; |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 void AddMountFunction::GrantFilePermissionsToHost(const FilePath& path, | |
| 1021 int permissions) { | |
| 1022 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | |
| 1023 render_view_host()->GetProcess()->GetID(), path, permissions); | |
| 1024 } | |
| 1020 | 1025 |
| 1021 void AddMountFunction::AddGDataMountPoint() { | 1026 void AddMountFunction::AddGDataMountPoint() { |
| 1022 fileapi::ExternalFileSystemMountPointProvider* provider = | 1027 fileapi::ExternalFileSystemMountPointProvider* provider = |
| 1023 BrowserContext::GetFileSystemContext(profile_)->external_provider(); | 1028 BrowserContext::GetFileSystemContext(profile_)->external_provider(); |
| 1024 const FilePath mount_point = gdata::util::GetGDataMountPointPath(); | 1029 const FilePath mount_point = gdata::util::GetGDataMountPointPath(); |
| 1025 if (!provider || provider->HasMountPoint(mount_point)) | 1030 if (!provider || provider->HasMountPoint(mount_point)) |
| 1026 return; | 1031 return; |
| 1027 | 1032 |
| 1028 // Grant R/W permissions to gdata 'folder'. File API layer still | 1033 // Grant R/W permissions to gdata 'folder'. File API layer still |
| 1029 // expects this to be satisfied. | 1034 // expects this to be satisfied. |
| 1030 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 1035 GrantFilePermissionsToHost(mount_point, |
| 1031 render_view_host()->GetProcess()->GetID(), mount_point, | 1036 file_handler_util::GetReadWritePermissions()); |
| 1032 file_handler_util::GetReadWritePermissions()); | 1037 |
| 1038 const gdata::GDataFileSystem* gdata_file_system = | |
| 1039 gdata::GDataFileSystemFactory::GetForProfile(profile_); | |
| 1040 | |
| 1041 // We check permissions for raw cache file paths only for read-only | |
| 1042 // operations (when fileEntry.file() is called), so read only permissions | |
| 1043 // should be sufficient for all cache paths. For the rest of supported | |
| 1044 // operations the file access check is done for gdata/ paths. | |
| 1045 GrantFilePermissionsToHost(gdata_file_system->GetGDataCacheTmpDirectory(), | |
| 1046 file_handler_util::GetReadOnlyPermissions()); | |
| 1047 GrantFilePermissionsToHost(gdata_file_system->GetGDataCachePinnedDirectory(), | |
| 1048 file_handler_util::GetReadOnlyPermissions()); | |
|
satorux1
2012/03/22 22:28:29
PinnedDirectory only contains symlinks, and the re
tonibarzic
2012/03/22 23:38:20
Yeah, my bad... that should have been Persistent..
| |
| 1033 | 1049 |
| 1034 provider->AddRemoteMountPoint(mount_point, | 1050 provider->AddRemoteMountPoint(mount_point, |
| 1035 new gdata::GDataFileSystemProxy(profile_)); | 1051 new gdata::GDataFileSystemProxy(profile_)); |
| 1052 FilePath mount_point_virtual; | |
| 1053 if (provider->GetVirtualPath(mount_point, &mount_point_virtual)) | |
| 1054 provider->GrantFileAccessToExtension(extension_id(), mount_point_virtual); | |
| 1036 } | 1055 } |
| 1037 | 1056 |
| 1038 void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) { | 1057 void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) { |
| 1039 chromeos::MountError error_code = error == gdata::HTTP_SUCCESS ? | 1058 chromeos::MountError error_code = error == gdata::HTTP_SUCCESS ? |
| 1040 chromeos::MOUNT_ERROR_NONE : chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; | 1059 chromeos::MOUNT_ERROR_NONE : chromeos::MOUNT_ERROR_NOT_AUTHENTICATED; |
| 1041 DiskMountManager::MountPointInfo mount_info( | 1060 DiskMountManager::MountPointInfo mount_info( |
| 1042 gdata::util::GetGDataMountPointPathAsString(), | 1061 gdata::util::GetGDataMountPointPathAsString(), |
| 1043 gdata::util::GetGDataMountPointPathAsString(), | 1062 gdata::util::GetGDataMountPointPathAsString(), |
| 1044 chromeos::MOUNT_TYPE_GDATA, | 1063 chromeos::MOUNT_TYPE_GDATA, |
| 1045 chromeos::disks::MOUNT_CONDITION_NONE); | 1064 chromeos::disks::MOUNT_CONDITION_NONE); |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1841 source_url_.GetOrigin(), | 1860 source_url_.GetOrigin(), |
| 1842 &file_url)) { | 1861 &file_url)) { |
| 1843 result->SetString("fileUrl", file_url.spec()); | 1862 result->SetString("fileUrl", file_url.spec()); |
| 1844 } | 1863 } |
| 1845 | 1864 |
| 1846 responses->Append(result.release()); | 1865 responses->Append(result.release()); |
| 1847 } | 1866 } |
| 1848 result_.reset(responses.release()); | 1867 result_.reset(responses.release()); |
| 1849 SendResponse(true); | 1868 SendResponse(true); |
| 1850 } | 1869 } |
| OLD | NEW |