| 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 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_MOUNT_POINT_PROVIDER_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_BACKEND_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_MOUNT_POINT_PROVIDER_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_BACKEND_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
| 15 #include "webkit/browser/fileapi/file_permission_policy.h" | 15 #include "webkit/browser/fileapi/file_permission_policy.h" |
| 16 #include "webkit/browser/fileapi/open_file_system_mode.h" | 16 #include "webkit/browser/fileapi/open_file_system_mode.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 28 class AsyncFileUtil; | 28 class AsyncFileUtil; |
| 29 class CopyOrMoveFileValidatorFactory; | 29 class CopyOrMoveFileValidatorFactory; |
| 30 class FileSystemURL; | 30 class FileSystemURL; |
| 31 class FileStreamWriter; | 31 class FileStreamWriter; |
| 32 class FileSystemContext; | 32 class FileSystemContext; |
| 33 class FileSystemFileUtil; | 33 class FileSystemFileUtil; |
| 34 class FileSystemOperation; | 34 class FileSystemOperation; |
| 35 class FileSystemQuotaUtil; | 35 class FileSystemQuotaUtil; |
| 36 class RemoteFileSystemProxyInterface; | 36 class RemoteFileSystemProxyInterface; |
| 37 | 37 |
| 38 // An interface to provide mount-point-specific path-related utilities | 38 // An interface for defining a file system backend. |
| 39 // and specialized FileSystemFileUtil instance. | |
| 40 // | 39 // |
| 41 // NOTE: when you implement a new MountPointProvider for your own | 40 // NOTE: when you implement a new FileSystemBackend for your own |
| 42 // FileSystem module, please contact to kinuko@chromium.org. | 41 // FileSystem module, please contact to kinuko@chromium.org. |
| 43 // | 42 // |
| 44 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemMountPointProvider { | 43 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemBackend { |
| 45 public: | 44 public: |
| 46 // Callback for OpenFileSystem. | 45 // Callback for OpenFileSystem. |
| 47 typedef base::Callback<void(base::PlatformFileError error)> | 46 typedef base::Callback<void(base::PlatformFileError error)> |
| 48 OpenFileSystemCallback; | 47 OpenFileSystemCallback; |
| 49 typedef base::Callback<void(base::PlatformFileError error)> | 48 typedef base::Callback<void(base::PlatformFileError error)> |
| 50 DeleteFileSystemCallback; | 49 DeleteFileSystemCallback; |
| 51 virtual ~FileSystemMountPointProvider() {} | 50 virtual ~FileSystemBackend() {} |
| 52 | 51 |
| 53 // Returns true if this mount point provider can handle |type|. | 52 // Returns true if this mount point provider can handle |type|. |
| 54 // One mount point provider may be able to handle multiple filesystem types. | 53 // One mount point provider may be able to handle multiple filesystem types. |
| 55 virtual bool CanHandleType(FileSystemType type) const = 0; | 54 virtual bool CanHandleType(FileSystemType type) const = 0; |
| 56 | 55 |
| 57 // Initializes the filesystem for the given |origin_url| and |type|. | 56 // Initializes the filesystem for the given |origin_url| and |type|. |
| 58 // This verifies if it is allowed to request (or create) the filesystem | 57 // This verifies if it is allowed to request (or create) the filesystem |
| 59 // and if it can access (or create) the root directory of the mount point. | 58 // and if it can access (or create) the root directory of the mount point. |
| 60 // If |mode| is CREATE_IF_NONEXISTENT calling this may also create | 59 // If |mode| is CREATE_IF_NONEXISTENT calling this may also create |
| 61 // the root directory (and/or related database entries etc) for | 60 // the root directory (and/or related database entries etc) for |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 119 |
| 121 // Deletes the filesystem for the given |origin_url| and |type|. | 120 // Deletes the filesystem for the given |origin_url| and |type|. |
| 122 virtual void DeleteFileSystem( | 121 virtual void DeleteFileSystem( |
| 123 const GURL& origin_url, | 122 const GURL& origin_url, |
| 124 FileSystemType type, | 123 FileSystemType type, |
| 125 FileSystemContext* context, | 124 FileSystemContext* context, |
| 126 const DeleteFileSystemCallback& callback) = 0; | 125 const DeleteFileSystemCallback& callback) = 0; |
| 127 }; | 126 }; |
| 128 | 127 |
| 129 // An interface to control external file system access permissions. | 128 // An interface to control external file system access permissions. |
| 130 class ExternalFileSystemMountPointProvider | 129 // TODO(satorux): Move this out of 'webkit/browser/fileapi'. crbug.com/257279 |
| 131 : public FileSystemMountPointProvider { | 130 class ExternalFileSystemBackend : public FileSystemBackend { |
| 132 public: | 131 public: |
| 133 // Returns true if |url| is allowed to be accessed. | 132 // Returns true if |url| is allowed to be accessed. |
| 134 // This is supposed to perform ExternalFileSystem-specific security | 133 // This is supposed to perform ExternalFileSystem-specific security |
| 135 // checks. | 134 // checks. |
| 136 virtual bool IsAccessAllowed(const fileapi::FileSystemURL& url) const = 0; | 135 virtual bool IsAccessAllowed(const fileapi::FileSystemURL& url) const = 0; |
| 137 // Returns the list of top level directories that are exposed by this | 136 // Returns the list of top level directories that are exposed by this |
| 138 // provider. This list is used to set appropriate child process file access | 137 // provider. This list is used to set appropriate child process file access |
| 139 // permissions. | 138 // permissions. |
| 140 virtual std::vector<base::FilePath> GetRootDirectories() const = 0; | 139 virtual std::vector<base::FilePath> GetRootDirectories() const = 0; |
| 141 // Grants access to all external file system from extension identified with | 140 // Grants access to all external file system from extension identified with |
| 142 // |extension_id|. | 141 // |extension_id|. |
| 143 virtual void GrantFullAccessToExtension(const std::string& extension_id) = 0; | 142 virtual void GrantFullAccessToExtension(const std::string& extension_id) = 0; |
| 144 // Grants access to |virtual_path| from |origin_url|. | 143 // Grants access to |virtual_path| from |origin_url|. |
| 145 virtual void GrantFileAccessToExtension( | 144 virtual void GrantFileAccessToExtension( |
| 146 const std::string& extension_id, | 145 const std::string& extension_id, |
| 147 const base::FilePath& virtual_path) = 0; | 146 const base::FilePath& virtual_path) = 0; |
| 148 // Revokes file access from extension identified with |extension_id|. | 147 // Revokes file access from extension identified with |extension_id|. |
| 149 virtual void RevokeAccessForExtension( | 148 virtual void RevokeAccessForExtension( |
| 150 const std::string& extension_id) = 0; | 149 const std::string& extension_id) = 0; |
| 151 // Gets virtual path by known filesystem path. Returns false when filesystem | 150 // Gets virtual path by known filesystem path. Returns false when filesystem |
| 152 // path is not exposed by this provider. | 151 // path is not exposed by this provider. |
| 153 virtual bool GetVirtualPath(const base::FilePath& file_system_path, | 152 virtual bool GetVirtualPath(const base::FilePath& file_system_path, |
| 154 base::FilePath* virtual_path) = 0; | 153 base::FilePath* virtual_path) = 0; |
| 155 }; | 154 }; |
| 156 | 155 |
| 157 } // namespace fileapi | 156 } // namespace fileapi |
| 158 | 157 |
| 159 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_MOUNT_POINT_PROVIDER_H_ | 158 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_BACKEND_H_ |
| OLD | NEW |