OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" | 5 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
6 | 6 |
7 #include "apps/browser/file_handler_util.h" | 7 #include "apps/browser/file_handler_util.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 const Extension* extension, | 292 const Extension* extension, |
293 int renderer_id, | 293 int renderer_id, |
294 const base::FilePath& path, | 294 const base::FilePath& path, |
295 bool is_directory) { | 295 bool is_directory) { |
296 GrantedFileEntry result; | 296 GrantedFileEntry result; |
297 fileapi::IsolatedContext* isolated_context = | 297 fileapi::IsolatedContext* isolated_context = |
298 fileapi::IsolatedContext::GetInstance(); | 298 fileapi::IsolatedContext::GetInstance(); |
299 DCHECK(isolated_context); | 299 DCHECK(isolated_context); |
300 | 300 |
301 result.filesystem_id = isolated_context->RegisterFileSystemForPath( | 301 result.filesystem_id = isolated_context->RegisterFileSystemForPath( |
302 fileapi::kFileSystemTypeNativeForPlatformApp, path, | 302 fileapi::kFileSystemTypeNativeForPlatformApp, std::string(), path, |
303 &result.registered_name); | 303 &result.registered_name); |
304 | 304 |
305 content::ChildProcessSecurityPolicy* policy = | 305 content::ChildProcessSecurityPolicy* policy = |
306 content::ChildProcessSecurityPolicy::GetInstance(); | 306 content::ChildProcessSecurityPolicy::GetInstance(); |
307 policy->GrantReadFileSystem(renderer_id, result.filesystem_id); | 307 policy->GrantReadFileSystem(renderer_id, result.filesystem_id); |
308 if (HasFileSystemWritePermission(extension)) { | 308 if (HasFileSystemWritePermission(extension)) { |
309 if (is_directory) { | 309 if (is_directory) { |
310 policy->GrantCreateReadWriteFileSystem(renderer_id, result.filesystem_id); | 310 policy->GrantCreateReadWriteFileSystem(renderer_id, result.filesystem_id); |
311 } else { | 311 } else { |
312 policy->GrantWriteFileSystem(renderer_id, result.filesystem_id); | 312 policy->GrantWriteFileSystem(renderer_id, result.filesystem_id); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 return false; | 361 return false; |
362 } | 362 } |
363 | 363 |
364 fileapi::IsolatedContext* context = fileapi::IsolatedContext::GetInstance(); | 364 fileapi::IsolatedContext* context = fileapi::IsolatedContext::GetInstance(); |
365 base::FilePath relative_path = | 365 base::FilePath relative_path = |
366 base::FilePath::FromUTF8Unsafe(filesystem_path); | 366 base::FilePath::FromUTF8Unsafe(filesystem_path); |
367 base::FilePath virtual_path = context->CreateVirtualRootPath(filesystem_id) | 367 base::FilePath virtual_path = context->CreateVirtualRootPath(filesystem_id) |
368 .Append(relative_path); | 368 .Append(relative_path); |
369 fileapi::FileSystemType type; | 369 fileapi::FileSystemType type; |
370 fileapi::FileSystemMountOption mount_option; | 370 fileapi::FileSystemMountOption mount_option; |
| 371 std::string cracked_id; |
371 if (!context->CrackVirtualPath( | 372 if (!context->CrackVirtualPath( |
372 virtual_path, &filesystem_id, &type, file_path, &mount_option)) { | 373 virtual_path, &filesystem_id, &type, &cracked_id, file_path, |
| 374 &mount_option)) { |
373 *error = kInvalidParameters; | 375 *error = kInvalidParameters; |
374 return false; | 376 return false; |
375 } | 377 } |
376 | 378 |
377 // The file system API is only intended to operate on file entries that | 379 // The file system API is only intended to operate on file entries that |
378 // correspond to a native file, selected by the user so only allow file | 380 // correspond to a native file, selected by the user so only allow file |
379 // systems returned by the file system API or from a drag and drop operation. | 381 // systems returned by the file system API or from a drag and drop operation. |
380 if (type != fileapi::kFileSystemTypeNativeForPlatformApp && | 382 if (type != fileapi::kFileSystemTypeNativeForPlatformApp && |
381 type != fileapi::kFileSystemTypeDragged) { | 383 type != fileapi::kFileSystemTypeDragged) { |
382 *error = kInvalidParameters; | 384 *error = kInvalidParameters; |
383 return false; | 385 return false; |
384 } | 386 } |
385 | 387 |
386 return true; | 388 return true; |
387 } | 389 } |
388 | 390 |
389 } // namespace app_file_handler_util | 391 } // namespace app_file_handler_util |
390 | 392 |
391 } // namespace extensions | 393 } // namespace extensions |
OLD | NEW |