| 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 "webkit/fileapi/file_system_mount_point_provider.h" | 14 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 14 #include "webkit/quota/special_storage_policy.h" | 15 #include "webkit/quota/special_storage_policy.h" |
| 15 | 16 |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 | 18 |
| 18 class FileAccessPermissions; | 19 class FileAccessPermissions; |
| 19 | 20 |
| 20 // An interface to provide local filesystem paths. | 21 // An interface to provide local filesystem paths. |
| 21 class CrosMountPointProvider | 22 class CrosMountPointProvider |
| 22 : public fileapi::ExternalFileSystemMountPointProvider { | 23 : public fileapi::ExternalFileSystemMountPointProvider { |
| 23 public: | 24 public: |
| 24 CrosMountPointProvider( | 25 CrosMountPointProvider( |
| 25 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); | 26 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); |
| 26 virtual ~CrosMountPointProvider(); | 27 virtual ~CrosMountPointProvider(); |
| 27 | 28 |
| 28 // fileapi::FileSystemMountPointProvider overrides. | 29 // fileapi::FileSystemMountPointProvider overrides. |
| 29 virtual bool IsAccessAllowed(const GURL& origin_url, | 30 virtual bool IsAccessAllowed(const GURL& origin_url, |
| 30 fileapi::FileSystemType type, | 31 fileapi::FileSystemType type, |
| 31 const FilePath& virtual_path) OVERRIDE; | 32 const FilePath& virtual_path) OVERRIDE; |
| 32 virtual void GetFileSystemRootPath( | 33 virtual void GetFileSystemRootPath( |
| 33 const GURL& origin_url, | 34 const GURL& origin_url, |
| 34 fileapi::FileSystemType type, | 35 fileapi::FileSystemType type, |
| 35 bool create, | 36 bool create, |
| 37 bool is_file_system, |
| 38 const FilePath& virtual_path, |
| 36 fileapi::FileSystemPathManager::GetRootPathCallback* callback) OVERRIDE; | 39 fileapi::FileSystemPathManager::GetRootPathCallback* callback) OVERRIDE; |
| 37 virtual FilePath GetFileSystemRootPathOnFileThread( | 40 virtual FilePath GetFileSystemRootPathOnFileThread( |
| 38 const GURL& origin_url, | 41 const GURL& origin_url, |
| 39 fileapi::FileSystemType type, | 42 fileapi::FileSystemType type, |
| 40 const FilePath& virtual_path, | 43 const FilePath& virtual_path, |
| 41 bool create); | 44 bool create); |
| 42 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; | 45 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; |
| 43 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; | 46 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; |
| 44 | 47 |
| 45 // fileapi::ExternalFileSystemMountPointProvider overrides. | 48 // fileapi::ExternalFileSystemMountPointProvider overrides. |
| 46 virtual void GrantFullAccessToExtension( | 49 virtual void GrantFullAccessToExtension( |
| 47 const std::string& extension_id) OVERRIDE; | 50 const std::string& extension_id) OVERRIDE; |
| 48 virtual void GrantFileAccessToExtension( | 51 virtual void GrantFileAccessToExtension( |
| 49 const std::string& extension_id, const FilePath& virtual_path) OVERRIDE; | 52 const std::string& extension_id, const FilePath& virtual_path) OVERRIDE; |
| 50 void RevokeAccessForExtension(const std::string& extension_id) OVERRIDE; | 53 virtual void RevokeAccessForExtension( |
| 54 const std::string& extension_id) OVERRIDE; |
| 55 virtual void AddMountPoint(FilePath mount_point) OVERRIDE; |
| 56 virtual void RemoveMountPoint(FilePath mount_point) OVERRIDE; |
| 51 | 57 |
| 52 private: | 58 private: |
| 53 class GetFileSystemRootPathTask; | 59 class GetFileSystemRootPathTask; |
| 54 typedef std::map<std::string, FilePath> MountPointMap; | 60 typedef std::map<std::string, FilePath> MountPointMap; |
| 55 | 61 |
| 62 // 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. |
| 64 bool GetRootForVirtualPath(const FilePath& virtual_path, FilePath* root_path); |
| 65 |
| 66 base::Lock lock_; // Synchronize all access to path_map_. |
| 56 MountPointMap mount_point_map_; | 67 MountPointMap mount_point_map_; |
| 57 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 68 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
| 58 scoped_ptr<FileAccessPermissions> file_access_permissions_; | 69 scoped_ptr<FileAccessPermissions> file_access_permissions_; |
| 59 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider); | 70 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider); |
| 60 }; | 71 }; |
| 61 | 72 |
| 62 } // namespace chromeos | 73 } // namespace chromeos |
| 63 | 74 |
| 64 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ | 75 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ |
| OLD | NEW |