Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | |
| 6 #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | |
| 7 | |
| 8 #include "base/file_path.h" | |
| 9 #include "googleurl/src/gurl.h" | |
| 10 #include "webkit/fileapi/file_system_mount_point_provider.h" | |
| 11 | |
| 12 class GURL; | |
| 13 | |
| 14 namespace base { | |
| 15 class MessageLoopProxy; | |
| 16 } | |
| 17 | |
| 18 namespace fileapi { | |
| 19 | |
| 20 class SandboxMountPointProvider : public FileSystemMountPointProvider { | |
| 21 public: | |
| 22 | |
| 23 SandboxMountPointProvider( | |
| 24 FileSystemPathManager* path_manager, | |
| 25 scoped_refptr<base::MessageLoopProxy> file_message_loop, | |
| 26 const FilePath& profile_path); | |
| 27 | |
| 28 // Checks if mount point access is allowed from |origin_url|. | |
| 29 virtual bool IsAccessAllowed(const GURL& origin_url); | |
| 30 | |
| 31 // Retrieves the root path for the given |origin_url| and |type|, and | |
| 32 // calls the given |callback| with the root path and name. | |
| 33 // If |create| is true this also creates the directory if it doesn't exist. | |
| 34 void GetFileSystemRootPath(const GURL& origin_url, | |
| 35 FileSystemType type, | |
| 36 bool create, | |
| 37 FileSystemPathManager::GetRootPathCallback* | |
| 38 callback); | |
|
kinuko
2011/03/14 11:03:57
nits: if we format these lines like following the
ericu
2011/03/15 02:43:11
Done.
| |
| 39 | |
| 40 // Like GetFileSystemRootPath, but synchronous, and can be called only while | |
| 41 // running on the file thread. | |
| 42 FilePath GetFileSystemRootPathOnFileThread(const GURL& origin_url, | |
| 43 FileSystemType type, | |
| 44 bool create); | |
| 45 | |
| 46 // The FileSystem directory name. | |
| 47 static const FilePath::CharType kFileSystemDirectory[]; | |
| 48 | |
| 49 static const char kPersistentName[]; | |
| 50 static const char kTemporaryName[]; | |
| 51 | |
| 52 const FilePath& base_path() const { | |
| 53 return base_path_; | |
| 54 } | |
| 55 | |
| 56 // Checks if a given |name| contains any restricted names/chars in it. | |
| 57 virtual bool IsRestrictedFileName(const FilePath& filename); | |
| 58 | |
| 59 // Returns the origin identifier string, which is used as a part of the | |
| 60 // sandboxed path component, for the given |url|. | |
| 61 static std::string GetOriginIdentifierFromURL(const GURL& url); | |
| 62 | |
| 63 // Gets a base directory path of the sandboxed filesystem that is | |
| 64 // specified by |origin_identifier| and |type|. | |
| 65 // |base_path| must be pointing the FileSystem's data directory | |
| 66 // under the profile directory, i.e. <profile_dir>/kFileSystemDirectory. | |
| 67 // Returns an empty path if any of the given parameters are invalid. | |
| 68 // Returned directory path does not contain 'unique' part, therefore | |
| 69 // it is not an actual root path for the filesystem. | |
| 70 static FilePath GetFileSystemBaseDirectoryForOriginAndType( | |
| 71 const FilePath& base_path, | |
| 72 const std::string& origin_identifier, | |
| 73 fileapi::FileSystemType type); | |
| 74 | |
| 75 // Enumerates origins under the given |base_path|. | |
| 76 // This must be used on the FILE thread. | |
| 77 class OriginEnumerator { | |
| 78 public: | |
| 79 OriginEnumerator(const FilePath& base_path); | |
| 80 | |
| 81 // Returns the next origin identifier. Returns empty if there are no | |
| 82 // more origins. | |
| 83 std::string Next(); | |
| 84 | |
| 85 bool HasTemporary(); | |
| 86 bool HasPersistent(); | |
| 87 const FilePath& path() { return current_; } | |
| 88 | |
| 89 private: | |
| 90 file_util::FileEnumerator enumerator_; | |
| 91 FilePath current_; | |
| 92 }; | |
| 93 | |
| 94 private: | |
| 95 bool GetOriginBasePathAndName( | |
| 96 const GURL& origin_url, | |
| 97 FilePath* base_path, | |
| 98 FileSystemType type, | |
| 99 std::string* name); | |
| 100 | |
| 101 class GetFileSystemRootPathTask; | |
| 102 | |
| 103 FileSystemPathManager* path_manager_; | |
|
kinuko
2011/03/14 11:03:57
Let's add a comment to note that it's not owned by
ericu
2011/03/15 02:43:11
Done.
| |
| 104 | |
| 105 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | |
| 106 | |
| 107 const FilePath base_path_; | |
| 108 | |
| 109 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); | |
| 110 }; | |
| 111 | |
| 112 } // namespace fileapi | |
| 113 | |
| 114 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | |
| 115 | |
| OLD | NEW |