| 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 "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/child_process_security_policy.h" | 10 #include "content/public/browser/child_process_security_policy.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 DCHECK(isolated_context); | 326 DCHECK(isolated_context); |
| 327 | 327 |
| 328 result.filesystem_id = isolated_context->RegisterFileSystemForPath( | 328 result.filesystem_id = isolated_context->RegisterFileSystemForPath( |
| 329 fileapi::kFileSystemTypeNativeForPlatformApp, path, | 329 fileapi::kFileSystemTypeNativeForPlatformApp, path, |
| 330 &result.registered_name); | 330 &result.registered_name); |
| 331 | 331 |
| 332 content::ChildProcessSecurityPolicy* policy = | 332 content::ChildProcessSecurityPolicy* policy = |
| 333 content::ChildProcessSecurityPolicy::GetInstance(); | 333 content::ChildProcessSecurityPolicy::GetInstance(); |
| 334 policy->GrantReadFileSystem(renderer_id, result.filesystem_id); | 334 policy->GrantReadFileSystem(renderer_id, result.filesystem_id); |
| 335 if (HasFileSystemWritePermission(extension)) { | 335 if (HasFileSystemWritePermission(extension)) { |
| 336 policy->GrantWriteFileSystem(renderer_id, result.filesystem_id); | 336 if (is_directory) { |
| 337 policy->GrantDeleteFromFileSystem(renderer_id, result.filesystem_id); | 337 policy->GrantCreateReadWriteFileSystem(renderer_id, result.filesystem_id); |
| 338 if (is_directory) | 338 } else { |
| 339 policy->GrantCreateFileForFileSystem(renderer_id, result.filesystem_id); | 339 policy->GrantWriteFileSystem(renderer_id, result.filesystem_id); |
| 340 policy->GrantDeleteFromFileSystem(renderer_id, result.filesystem_id); |
| 341 } |
| 340 } | 342 } |
| 341 | 343 |
| 342 result.id = result.filesystem_id + ":" + result.registered_name; | 344 result.id = result.filesystem_id + ":" + result.registered_name; |
| 343 return result; | 345 return result; |
| 344 } | 346 } |
| 345 | 347 |
| 346 void CheckWritableFiles( | 348 void CheckWritableFiles( |
| 347 const std::vector<base::FilePath>& paths, | 349 const std::vector<base::FilePath>& paths, |
| 348 Profile* profile, | 350 Profile* profile, |
| 349 bool is_directory, | 351 bool is_directory, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 *error = kInvalidParameters; | 410 *error = kInvalidParameters; |
| 409 return false; | 411 return false; |
| 410 } | 412 } |
| 411 | 413 |
| 412 return true; | 414 return true; |
| 413 } | 415 } |
| 414 | 416 |
| 415 } // namespace app_file_handler_util | 417 } // namespace app_file_handler_util |
| 416 | 418 |
| 417 } // namespace extensions | 419 } // namespace extensions |
| OLD | NEW |