| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ | 5 #ifndef WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ |
| 6 #define WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ | 6 #define WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "webkit/fileapi/file_system_mount_point_provider.h" | 14 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 15 #include "webkit/fileapi/local_file_system_file_util.h" |
| 15 #include "webkit/quota/special_storage_policy.h" | 16 #include "webkit/quota/special_storage_policy.h" |
| 16 | 17 |
| 18 namespace fileapi { |
| 19 class FileSystemFileUtil; |
| 20 } |
| 21 |
| 17 namespace chromeos { | 22 namespace chromeos { |
| 18 | 23 |
| 19 class FileAccessPermissions; | 24 class FileAccessPermissions; |
| 20 | 25 |
| 21 // An interface to provide local filesystem paths. | 26 // An interface to provide local filesystem paths. |
| 22 class CrosMountPointProvider | 27 class CrosMountPointProvider |
| 23 : public fileapi::ExternalFileSystemMountPointProvider { | 28 : public fileapi::ExternalFileSystemMountPointProvider { |
| 24 public: | 29 public: |
| 25 CrosMountPointProvider( | 30 CrosMountPointProvider( |
| 26 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); | 31 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); |
| 27 virtual ~CrosMountPointProvider(); | 32 virtual ~CrosMountPointProvider(); |
| 28 | 33 |
| 29 // fileapi::FileSystemMountPointProvider overrides. | 34 // fileapi::FileSystemMountPointProvider overrides. |
| 30 virtual bool IsAccessAllowed(const GURL& origin_url, | 35 virtual bool IsAccessAllowed(const GURL& origin_url, |
| 31 fileapi::FileSystemType type, | 36 fileapi::FileSystemType type, |
| 32 const FilePath& virtual_path) OVERRIDE; | 37 const FilePath& virtual_path) OVERRIDE; |
| 33 virtual void ValidateFileSystemRootAndGetURL( | 38 virtual void ValidateFileSystemRootAndGetURL( |
| 34 const GURL& origin_url, | 39 const GURL& origin_url, |
| 35 fileapi::FileSystemType type, | 40 fileapi::FileSystemType type, |
| 36 bool create, | 41 bool create, |
| 37 fileapi::FileSystemPathManager::GetRootPathCallback* callback) OVERRIDE; | 42 fileapi::FileSystemPathManager::GetRootPathCallback* callback) OVERRIDE; |
| 38 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( | 43 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( |
| 39 const GURL& origin_url, | 44 const GURL& origin_url, |
| 40 fileapi::FileSystemType type, | 45 fileapi::FileSystemType type, |
| 41 const FilePath& virtual_path, | 46 const FilePath& virtual_path, |
| 42 bool create); | 47 bool create); |
| 43 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; | 48 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; |
| 44 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; | 49 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; |
| 50 virtual fileapi::FileSystemFileUtil* GetFileSystemFileUtil() OVERRIDE; |
| 45 | 51 |
| 46 // fileapi::ExternalFileSystemMountPointProvider overrides. | 52 // fileapi::ExternalFileSystemMountPointProvider overrides. |
| 47 virtual void GrantFullAccessToExtension( | 53 virtual void GrantFullAccessToExtension( |
| 48 const std::string& extension_id) OVERRIDE; | 54 const std::string& extension_id) OVERRIDE; |
| 49 virtual void GrantFileAccessToExtension( | 55 virtual void GrantFileAccessToExtension( |
| 50 const std::string& extension_id, const FilePath& virtual_path) OVERRIDE; | 56 const std::string& extension_id, const FilePath& virtual_path) OVERRIDE; |
| 51 virtual void RevokeAccessForExtension( | 57 virtual void RevokeAccessForExtension( |
| 52 const std::string& extension_id) OVERRIDE; | 58 const std::string& extension_id) OVERRIDE; |
| 53 virtual void AddMountPoint(FilePath mount_point) OVERRIDE; | 59 virtual void AddMountPoint(FilePath mount_point) OVERRIDE; |
| 54 virtual void RemoveMountPoint(FilePath mount_point) OVERRIDE; | 60 virtual void RemoveMountPoint(FilePath mount_point) OVERRIDE; |
| 55 virtual bool GetVirtualPath(const FilePath& filesystem_path, | 61 virtual bool GetVirtualPath(const FilePath& filesystem_path, |
| 56 FilePath* virtual_path) OVERRIDE; | 62 FilePath* virtual_path) OVERRIDE; |
| 57 | 63 |
| 58 private: | 64 private: |
| 59 class GetFileSystemRootPathTask; | 65 class GetFileSystemRootPathTask; |
| 60 typedef std::map<std::string, FilePath> MountPointMap; | 66 typedef std::map<std::string, FilePath> MountPointMap; |
| 61 | 67 |
| 62 // Gives the real file system's |root_path| for given |virtual_path|. Returns | 68 // Gives the real file system's |root_path| for given |virtual_path|. Returns |
| 63 // false when |virtual_path| cannot be mapped to the real file system. | 69 // false when |virtual_path| cannot be mapped to the real file system. |
| 64 bool GetRootForVirtualPath(const FilePath& virtual_path, FilePath* root_path); | 70 bool GetRootForVirtualPath(const FilePath& virtual_path, FilePath* root_path); |
| 65 | 71 |
| 66 base::Lock lock_; // Synchronize all access to path_map_. | 72 base::Lock lock_; // Synchronize all access to path_map_. |
| 67 MountPointMap mount_point_map_; | 73 MountPointMap mount_point_map_; |
| 68 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 74 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
| 69 scoped_ptr<FileAccessPermissions> file_access_permissions_; | 75 scoped_ptr<FileAccessPermissions> file_access_permissions_; |
| 76 scoped_ptr<fileapi::LocalFileSystemFileUtil> local_file_util_; |
| 70 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider); | 77 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider); |
| 71 }; | 78 }; |
| 72 | 79 |
| 73 } // namespace chromeos | 80 } // namespace chromeos |
| 74 | 81 |
| 75 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ | 82 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ |
| OLD | NEW |