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

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

Issue 6810037: File API changes needed for safely passing user selected file entities from the file browser comp... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
« no previous file with comments | « webkit/fileapi/sandbox_mount_point_provider.h ('k') | webkit/fileapi/webkit_fileapi.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return root; 104 return root;
105 } 105 }
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";
115 const char SandboxMountPointProvider::kTemporaryName[] = "Temporary";
116
117 SandboxMountPointProvider::SandboxMountPointProvider( 114 SandboxMountPointProvider::SandboxMountPointProvider(
118 FileSystemPathManager* path_manager, 115 FileSystemPathManager* path_manager,
119 scoped_refptr<base::MessageLoopProxy> file_message_loop, 116 scoped_refptr<base::MessageLoopProxy> file_message_loop,
120 const FilePath& profile_path) 117 const FilePath& profile_path)
121 : path_manager_(path_manager), 118 : path_manager_(path_manager),
122 file_message_loop_(file_message_loop), 119 file_message_loop_(file_message_loop),
123 base_path_(profile_path.Append(kFileSystemDirectory)) { 120 base_path_(profile_path.Append(kFileSystemDirectory)) {
124 } 121 }
125 122
126 SandboxMountPointProvider::~SandboxMountPointProvider() { 123 SandboxMountPointProvider::~SandboxMountPointProvider() {
127 } 124 }
128 125
129 bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url) { 126 bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url,
127 FileSystemType type,
128 const FilePath& unused) {
129 if (type != kFileSystemTypeTemporary && type != kFileSystemTypePersistent)
130 return false;
130 // We essentially depend on quota to do our access controls. 131 // We essentially depend on quota to do our access controls.
131 return path_manager_->IsAllowedScheme(origin_url); 132 return path_manager_->IsAllowedScheme(origin_url);
132 } 133 }
133 134
134 class SandboxMountPointProvider::GetFileSystemRootPathTask 135 class SandboxMountPointProvider::GetFileSystemRootPathTask
135 : public base::RefCountedThreadSafe< 136 : public base::RefCountedThreadSafe<
136 SandboxMountPointProvider::GetFileSystemRootPathTask> { 137 SandboxMountPointProvider::GetFileSystemRootPathTask> {
137 public: 138 public:
138 GetFileSystemRootPathTask( 139 GetFileSystemRootPathTask(
139 scoped_refptr<base::MessageLoopProxy> file_message_loop, 140 scoped_refptr<base::MessageLoopProxy> file_message_loop,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 205
205 for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) { 206 for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) {
206 if (filename.value().find(kRestrictedChars[i]) != 207 if (filename.value().find(kRestrictedChars[i]) !=
207 FilePath::StringType::npos) 208 FilePath::StringType::npos)
208 return true; 209 return true;
209 } 210 }
210 211
211 return false; 212 return false;
212 } 213 }
213 214
215 std::vector<FilePath> SandboxMountPointProvider::GetRootDirectories() const {
216 NOTREACHED();
217 // TODO(ericu): Implement this method and check for access permissions as
218 // fileBrowserPrivate extension API does. We currently have another mechanism,
219 // but we should switch over.
220 return std::vector<FilePath>();
221 }
222
214 void SandboxMountPointProvider::GetFileSystemRootPath( 223 void SandboxMountPointProvider::GetFileSystemRootPath(
215 const GURL& origin_url, fileapi::FileSystemType type, 224 const GURL& origin_url, fileapi::FileSystemType type,
216 bool create, FileSystemPathManager::GetRootPathCallback* callback_ptr) { 225 bool create, FileSystemPathManager::GetRootPathCallback* callback_ptr) {
217 scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback(callback_ptr); 226 scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback(callback_ptr);
218 std::string name; 227 std::string name;
219 FilePath origin_base_path; 228 FilePath origin_base_path;
220 229
221 if (!GetOriginBasePathAndName(origin_url, &origin_base_path, type, &name)) { 230 if (!GetOriginBasePathAndName(origin_url, &origin_base_path, type, &name)) {
222 callback->Run(false, FilePath(), std::string()); 231 callback->Run(false, FilePath(), std::string());
223 return; 232 return;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 file_util::FileEnumerator::DIRECTORIES) { 280 file_util::FileEnumerator::DIRECTORIES) {
272 } 281 }
273 282
274 std::string SandboxMountPointProvider::OriginEnumerator::Next() { 283 std::string SandboxMountPointProvider::OriginEnumerator::Next() {
275 current_ = enumerator_.Next(); 284 current_ = enumerator_.Next();
276 return FilePathStringToASCII(current_.BaseName().value()); 285 return FilePathStringToASCII(current_.BaseName().value());
277 } 286 }
278 287
279 bool SandboxMountPointProvider::OriginEnumerator::HasTemporary() { 288 bool SandboxMountPointProvider::OriginEnumerator::HasTemporary() {
280 return !current_.empty() && file_util::DirectoryExists(current_.AppendASCII( 289 return !current_.empty() && file_util::DirectoryExists(current_.AppendASCII(
281 SandboxMountPointProvider::kTemporaryName)); 290 fileapi::kTemporaryName));
282 } 291 }
283 292
284 bool SandboxMountPointProvider::OriginEnumerator::HasPersistent() { 293 bool SandboxMountPointProvider::OriginEnumerator::HasPersistent() {
285 return !current_.empty() && file_util::DirectoryExists(current_.AppendASCII( 294 return !current_.empty() && file_util::DirectoryExists(current_.AppendASCII(
286 SandboxMountPointProvider::kPersistentName)); 295 fileapi::kPersistentName));
287 } 296 }
288 297
289 bool SandboxMountPointProvider::GetOriginBasePathAndName( 298 bool SandboxMountPointProvider::GetOriginBasePathAndName(
290 const GURL& origin_url, 299 const GURL& origin_url,
291 FilePath* origin_base_path, 300 FilePath* origin_base_path,
292 FileSystemType type, 301 FileSystemType type,
293 std::string* name) { 302 std::string* name) {
294 303
295 if (path_manager_->is_incognito()) 304 if (path_manager_->is_incognito())
296 // TODO(kinuko): return an isolated temporary directory. 305 // TODO(kinuko): return an isolated temporary directory.
(...skipping 10 matching lines...) Expand all
307 316
308 std::string type_string = 317 std::string type_string =
309 FileSystemPathManager::GetFileSystemTypeString(type); 318 FileSystemPathManager::GetFileSystemTypeString(type);
310 DCHECK(!type_string.empty()); 319 DCHECK(!type_string.empty());
311 if (name) 320 if (name)
312 *name = origin_identifier + ":" + type_string; 321 *name = origin_identifier + ":" + type_string;
313 return true; 322 return true;
314 } 323 }
315 324
316 } // namespace fileapi 325 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/sandbox_mount_point_provider.h ('k') | webkit/fileapi/webkit_fileapi.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698