Index: webkit/chromeos/fileapi/cros_mount_point_provider.cc |
diff --git a/webkit/chromeos/fileapi/cros_mount_point_provider.cc b/webkit/chromeos/fileapi/cros_mount_point_provider.cc |
index a90fcfaa6ecd871b295f950bce332557fbff086f..ef72339f30f70aea800125674f15453df8c6e84f 100644 |
--- a/webkit/chromeos/fileapi/cros_mount_point_provider.cc |
+++ b/webkit/chromeos/fileapi/cros_mount_point_provider.cc |
@@ -30,6 +30,8 @@ |
#include "webkit/fileapi/local_file_system_operation.h" |
#include "webkit/glue/webkit_glue.h" |
+using fileapi::FileSystemURL; |
+ |
namespace { |
const char kChromeUIScheme[] = "chrome"; |
@@ -39,7 +41,7 @@ const char kChromeUIScheme[] = "chrome"; |
namespace chromeos { |
// static |
-bool CrosMountPointProvider::CanHandleURL(const fileapi::FileSystemURL& url) { |
+bool CrosMountPointProvider::CanHandleURL(const FileSystemURL& url) { |
if (!url.is_valid()) |
return false; |
return url.type() == fileapi::kFileSystemTypeNativeLocal || |
@@ -73,7 +75,7 @@ void CrosMountPointProvider::ValidateFileSystemRoot( |
} |
base::FilePath CrosMountPointProvider::GetFileSystemRootPathOnFileThread( |
- const fileapi::FileSystemURL& url, |
+ const FileSystemURL& url, |
bool create) { |
DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); |
if (!url.is_valid()) |
@@ -89,8 +91,7 @@ base::FilePath CrosMountPointProvider::GetFileSystemRootPathOnFileThread( |
return root_path.DirName(); |
} |
-bool CrosMountPointProvider::IsAccessAllowed( |
- const fileapi::FileSystemURL& url) { |
+bool CrosMountPointProvider::IsAccessAllowed(const FileSystemURL& url) { |
if (!url.is_valid()) |
return false; |
@@ -207,7 +208,7 @@ fileapi::AsyncFileUtil* CrosMountPointProvider::GetAsyncFileUtil( |
} |
fileapi::FilePermissionPolicy CrosMountPointProvider::GetPermissionPolicy( |
- const fileapi::FileSystemURL& url, int permissions) const { |
+ const FileSystemURL& url, int permissions) const { |
if (url.mount_type() == fileapi::kFileSystemTypeIsolated) { |
// Permissions in isolated filesystems should be examined with |
// FileSystem permission. |
@@ -217,14 +218,15 @@ fileapi::FilePermissionPolicy CrosMountPointProvider::GetPermissionPolicy( |
} |
fileapi::FileSystemOperation* CrosMountPointProvider::CreateFileSystemOperation( |
- const fileapi::FileSystemURL& url, |
+ const FileSystemURL& url, |
fileapi::FileSystemContext* context, |
base::PlatformFileError* error_code) const { |
DCHECK(url.is_valid()); |
if (url.type() == fileapi::kFileSystemTypeDrive) { |
+ FileSystemURL external_url = GetAsExternalFileSystemURL(url); |
fileapi::RemoteFileSystemProxyInterface* remote_proxy = |
- GetRemoteProxy(url.filesystem_id()); |
+ GetRemoteProxy(external_url); |
if (!remote_proxy) { |
*error_code = base::PLATFORM_FILE_ERROR_NOT_FOUND; |
return NULL; |
@@ -241,7 +243,7 @@ fileapi::FileSystemOperation* CrosMountPointProvider::CreateFileSystemOperation( |
} |
webkit_blob::FileStreamReader* CrosMountPointProvider::CreateFileStreamReader( |
- const fileapi::FileSystemURL& url, |
+ const FileSystemURL& url, |
int64 offset, |
const base::Time& expected_modification_time, |
fileapi::FileSystemContext* context) const { |
@@ -253,14 +255,15 @@ webkit_blob::FileStreamReader* CrosMountPointProvider::CreateFileStreamReader( |
} |
fileapi::FileStreamWriter* CrosMountPointProvider::CreateFileStreamWriter( |
- const fileapi::FileSystemURL& url, |
+ const FileSystemURL& url, |
int64 offset, |
fileapi::FileSystemContext* context) const { |
DCHECK(url.is_valid()); |
if (url.type() == fileapi::kFileSystemTypeDrive) { |
+ FileSystemURL external_url = GetAsExternalFileSystemURL(url); |
fileapi::RemoteFileSystemProxyInterface* remote_proxy = |
- GetRemoteProxy(url.filesystem_id()); |
+ GetRemoteProxy(external_url); |
if (!remote_proxy) |
return NULL; |
return new fileapi::RemoteFileStreamWriter(remote_proxy, url, offset); |
@@ -273,19 +276,46 @@ fileapi::FileStreamWriter* CrosMountPointProvider::CreateFileStreamWriter( |
return new fileapi::LocalFileStreamWriter(url.path(), offset); |
} |
-bool CrosMountPointProvider::GetVirtualPath(const base::FilePath& filesystem_path, |
- base::FilePath* virtual_path) { |
+bool CrosMountPointProvider::GetVirtualPath( |
+ const base::FilePath& filesystem_path, |
+ base::FilePath* virtual_path) const { |
return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || |
system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); |
} |
+fileapi::FileSystemURL CrosMountPointProvider::GetAsExternalFileSystemURL( |
+ const fileapi::FileSystemURL& original) const { |
kinuko
2013/02/14 17:09:48
Do we need to specifically crack the isolated URL
tbarzic
2013/02/14 20:22:32
this could be problematic because we use different
|
+ if (original.mount_type() == fileapi::kFileSystemTypeExternal) |
+ return original; |
+ |
+ if (original.mount_type() == fileapi::kFileSystemTypeIsolated) { |
+ base::FilePath external_path; |
+ if (!GetVirtualPath(original.path(), &external_path)) |
+ return fileapi::FileSystemURL(); |
+ |
+ fileapi::FileSystemURL external = mount_points_->CreateCrackedFileSystemURL( |
+ original.origin(), fileapi::kFileSystemTypeExternal, external_path); |
+ if (external.is_valid() && external.type() == original.type()) |
+ return external; |
+ |
+ external = system_mount_points_->CreateCrackedFileSystemURL( |
+ original.origin(), fileapi::kFileSystemTypeExternal, external_path); |
+ if (external.is_valid() && external.type() == original.type()) |
+ return external; |
+ } |
+ |
+ return fileapi::FileSystemURL(); |
+} |
+ |
fileapi::RemoteFileSystemProxyInterface* CrosMountPointProvider::GetRemoteProxy( |
- const std::string& mount_name) const { |
+ const FileSystemURL& url) const { |
+ if (!url.is_valid()) |
+ return NULL; |
fileapi::RemoteFileSystemProxyInterface* proxy = |
- mount_points_->GetRemoteFileSystemProxy(mount_name); |
+ mount_points_->GetRemoteFileSystemProxy(url.filesystem_id()); |
if (proxy) |
return proxy; |
- return system_mount_points_->GetRemoteFileSystemProxy(mount_name); |
+ return system_mount_points_->GetRemoteFileSystemProxy(url.filesystem_id()); |
} |
} // namespace chromeos |