| 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 "webkit/fileapi/isolated_mount_point_provider.h" | 5 #include "webkit/fileapi/isolated_mount_point_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 std::string fsid; | 37 std::string fsid; |
| 38 FilePath path; | 38 FilePath path; |
| 39 if (!isolated_context()->CrackIsolatedPath(url.path(), &fsid, NULL, &path)) | 39 if (!isolated_context()->CrackIsolatedPath(url.path(), &fsid, NULL, &path)) |
| 40 return FilePath(); | 40 return FilePath(); |
| 41 return path; | 41 return path; |
| 42 } | 42 } |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 IsolatedMountPointProvider::IsolatedMountPointProvider() | 46 IsolatedMountPointProvider::IsolatedMountPointProvider() |
| 47 : isolated_file_util_(new IsolatedFileUtil()) { | 47 : isolated_file_util_(new IsolatedFileUtil()), |
| 48 dragged_file_util_(new DraggedFileUtil()) { |
| 48 } | 49 } |
| 49 | 50 |
| 50 IsolatedMountPointProvider::~IsolatedMountPointProvider() { | 51 IsolatedMountPointProvider::~IsolatedMountPointProvider() { |
| 51 } | 52 } |
| 52 | 53 |
| 53 void IsolatedMountPointProvider::ValidateFileSystemRoot( | 54 void IsolatedMountPointProvider::ValidateFileSystemRoot( |
| 54 const GURL& origin_url, | 55 const GURL& origin_url, |
| 55 FileSystemType type, | 56 FileSystemType type, |
| 56 bool create, | 57 bool create, |
| 57 const ValidateFileSystemCallback& callback) { | 58 const ValidateFileSystemCallback& callback) { |
| 58 // We never allow opening a new isolated FileSystem via usual OpenFileSystem. | 59 // We never allow opening a new isolated FileSystem via usual OpenFileSystem. |
| 59 base::MessageLoopProxy::current()->PostTask( | 60 base::MessageLoopProxy::current()->PostTask( |
| 60 FROM_HERE, | 61 FROM_HERE, |
| 61 base::Bind(callback, base::PLATFORM_FILE_ERROR_SECURITY)); | 62 base::Bind(callback, base::PLATFORM_FILE_ERROR_SECURITY)); |
| 62 } | 63 } |
| 63 | 64 |
| 64 FilePath IsolatedMountPointProvider::GetFileSystemRootPathOnFileThread( | 65 FilePath IsolatedMountPointProvider::GetFileSystemRootPathOnFileThread( |
| 65 const GURL& origin_url, | 66 const GURL& origin_url, |
| 66 FileSystemType type, | 67 FileSystemType type, |
| 67 const FilePath& virtual_path, | 68 const FilePath& virtual_path, |
| 68 bool create) { | 69 bool create) { |
| 69 if (create || type != kFileSystemTypeIsolated) | 70 if (create) |
| 70 return FilePath(); | 71 return FilePath(); |
| 71 std::string fsid; | 72 std::string fsid; |
| 72 FilePath path; | 73 FilePath path; |
| 73 IsolatedContext::FileInfo root; | 74 IsolatedContext::FileInfo root; |
| 74 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, &root, &path)) | 75 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, &root, &path)) |
| 75 return FilePath(); | 76 return FilePath(); |
| 76 return root.path; | 77 return root.path; |
| 77 } | 78 } |
| 78 | 79 |
| 79 bool IsolatedMountPointProvider::IsAccessAllowed( | 80 bool IsolatedMountPointProvider::IsAccessAllowed( |
| 80 const GURL& origin_url, FileSystemType type, const FilePath& virtual_path) { | 81 const GURL& origin_url, FileSystemType type, const FilePath& virtual_path) { |
| 81 if (type != fileapi::kFileSystemTypeIsolated) | 82 if (type != fileapi::kFileSystemTypeIsolated) |
| 82 return false; | 83 return false; |
| 83 | 84 |
| 84 std::string filesystem_id; | 85 std::string filesystem_id; |
| 85 FilePath path; | 86 FilePath path; |
| 86 return isolated_context()->CrackIsolatedPath( | 87 return isolated_context()->CrackIsolatedPath( |
| 87 virtual_path, &filesystem_id, NULL, &path); | 88 virtual_path, &filesystem_id, NULL, &path); |
| 88 } | 89 } |
| 89 | 90 |
| 90 bool IsolatedMountPointProvider::IsRestrictedFileName( | 91 bool IsolatedMountPointProvider::IsRestrictedFileName( |
| 91 const FilePath& filename) const { | 92 const FilePath& filename) const { |
| 92 return false; | 93 return false; |
| 93 } | 94 } |
| 94 | 95 |
| 95 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil() { | 96 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil( |
| 96 return isolated_file_util_.get(); | 97 FileSystemType type) { |
| 98 if (type == kFileSystemTypeDragged) |
| 99 return dragged_file_util_.get(); |
| 100 else |
| 101 return isolated_file_util_.get(); |
| 97 } | 102 } |
| 98 | 103 |
| 99 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( | 104 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( |
| 100 const FilePath& virtual_path) const { | 105 const FilePath& virtual_path) const { |
| 101 std::string fsid; | 106 std::string fsid; |
| 102 FilePath path; | 107 FilePath path; |
| 103 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path)) | 108 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path)) |
| 104 return FilePath(); | 109 return FilePath(); |
| 105 return path; | 110 return path; |
| 106 } | 111 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 129 FilePath path = GetPathFromURL(url); | 134 FilePath path = GetPathFromURL(url); |
| 130 return path.empty() ? NULL : new LocalFileStreamWriter(path, offset); | 135 return path.empty() ? NULL : new LocalFileStreamWriter(path, offset); |
| 131 } | 136 } |
| 132 | 137 |
| 133 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { | 138 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { |
| 134 // No quota support. | 139 // No quota support. |
| 135 return NULL; | 140 return NULL; |
| 136 } | 141 } |
| 137 | 142 |
| 138 } // namespace fileapi | 143 } // namespace fileapi |
| OLD | NEW |