| 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_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 5 #ifndef WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| 6 #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 6 #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 11 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 12 #include "webkit/fileapi/file_system_mount_point_provider.h" | 13 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 13 | 14 |
| 14 class GURL; | 15 class GURL; |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class MessageLoopProxy; | 18 class MessageLoopProxy; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace fileapi { | 21 namespace fileapi { |
| 21 | 22 |
| 22 class SandboxMountPointProvider : public FileSystemMountPointProvider { | 23 class SandboxMountPointProvider : public FileSystemMountPointProvider { |
| 23 public: | 24 public: |
| 24 | 25 |
| 25 SandboxMountPointProvider( | 26 SandboxMountPointProvider( |
| 26 FileSystemPathManager* path_manager, | 27 FileSystemPathManager* path_manager, |
| 27 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 28 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
| 28 const FilePath& profile_path); | 29 const FilePath& profile_path); |
| 29 virtual ~SandboxMountPointProvider(); | 30 virtual ~SandboxMountPointProvider(); |
| 30 | 31 |
| 31 // Checks if mount point access is allowed from |origin_url|. | 32 // Checks if access to |virtual_path| is allowed from |origin_url|. |
| 32 virtual bool IsAccessAllowed(const GURL& origin_url); | 33 virtual bool IsAccessAllowed(const GURL& origin_url, |
| 34 const FilePath& virtual_path); |
| 33 | 35 |
| 34 // Retrieves the root path for the given |origin_url| and |type|, and | 36 // Retrieves the root path for the given |origin_url| and |type|, and |
| 35 // calls the given |callback| with the root path and name. | 37 // calls the given |callback| with the root path and name. |
| 36 // If |create| is true this also creates the directory if it doesn't exist. | 38 // If |create| is true this also creates the directory if it doesn't exist. |
| 37 virtual void GetFileSystemRootPath( | 39 virtual void GetFileSystemRootPath( |
| 38 const GURL& origin_url, | 40 const GURL& origin_url, |
| 39 FileSystemType type, | 41 FileSystemType type, |
| 40 bool create, | 42 bool create, |
| 41 FileSystemPathManager::GetRootPathCallback* callback); | 43 FileSystemPathManager::GetRootPathCallback* callback); |
| 42 | 44 |
| 43 // Like GetFileSystemRootPath, but synchronous, and can be called only while | 45 // Like GetFileSystemRootPath, but synchronous, and can be called only while |
| 44 // running on the file thread. | 46 // running on the file thread. |
| 45 virtual FilePath GetFileSystemRootPathOnFileThread( | 47 virtual FilePath GetFileSystemRootPathOnFileThread( |
| 46 const GURL& origin_url, | 48 const GURL& origin_url, |
| 47 FileSystemType type, | 49 FileSystemType type, |
| 48 const FilePath& unused, | 50 const FilePath& unused, |
| 49 bool create); | 51 bool create); |
| 50 | 52 |
| 51 // The FileSystem directory name. | 53 // The FileSystem directory name. |
| 52 static const FilePath::CharType kFileSystemDirectory[]; | 54 static const FilePath::CharType kFileSystemDirectory[]; |
| 53 | 55 |
| 54 static const char kPersistentName[]; | 56 static const char kPersistentName[]; |
| 55 static const char kTemporaryName[]; | 57 static const char kTemporaryName[]; |
| 58 static const char kExternalName[]; |
| 56 | 59 |
| 57 const FilePath& base_path() const { | 60 const FilePath& base_path() const { |
| 58 return base_path_; | 61 return base_path_; |
| 59 } | 62 } |
| 60 | 63 |
| 61 // Checks if a given |name| contains any restricted names/chars in it. | 64 // Checks if a given |name| contains any restricted names/chars in it. |
| 62 virtual bool IsRestrictedFileName(const FilePath& filename) const; | 65 virtual bool IsRestrictedFileName(const FilePath& filename) const; |
| 63 | 66 |
| 67 virtual std::vector<FilePath> GetRootDirectories() const; |
| 68 |
| 64 // Returns the origin identifier string, which is used as a part of the | 69 // Returns the origin identifier string, which is used as a part of the |
| 65 // sandboxed path component, for the given |url|. | 70 // sandboxed path component, for the given |url|. |
| 66 static std::string GetOriginIdentifierFromURL(const GURL& url); | 71 static std::string GetOriginIdentifierFromURL(const GURL& url); |
| 67 | 72 |
| 68 // Gets a base directory path of the sandboxed filesystem that is | 73 // Gets a base directory path of the sandboxed filesystem that is |
| 69 // specified by |origin_identifier| and |type|. | 74 // specified by |origin_identifier| and |type|. |
| 70 // |base_path| must be pointing the FileSystem's data directory | 75 // |base_path| must be pointing the FileSystem's data directory |
| 71 // under the profile directory, i.e. <profile_dir>/kFileSystemDirectory. | 76 // under the profile directory, i.e. <profile_dir>/kFileSystemDirectory. |
| 72 // Returns an empty path if any of the given parameters are invalid. | 77 // Returns an empty path if any of the given parameters are invalid. |
| 73 // Returned directory path does not contain 'unique' part, therefore | 78 // Returned directory path does not contain 'unique' part, therefore |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 118 |
| 114 const FilePath base_path_; | 119 const FilePath base_path_; |
| 115 | 120 |
| 116 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); | 121 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); |
| 117 }; | 122 }; |
| 118 | 123 |
| 119 } // namespace fileapi | 124 } // namespace fileapi |
| 120 | 125 |
| 121 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 126 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| 122 | 127 |
| OLD | NEW |