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 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 5 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_callback_factory.h" | 8 #include "base/memory/scoped_callback_factory.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 } // anonymous namespace | 107 } // anonymous namespace |
108 | 108 |
109 namespace fileapi { | 109 namespace fileapi { |
110 | 110 |
111 const FilePath::CharType SandboxMountPointProvider::kFileSystemDirectory[] = | 111 const FilePath::CharType SandboxMountPointProvider::kFileSystemDirectory[] = |
112 FILE_PATH_LITERAL("FileSystem"); | 112 FILE_PATH_LITERAL("FileSystem"); |
113 | 113 |
114 const char SandboxMountPointProvider::kPersistentName[] = "Persistent"; | 114 const char SandboxMountPointProvider::kPersistentName[] = "Persistent"; |
115 const char SandboxMountPointProvider::kTemporaryName[] = "Temporary"; | 115 const char SandboxMountPointProvider::kTemporaryName[] = "Temporary"; |
| 116 const char SandboxMountPointProvider::kExternalName[] = "External"; |
116 | 117 |
117 SandboxMountPointProvider::SandboxMountPointProvider( | 118 SandboxMountPointProvider::SandboxMountPointProvider( |
118 FileSystemPathManager* path_manager, | 119 FileSystemPathManager* path_manager, |
119 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 120 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
120 const FilePath& profile_path) | 121 const FilePath& profile_path) |
121 : path_manager_(path_manager), | 122 : path_manager_(path_manager), |
122 file_message_loop_(file_message_loop), | 123 file_message_loop_(file_message_loop), |
123 base_path_(profile_path.Append(kFileSystemDirectory)) { | 124 base_path_(profile_path.Append(kFileSystemDirectory)) { |
124 } | 125 } |
125 | 126 |
126 SandboxMountPointProvider::~SandboxMountPointProvider() { | 127 SandboxMountPointProvider::~SandboxMountPointProvider() { |
127 } | 128 } |
128 | 129 |
129 bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url) { | 130 bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url, |
| 131 const FilePath& unused) { |
130 // We essentially depend on quota to do our access controls. | 132 // We essentially depend on quota to do our access controls. |
131 return path_manager_->IsAllowedScheme(origin_url); | 133 return path_manager_->IsAllowedScheme(origin_url); |
132 } | 134 } |
133 | 135 |
134 class SandboxMountPointProvider::GetFileSystemRootPathTask | 136 class SandboxMountPointProvider::GetFileSystemRootPathTask |
135 : public base::RefCountedThreadSafe< | 137 : public base::RefCountedThreadSafe< |
136 SandboxMountPointProvider::GetFileSystemRootPathTask> { | 138 SandboxMountPointProvider::GetFileSystemRootPathTask> { |
137 public: | 139 public: |
138 GetFileSystemRootPathTask( | 140 GetFileSystemRootPathTask( |
139 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 141 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 206 |
205 for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) { | 207 for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) { |
206 if (filename.value().find(kRestrictedChars[i]) != | 208 if (filename.value().find(kRestrictedChars[i]) != |
207 FilePath::StringType::npos) | 209 FilePath::StringType::npos) |
208 return true; | 210 return true; |
209 } | 211 } |
210 | 212 |
211 return false; | 213 return false; |
212 } | 214 } |
213 | 215 |
| 216 std::vector<FilePath> SandboxMountPointProvider::GetRootDirectories() const { |
| 217 NOTREACHED(); |
| 218 // TODO(ericu): Implement this method and check for access permissions as |
| 219 // fileBrowserPrivate extension API does. We currently have another mechanism, |
| 220 // but we should switch over. |
| 221 return std::vector<FilePath>(); |
| 222 } |
| 223 |
214 void SandboxMountPointProvider::GetFileSystemRootPath( | 224 void SandboxMountPointProvider::GetFileSystemRootPath( |
215 const GURL& origin_url, fileapi::FileSystemType type, | 225 const GURL& origin_url, fileapi::FileSystemType type, |
216 bool create, FileSystemPathManager::GetRootPathCallback* callback_ptr) { | 226 bool create, FileSystemPathManager::GetRootPathCallback* callback_ptr) { |
217 scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback(callback_ptr); | 227 scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback(callback_ptr); |
218 std::string name; | 228 std::string name; |
219 FilePath origin_base_path; | 229 FilePath origin_base_path; |
220 | 230 |
221 if (!GetOriginBasePathAndName(origin_url, &origin_base_path, type, &name)) { | 231 if (!GetOriginBasePathAndName(origin_url, &origin_base_path, type, &name)) { |
222 callback->Run(false, FilePath(), std::string()); | 232 callback->Run(false, FilePath(), std::string()); |
223 return; | 233 return; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 317 |
308 std::string type_string = | 318 std::string type_string = |
309 FileSystemPathManager::GetFileSystemTypeString(type); | 319 FileSystemPathManager::GetFileSystemTypeString(type); |
310 DCHECK(!type_string.empty()); | 320 DCHECK(!type_string.empty()); |
311 if (name) | 321 if (name) |
312 *name = origin_identifier + ":" + type_string; | 322 *name = origin_identifier + ":" + type_string; |
313 return true; | 323 return true; |
314 } | 324 } |
315 | 325 |
316 } // namespace fileapi | 326 } // namespace fileapi |
OLD | NEW |