| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
| 13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 14 #include "webkit/blob/local_file_stream_reader.h" | 14 #include "webkit/blob/local_file_stream_reader.h" |
| 15 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 15 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 16 #include "webkit/fileapi/file_system_context.h" | 16 #include "webkit/fileapi/file_system_context.h" |
| 17 #include "webkit/fileapi/file_system_file_stream_reader.h" | 17 #include "webkit/fileapi/file_system_file_stream_reader.h" |
| 18 #include "webkit/fileapi/file_system_types.h" | 18 #include "webkit/fileapi/file_system_types.h" |
| 19 #include "webkit/fileapi/file_system_util.h" | 19 #include "webkit/fileapi/file_system_util.h" |
| 20 #include "webkit/fileapi/isolated_context.h" | 20 #include "webkit/fileapi/isolated_context.h" |
| 21 #include "webkit/fileapi/isolated_file_util.h" | 21 #include "webkit/fileapi/isolated_file_util.h" |
| 22 #include "webkit/fileapi/local_file_stream_writer.h" | 22 #include "webkit/fileapi/local_file_stream_writer.h" |
| 23 #include "webkit/fileapi/local_file_system_operation.h" | 23 #include "webkit/fileapi/local_file_system_operation.h" |
| 24 #include "webkit/fileapi/media/local_media_file_util.h" |
| 25 #include "webkit/fileapi/media/media_path_filter.h" |
| 24 #include "webkit/fileapi/native_file_util.h" | 26 #include "webkit/fileapi/native_file_util.h" |
| 25 | 27 |
| 26 namespace fileapi { | 28 namespace fileapi { |
| 27 | 29 |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 IsolatedContext* isolated_context() { | 32 IsolatedContext* isolated_context() { |
| 31 return IsolatedContext::GetInstance(); | 33 return IsolatedContext::GetInstance(); |
| 32 } | 34 } |
| 33 | 35 |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| 36 IsolatedMountPointProvider::IsolatedMountPointProvider() | 38 IsolatedMountPointProvider::IsolatedMountPointProvider() |
| 37 : isolated_file_util_(new IsolatedFileUtil()), | 39 : media_path_filter_(new MediaPathFilter()), |
| 38 dragged_file_util_(new DraggedFileUtil()) { | 40 isolated_file_util_(new IsolatedFileUtil()), |
| 41 dragged_file_util_(new DraggedFileUtil()), |
| 42 local_media_file_util_(new LocalMediaFileUtil()) { |
| 39 } | 43 } |
| 40 | 44 |
| 41 IsolatedMountPointProvider::~IsolatedMountPointProvider() { | 45 IsolatedMountPointProvider::~IsolatedMountPointProvider() { |
| 42 } | 46 } |
| 43 | 47 |
| 44 void IsolatedMountPointProvider::ValidateFileSystemRoot( | 48 void IsolatedMountPointProvider::ValidateFileSystemRoot( |
| 45 const GURL& origin_url, | 49 const GURL& origin_url, |
| 46 FileSystemType type, | 50 FileSystemType type, |
| 47 bool create, | 51 bool create, |
| 48 const ValidateFileSystemCallback& callback) { | 52 const ValidateFileSystemCallback& callback) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 69 | 73 |
| 70 bool IsolatedMountPointProvider::IsRestrictedFileName( | 74 bool IsolatedMountPointProvider::IsRestrictedFileName( |
| 71 const FilePath& filename) const { | 75 const FilePath& filename) const { |
| 72 // TODO(kinuko): We need to check platform-specific restricted file names | 76 // TODO(kinuko): We need to check platform-specific restricted file names |
| 73 // before we actually start allowing file creation in isolated file systems. | 77 // before we actually start allowing file creation in isolated file systems. |
| 74 return false; | 78 return false; |
| 75 } | 79 } |
| 76 | 80 |
| 77 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil( | 81 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil( |
| 78 FileSystemType type) { | 82 FileSystemType type) { |
| 79 if (type == kFileSystemTypeDragged) | 83 switch (type) { |
| 80 return dragged_file_util_.get(); | 84 case kFileSystemTypeIsolated: |
| 81 else | 85 return isolated_file_util_.get(); |
| 82 return isolated_file_util_.get(); | 86 case kFileSystemTypeDragged: |
| 87 return dragged_file_util_.get(); |
| 88 case kFileSystemTypeLocalMedia: |
| 89 return local_media_file_util_.get(); |
| 90 |
| 91 case kFileSystemTypeDeviceMedia: |
| 92 case kFileSystemTypeTemporary: |
| 93 case kFileSystemTypePersistent: |
| 94 case kFileSystemTypeExternal: |
| 95 case kFileSystemTypeTest: |
| 96 case kFileSystemTypeUnknown: |
| 97 NOTREACHED(); |
| 98 } |
| 99 return NULL; |
| 83 } | 100 } |
| 84 | 101 |
| 85 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( | 102 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( |
| 86 const FilePath& virtual_path) const { | 103 const FilePath& virtual_path) const { |
| 87 // For isolated filesystems we only check per-filesystem permissions. | 104 // For isolated filesystems we only check per-filesystem permissions. |
| 88 NOTREACHED(); | 105 NOTREACHED(); |
| 89 return virtual_path; | 106 return virtual_path; |
| 90 } | 107 } |
| 91 | 108 |
| 92 FileSystemOperationInterface* | 109 FileSystemOperationInterface* |
| 93 IsolatedMountPointProvider::CreateFileSystemOperation( | 110 IsolatedMountPointProvider::CreateFileSystemOperation( |
| 94 const FileSystemURL& url, | 111 const FileSystemURL& url, |
| 95 FileSystemContext* context) const { | 112 FileSystemContext* context) const { |
| 96 scoped_ptr<FileSystemOperationContext> operation_context( | 113 scoped_ptr<FileSystemOperationContext> operation_context( |
| 97 new FileSystemOperationContext(context)); | 114 new FileSystemOperationContext(context)); |
| 115 operation_context->set_media_path_filter(media_path_filter_.get()); |
| 98 return new LocalFileSystemOperation(context, operation_context.Pass()); | 116 return new LocalFileSystemOperation(context, operation_context.Pass()); |
| 99 } | 117 } |
| 100 | 118 |
| 101 webkit_blob::FileStreamReader* | 119 webkit_blob::FileStreamReader* |
| 102 IsolatedMountPointProvider::CreateFileStreamReader( | 120 IsolatedMountPointProvider::CreateFileStreamReader( |
| 103 const FileSystemURL& url, | 121 const FileSystemURL& url, |
| 104 int64 offset, | 122 int64 offset, |
| 105 FileSystemContext* context) const { | 123 FileSystemContext* context) const { |
| 106 return new webkit_blob::LocalFileStreamReader( | 124 return new webkit_blob::LocalFileStreamReader( |
| 107 context->file_task_runner(), url.path(), offset, base::Time()); | 125 context->file_task_runner(), url.path(), offset, base::Time()); |
| 108 } | 126 } |
| 109 | 127 |
| 110 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter( | 128 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter( |
| 111 const FileSystemURL& url, | 129 const FileSystemURL& url, |
| 112 int64 offset, | 130 int64 offset, |
| 113 FileSystemContext* context) const { | 131 FileSystemContext* context) const { |
| 114 return new LocalFileStreamWriter(url.path(), offset); | 132 return new LocalFileStreamWriter(url.path(), offset); |
| 115 } | 133 } |
| 116 | 134 |
| 117 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { | 135 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { |
| 118 // No quota support. | 136 // No quota support. |
| 119 return NULL; | 137 return NULL; |
| 120 } | 138 } |
| 121 | 139 |
| 122 } // namespace fileapi | 140 } // namespace fileapi |
| OLD | NEW |