Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: webkit/fileapi/sandbox_mount_point_provider.h

Issue 6603034: Stop returning the true root path of each filesystem from openFileSystem.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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(
35 const GURL& origin_url,
36 FileSystemType type,
37 bool create,
38 FileSystemPathManager::GetRootPathCallback* callback);
39
40 // Like GetFileSystemRootPath, but synchronous, and can be called only while
41 // running on the file thread.
42 FilePath GetFileSystemRootPathOnFileThread(
43 const GURL& origin_url,
44 FileSystemType type,
45 bool create);
46
47 // The FileSystem directory name.
48 static const FilePath::CharType kFileSystemDirectory[];
49
50 static const char kPersistentName[];
51 static const char kTemporaryName[];
52
53 const FilePath& base_path() const {
54 return base_path_;
55 }
56
57 // Checks if a given |name| contains any restricted names/chars in it.
58 virtual bool IsRestrictedFileName(const FilePath& filename) const;
59
60 // Returns the origin identifier string, which is used as a part of the
61 // sandboxed path component, for the given |url|.
62 static std::string GetOriginIdentifierFromURL(const GURL& url);
63
64 // Gets a base directory path of the sandboxed filesystem that is
65 // specified by |origin_identifier| and |type|.
66 // |base_path| must be pointing the FileSystem's data directory
67 // under the profile directory, i.e. <profile_dir>/kFileSystemDirectory.
68 // Returns an empty path if any of the given parameters are invalid.
69 // Returned directory path does not contain 'unique' part, therefore
70 // it is not an actual root path for the filesystem.
71 static FilePath GetFileSystemBaseDirectoryForOriginAndType(
72 const FilePath& base_path,
73 const std::string& origin_identifier,
74 fileapi::FileSystemType type);
75
76 // Enumerates origins under the given |base_path|.
77 // This must be used on the FILE thread.
78 class OriginEnumerator {
79 public:
80 OriginEnumerator(const FilePath& base_path);
81
82 // Returns the next origin identifier. Returns empty if there are no
83 // more origins.
84 std::string Next();
85
86 bool HasTemporary();
87 bool HasPersistent();
88 const FilePath& path() { return current_; }
89
90 private:
91 file_util::FileEnumerator enumerator_;
92 FilePath current_;
93 };
94
95 private:
96 bool GetOriginBasePathAndName(
97 const GURL& origin_url,
98 FilePath* base_path,
99 FileSystemType type,
100 std::string* name);
101
102 class GetFileSystemRootPathTask;
103
104 // The path_manager_ isn't owned by this instance; this instance is owned by
105 // the path_manager_, and they have the same lifetime.
106 FileSystemPathManager* path_manager_;
107
108 scoped_refptr<base::MessageLoopProxy> file_message_loop_;
109
110 const FilePath base_path_;
111
112 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider);
113 };
114
115 } // namespace fileapi
116
117 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_
118
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698