| 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/fileapi/cros_mount_point_provider.h" | 5 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" | 14 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" |
| 15 #include "chrome/browser/chromeos/fileapi/remote_file_stream_writer.h" | 15 #include "chrome/browser/chromeos/fileapi/remote_file_stream_writer.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 const char kChromeUIScheme[] = "chrome"; | 33 const char kChromeUIScheme[] = "chrome"; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 namespace chromeos { | 37 namespace chromeos { |
| 38 | 38 |
| 39 // static | 39 // static |
| 40 bool CrosMountPointProvider::CanHandleURL(const fileapi::FileSystemURL& url) { | 40 bool FileSystemBackend::CanHandleURL(const fileapi::FileSystemURL& url) { |
| 41 if (!url.is_valid()) | 41 if (!url.is_valid()) |
| 42 return false; | 42 return false; |
| 43 return url.type() == fileapi::kFileSystemTypeNativeLocal || | 43 return url.type() == fileapi::kFileSystemTypeNativeLocal || |
| 44 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal || | 44 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal || |
| 45 url.type() == fileapi::kFileSystemTypeDrive; | 45 url.type() == fileapi::kFileSystemTypeDrive; |
| 46 } | 46 } |
| 47 | 47 |
| 48 CrosMountPointProvider::CrosMountPointProvider( | 48 FileSystemBackend::FileSystemBackend( |
| 49 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, | 49 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, |
| 50 scoped_refptr<fileapi::ExternalMountPoints> mount_points, | 50 scoped_refptr<fileapi::ExternalMountPoints> mount_points, |
| 51 fileapi::ExternalMountPoints* system_mount_points) | 51 fileapi::ExternalMountPoints* system_mount_points) |
| 52 : special_storage_policy_(special_storage_policy), | 52 : special_storage_policy_(special_storage_policy), |
| 53 file_access_permissions_(new FileAccessPermissions()), | 53 file_access_permissions_(new FileAccessPermissions()), |
| 54 local_file_util_(new fileapi::AsyncFileUtilAdapter( | 54 local_file_util_(new fileapi::AsyncFileUtilAdapter( |
| 55 new fileapi::IsolatedFileUtil())), | 55 new fileapi::IsolatedFileUtil())), |
| 56 mount_points_(mount_points), | 56 mount_points_(mount_points), |
| 57 system_mount_points_(system_mount_points) { | 57 system_mount_points_(system_mount_points) { |
| 58 } | 58 } |
| 59 | 59 |
| 60 CrosMountPointProvider::~CrosMountPointProvider() { | 60 FileSystemBackend::~FileSystemBackend() { |
| 61 } | 61 } |
| 62 | 62 |
| 63 void CrosMountPointProvider::AddSystemMountPoints() { | 63 void FileSystemBackend::AddSystemMountPoints() { |
| 64 // RegisterFileSystem() is no-op if the mount point with the same name | 64 // RegisterFileSystem() is no-op if the mount point with the same name |
| 65 // already exists, hence it's safe to call without checking if a mount | 65 // already exists, hence it's safe to call without checking if a mount |
| 66 // point already exists or not. | 66 // point already exists or not. |
| 67 | 67 |
| 68 // TODO(satorux): "Downloads" directory should probably be per-profile. For | 68 // TODO(satorux): "Downloads" directory should probably be per-profile. For |
| 69 // this to be per-profile, a unique directory path should be chosen per | 69 // this to be per-profile, a unique directory path should be chosen per |
| 70 // profile, and the mount point should be added to | 70 // profile, and the mount point should be added to |
| 71 // mount_points_. crbug.com/247236 | 71 // mount_points_. crbug.com/247236 |
| 72 base::FilePath home_path; | 72 base::FilePath home_path; |
| 73 if (PathService::Get(base::DIR_HOME, &home_path)) { | 73 if (PathService::Get(base::DIR_HOME, &home_path)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 84 system_mount_points_->RegisterFileSystem( | 84 system_mount_points_->RegisterFileSystem( |
| 85 "removable", | 85 "removable", |
| 86 fileapi::kFileSystemTypeNativeLocal, | 86 fileapi::kFileSystemTypeNativeLocal, |
| 87 chromeos::CrosDisksClient::GetRemovableDiskMountPoint()); | 87 chromeos::CrosDisksClient::GetRemovableDiskMountPoint()); |
| 88 system_mount_points_->RegisterFileSystem( | 88 system_mount_points_->RegisterFileSystem( |
| 89 "oem", | 89 "oem", |
| 90 fileapi::kFileSystemTypeRestrictedNativeLocal, | 90 fileapi::kFileSystemTypeRestrictedNativeLocal, |
| 91 base::FilePath(FILE_PATH_LITERAL("/usr/share/oem"))); | 91 base::FilePath(FILE_PATH_LITERAL("/usr/share/oem"))); |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool CrosMountPointProvider::CanHandleType(fileapi::FileSystemType type) const { | 94 bool FileSystemBackend::CanHandleType(fileapi::FileSystemType type) const { |
| 95 switch (type) { | 95 switch (type) { |
| 96 case fileapi::kFileSystemTypeExternal: | 96 case fileapi::kFileSystemTypeExternal: |
| 97 case fileapi::kFileSystemTypeDrive: | 97 case fileapi::kFileSystemTypeDrive: |
| 98 case fileapi::kFileSystemTypeRestrictedNativeLocal: | 98 case fileapi::kFileSystemTypeRestrictedNativeLocal: |
| 99 case fileapi::kFileSystemTypeNativeLocal: | 99 case fileapi::kFileSystemTypeNativeLocal: |
| 100 case fileapi::kFileSystemTypeNativeForPlatformApp: | 100 case fileapi::kFileSystemTypeNativeForPlatformApp: |
| 101 return true; | 101 return true; |
| 102 default: | 102 default: |
| 103 return false; | 103 return false; |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 void CrosMountPointProvider::OpenFileSystem( | 107 void FileSystemBackend::OpenFileSystem( |
| 108 const GURL& origin_url, | 108 const GURL& origin_url, |
| 109 fileapi::FileSystemType type, | 109 fileapi::FileSystemType type, |
| 110 fileapi::OpenFileSystemMode mode, | 110 fileapi::OpenFileSystemMode mode, |
| 111 const OpenFileSystemCallback& callback) { | 111 const OpenFileSystemCallback& callback) { |
| 112 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); | 112 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); |
| 113 // Nothing to validate for external filesystem. | 113 // Nothing to validate for external filesystem. |
| 114 callback.Run(base::PLATFORM_FILE_OK); | 114 callback.Run(base::PLATFORM_FILE_OK); |
| 115 } | 115 } |
| 116 | 116 |
| 117 fileapi::FileSystemQuotaUtil* CrosMountPointProvider::GetQuotaUtil() { | 117 fileapi::FileSystemQuotaUtil* FileSystemBackend::GetQuotaUtil() { |
| 118 // No quota support. | 118 // No quota support. |
| 119 return NULL; | 119 return NULL; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void CrosMountPointProvider::DeleteFileSystem( | 122 void FileSystemBackend::DeleteFileSystem( |
| 123 const GURL& origin_url, | 123 const GURL& origin_url, |
| 124 fileapi::FileSystemType type, | 124 fileapi::FileSystemType type, |
| 125 fileapi::FileSystemContext* context, | 125 fileapi::FileSystemContext* context, |
| 126 const DeleteFileSystemCallback& callback) { | 126 const DeleteFileSystemCallback& callback) { |
| 127 NOTREACHED(); | 127 NOTREACHED(); |
| 128 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 128 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool CrosMountPointProvider::IsAccessAllowed( | 131 bool FileSystemBackend::IsAccessAllowed( |
| 132 const fileapi::FileSystemURL& url) const { | 132 const fileapi::FileSystemURL& url) const { |
| 133 if (!url.is_valid()) | 133 if (!url.is_valid()) |
| 134 return false; | 134 return false; |
| 135 | 135 |
| 136 // Permit access to mount points from internal WebUI. | 136 // Permit access to mount points from internal WebUI. |
| 137 const GURL& origin_url = url.origin(); | 137 const GURL& origin_url = url.origin(); |
| 138 if (origin_url.SchemeIs(kChromeUIScheme)) | 138 if (origin_url.SchemeIs(kChromeUIScheme)) |
| 139 return true; | 139 return true; |
| 140 | 140 |
| 141 // No extra check is needed for isolated file systems. | 141 // No extra check is needed for isolated file systems. |
| 142 if (url.mount_type() == fileapi::kFileSystemTypeIsolated) | 142 if (url.mount_type() == fileapi::kFileSystemTypeIsolated) |
| 143 return true; | 143 return true; |
| 144 | 144 |
| 145 if (!CanHandleURL(url)) | 145 if (!CanHandleURL(url)) |
| 146 return false; | 146 return false; |
| 147 | 147 |
| 148 std::string extension_id = origin_url.host(); | 148 std::string extension_id = origin_url.host(); |
| 149 // Check first to make sure this extension has fileBrowserHander permissions. | 149 // Check first to make sure this extension has fileBrowserHander permissions. |
| 150 if (!special_storage_policy_->IsFileHandler(extension_id)) | 150 if (!special_storage_policy_->IsFileHandler(extension_id)) |
| 151 return false; | 151 return false; |
| 152 | 152 |
| 153 return file_access_permissions_->HasAccessPermission(extension_id, | 153 return file_access_permissions_->HasAccessPermission(extension_id, |
| 154 url.virtual_path()); | 154 url.virtual_path()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void CrosMountPointProvider::GrantFullAccessToExtension( | 157 void FileSystemBackend::GrantFullAccessToExtension( |
| 158 const std::string& extension_id) { | 158 const std::string& extension_id) { |
| 159 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); | 159 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); |
| 160 if (!special_storage_policy_->IsFileHandler(extension_id)) | 160 if (!special_storage_policy_->IsFileHandler(extension_id)) |
| 161 return; | 161 return; |
| 162 | 162 |
| 163 std::vector<fileapi::MountPoints::MountPointInfo> files; | 163 std::vector<fileapi::MountPoints::MountPointInfo> files; |
| 164 mount_points_->AddMountPointInfosTo(&files); | 164 mount_points_->AddMountPointInfosTo(&files); |
| 165 system_mount_points_->AddMountPointInfosTo(&files); | 165 system_mount_points_->AddMountPointInfosTo(&files); |
| 166 | 166 |
| 167 for (size_t i = 0; i < files.size(); ++i) { | 167 for (size_t i = 0; i < files.size(); ++i) { |
| 168 file_access_permissions_->GrantAccessPermission( | 168 file_access_permissions_->GrantAccessPermission( |
| 169 extension_id, | 169 extension_id, |
| 170 base::FilePath::FromUTF8Unsafe(files[i].name)); | 170 base::FilePath::FromUTF8Unsafe(files[i].name)); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 void CrosMountPointProvider::GrantFileAccessToExtension( | 174 void FileSystemBackend::GrantFileAccessToExtension( |
| 175 const std::string& extension_id, const base::FilePath& virtual_path) { | 175 const std::string& extension_id, const base::FilePath& virtual_path) { |
| 176 // All we care about here is access from extensions for now. | 176 // All we care about here is access from extensions for now. |
| 177 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); | 177 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); |
| 178 if (!special_storage_policy_->IsFileHandler(extension_id)) | 178 if (!special_storage_policy_->IsFileHandler(extension_id)) |
| 179 return; | 179 return; |
| 180 | 180 |
| 181 std::string id; | 181 std::string id; |
| 182 fileapi::FileSystemType type; | 182 fileapi::FileSystemType type; |
| 183 base::FilePath path; | 183 base::FilePath path; |
| 184 if (!mount_points_->CrackVirtualPath(virtual_path, &id, &type, &path) && | 184 if (!mount_points_->CrackVirtualPath(virtual_path, &id, &type, &path) && |
| 185 !system_mount_points_->CrackVirtualPath(virtual_path, | 185 !system_mount_points_->CrackVirtualPath(virtual_path, |
| 186 &id, &type, &path)) { | 186 &id, &type, &path)) { |
| 187 return; | 187 return; |
| 188 } | 188 } |
| 189 | 189 |
| 190 if (type == fileapi::kFileSystemTypeRestrictedNativeLocal) { | 190 if (type == fileapi::kFileSystemTypeRestrictedNativeLocal) { |
| 191 LOG(ERROR) << "Can't grant access for restricted mount point"; | 191 LOG(ERROR) << "Can't grant access for restricted mount point"; |
| 192 return; | 192 return; |
| 193 } | 193 } |
| 194 | 194 |
| 195 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path); | 195 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void CrosMountPointProvider::RevokeAccessForExtension( | 198 void FileSystemBackend::RevokeAccessForExtension( |
| 199 const std::string& extension_id) { | 199 const std::string& extension_id) { |
| 200 file_access_permissions_->RevokePermissions(extension_id); | 200 file_access_permissions_->RevokePermissions(extension_id); |
| 201 } | 201 } |
| 202 | 202 |
| 203 std::vector<base::FilePath> CrosMountPointProvider::GetRootDirectories() const { | 203 std::vector<base::FilePath> FileSystemBackend::GetRootDirectories() const { |
| 204 std::vector<fileapi::MountPoints::MountPointInfo> mount_points; | 204 std::vector<fileapi::MountPoints::MountPointInfo> mount_points; |
| 205 mount_points_->AddMountPointInfosTo(&mount_points); | 205 mount_points_->AddMountPointInfosTo(&mount_points); |
| 206 system_mount_points_->AddMountPointInfosTo(&mount_points); | 206 system_mount_points_->AddMountPointInfosTo(&mount_points); |
| 207 | 207 |
| 208 std::vector<base::FilePath> root_dirs; | 208 std::vector<base::FilePath> root_dirs; |
| 209 for (size_t i = 0; i < mount_points.size(); ++i) | 209 for (size_t i = 0; i < mount_points.size(); ++i) |
| 210 root_dirs.push_back(mount_points[i].path); | 210 root_dirs.push_back(mount_points[i].path); |
| 211 return root_dirs; | 211 return root_dirs; |
| 212 } | 212 } |
| 213 | 213 |
| 214 fileapi::FileSystemFileUtil* CrosMountPointProvider::GetFileUtil( | 214 fileapi::FileSystemFileUtil* FileSystemBackend::GetFileUtil( |
| 215 fileapi::FileSystemType type) { | 215 fileapi::FileSystemType type) { |
| 216 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || | 216 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || |
| 217 type == fileapi::kFileSystemTypeRestrictedNativeLocal); | 217 type == fileapi::kFileSystemTypeRestrictedNativeLocal); |
| 218 return local_file_util_->sync_file_util(); | 218 return local_file_util_->sync_file_util(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 fileapi::AsyncFileUtil* CrosMountPointProvider::GetAsyncFileUtil( | 221 fileapi::AsyncFileUtil* FileSystemBackend::GetAsyncFileUtil( |
| 222 fileapi::FileSystemType type) { | 222 fileapi::FileSystemType type) { |
| 223 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || | 223 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || |
| 224 type == fileapi::kFileSystemTypeRestrictedNativeLocal); | 224 type == fileapi::kFileSystemTypeRestrictedNativeLocal); |
| 225 return local_file_util_.get(); | 225 return local_file_util_.get(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 fileapi::CopyOrMoveFileValidatorFactory* | 228 fileapi::CopyOrMoveFileValidatorFactory* |
| 229 CrosMountPointProvider::GetCopyOrMoveFileValidatorFactory( | 229 FileSystemBackend::GetCopyOrMoveFileValidatorFactory( |
| 230 fileapi::FileSystemType type, base::PlatformFileError* error_code) { | 230 fileapi::FileSystemType type, base::PlatformFileError* error_code) { |
| 231 DCHECK(error_code); | 231 DCHECK(error_code); |
| 232 *error_code = base::PLATFORM_FILE_OK; | 232 *error_code = base::PLATFORM_FILE_OK; |
| 233 return NULL; | 233 return NULL; |
| 234 } | 234 } |
| 235 | 235 |
| 236 fileapi::FileSystemOperation* CrosMountPointProvider::CreateFileSystemOperation( | 236 fileapi::FileSystemOperation* FileSystemBackend::CreateFileSystemOperation( |
| 237 const fileapi::FileSystemURL& url, | 237 const fileapi::FileSystemURL& url, |
| 238 fileapi::FileSystemContext* context, | 238 fileapi::FileSystemContext* context, |
| 239 base::PlatformFileError* error_code) const { | 239 base::PlatformFileError* error_code) const { |
| 240 DCHECK(url.is_valid()); | 240 DCHECK(url.is_valid()); |
| 241 | 241 |
| 242 if (!IsAccessAllowed(url)) { | 242 if (!IsAccessAllowed(url)) { |
| 243 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; | 243 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; |
| 244 return NULL; | 244 return NULL; |
| 245 } | 245 } |
| 246 | 246 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 257 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || | 257 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || |
| 258 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); | 258 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); |
| 259 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( | 259 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( |
| 260 new fileapi::FileSystemOperationContext(context)); | 260 new fileapi::FileSystemOperationContext(context)); |
| 261 operation_context->set_root_path(GetFileSystemRootPath(url)); | 261 operation_context->set_root_path(GetFileSystemRootPath(url)); |
| 262 return new fileapi::LocalFileSystemOperation(url, context, | 262 return new fileapi::LocalFileSystemOperation(url, context, |
| 263 operation_context.Pass()); | 263 operation_context.Pass()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 scoped_ptr<webkit_blob::FileStreamReader> | 266 scoped_ptr<webkit_blob::FileStreamReader> |
| 267 CrosMountPointProvider::CreateFileStreamReader( | 267 FileSystemBackend::CreateFileStreamReader( |
| 268 const fileapi::FileSystemURL& url, | 268 const fileapi::FileSystemURL& url, |
| 269 int64 offset, | 269 int64 offset, |
| 270 const base::Time& expected_modification_time, | 270 const base::Time& expected_modification_time, |
| 271 fileapi::FileSystemContext* context) const { | 271 fileapi::FileSystemContext* context) const { |
| 272 DCHECK(url.is_valid()); | 272 DCHECK(url.is_valid()); |
| 273 | 273 |
| 274 if (!IsAccessAllowed(url)) | 274 if (!IsAccessAllowed(url)) |
| 275 return scoped_ptr<webkit_blob::FileStreamReader>(); | 275 return scoped_ptr<webkit_blob::FileStreamReader>(); |
| 276 | 276 |
| 277 if (url.type() == fileapi::kFileSystemTypeDrive) { | 277 if (url.type() == fileapi::kFileSystemTypeDrive) { |
| 278 fileapi::RemoteFileSystemProxyInterface* remote_proxy = | 278 fileapi::RemoteFileSystemProxyInterface* remote_proxy = |
| 279 GetRemoteProxy(url.filesystem_id()); | 279 GetRemoteProxy(url.filesystem_id()); |
| 280 if (!remote_proxy) | 280 if (!remote_proxy) |
| 281 return scoped_ptr<webkit_blob::FileStreamReader>(); | 281 return scoped_ptr<webkit_blob::FileStreamReader>(); |
| 282 return remote_proxy->CreateFileStreamReader( | 282 return remote_proxy->CreateFileStreamReader( |
| 283 context->task_runners()->file_task_runner(), | 283 context->task_runners()->file_task_runner(), |
| 284 url, offset, expected_modification_time); | 284 url, offset, expected_modification_time); |
| 285 } | 285 } |
| 286 | 286 |
| 287 return scoped_ptr<webkit_blob::FileStreamReader>( | 287 return scoped_ptr<webkit_blob::FileStreamReader>( |
| 288 new fileapi::FileSystemFileStreamReader( | 288 new fileapi::FileSystemFileStreamReader( |
| 289 context, url, offset, expected_modification_time)); | 289 context, url, offset, expected_modification_time)); |
| 290 } | 290 } |
| 291 | 291 |
| 292 scoped_ptr<fileapi::FileStreamWriter> | 292 scoped_ptr<fileapi::FileStreamWriter> |
| 293 CrosMountPointProvider::CreateFileStreamWriter( | 293 FileSystemBackend::CreateFileStreamWriter( |
| 294 const fileapi::FileSystemURL& url, | 294 const fileapi::FileSystemURL& url, |
| 295 int64 offset, | 295 int64 offset, |
| 296 fileapi::FileSystemContext* context) const { | 296 fileapi::FileSystemContext* context) const { |
| 297 DCHECK(url.is_valid()); | 297 DCHECK(url.is_valid()); |
| 298 | 298 |
| 299 if (!IsAccessAllowed(url)) | 299 if (!IsAccessAllowed(url)) |
| 300 return scoped_ptr<fileapi::FileStreamWriter>(); | 300 return scoped_ptr<fileapi::FileStreamWriter>(); |
| 301 | 301 |
| 302 if (url.type() == fileapi::kFileSystemTypeDrive) { | 302 if (url.type() == fileapi::kFileSystemTypeDrive) { |
| 303 fileapi::RemoteFileSystemProxyInterface* remote_proxy = | 303 fileapi::RemoteFileSystemProxyInterface* remote_proxy = |
| 304 GetRemoteProxy(url.filesystem_id()); | 304 GetRemoteProxy(url.filesystem_id()); |
| 305 if (!remote_proxy) | 305 if (!remote_proxy) |
| 306 return scoped_ptr<fileapi::FileStreamWriter>(); | 306 return scoped_ptr<fileapi::FileStreamWriter>(); |
| 307 return scoped_ptr<fileapi::FileStreamWriter>( | 307 return scoped_ptr<fileapi::FileStreamWriter>( |
| 308 new RemoteFileStreamWriter( | 308 new RemoteFileStreamWriter( |
| 309 remote_proxy, url, offset, | 309 remote_proxy, url, offset, |
| 310 context->task_runners()->file_task_runner())); | 310 context->task_runners()->file_task_runner())); |
| 311 } | 311 } |
| 312 | 312 |
| 313 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) | 313 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) |
| 314 return scoped_ptr<fileapi::FileStreamWriter>(); | 314 return scoped_ptr<fileapi::FileStreamWriter>(); |
| 315 | 315 |
| 316 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); | 316 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); |
| 317 return scoped_ptr<fileapi::FileStreamWriter>( | 317 return scoped_ptr<fileapi::FileStreamWriter>( |
| 318 new fileapi::LocalFileStreamWriter( | 318 new fileapi::LocalFileStreamWriter( |
| 319 context->task_runners()->file_task_runner(), url.path(), offset)); | 319 context->task_runners()->file_task_runner(), url.path(), offset)); |
| 320 } | 320 } |
| 321 | 321 |
| 322 bool CrosMountPointProvider::GetVirtualPath( | 322 bool FileSystemBackend::GetVirtualPath( |
| 323 const base::FilePath& filesystem_path, | 323 const base::FilePath& filesystem_path, |
| 324 base::FilePath* virtual_path) { | 324 base::FilePath* virtual_path) { |
| 325 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || | 325 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || |
| 326 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); | 326 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); |
| 327 } | 327 } |
| 328 | 328 |
| 329 fileapi::RemoteFileSystemProxyInterface* CrosMountPointProvider::GetRemoteProxy( | 329 fileapi::RemoteFileSystemProxyInterface* FileSystemBackend::GetRemoteProxy( |
| 330 const std::string& mount_name) const { | 330 const std::string& mount_name) const { |
| 331 fileapi::RemoteFileSystemProxyInterface* proxy = | 331 fileapi::RemoteFileSystemProxyInterface* proxy = |
| 332 mount_points_->GetRemoteFileSystemProxy(mount_name); | 332 mount_points_->GetRemoteFileSystemProxy(mount_name); |
| 333 if (proxy) | 333 if (proxy) |
| 334 return proxy; | 334 return proxy; |
| 335 return system_mount_points_->GetRemoteFileSystemProxy(mount_name); | 335 return system_mount_points_->GetRemoteFileSystemProxy(mount_name); |
| 336 } | 336 } |
| 337 | 337 |
| 338 base::FilePath CrosMountPointProvider::GetFileSystemRootPath( | 338 base::FilePath FileSystemBackend::GetFileSystemRootPath( |
| 339 const fileapi::FileSystemURL& url) const { | 339 const fileapi::FileSystemURL& url) const { |
| 340 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); | 340 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); |
| 341 if (!url.is_valid()) | 341 if (!url.is_valid()) |
| 342 return base::FilePath(); | 342 return base::FilePath(); |
| 343 | 343 |
| 344 base::FilePath root_path; | 344 base::FilePath root_path; |
| 345 std::string mount_name = url.filesystem_id(); | 345 std::string mount_name = url.filesystem_id(); |
| 346 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && | 346 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && |
| 347 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { | 347 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { |
| 348 return base::FilePath(); | 348 return base::FilePath(); |
| 349 } | 349 } |
| 350 | 350 |
| 351 return root_path.DirName(); | 351 return root_path.DirName(); |
| 352 } | 352 } |
| 353 | 353 |
| 354 } // namespace chromeos | 354 } // namespace chromeos |
| OLD | NEW |