| 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 "chrome/browser/extensions/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 result.filesystem_id = isolated_context->RegisterFileSystemForPath( | 307 result.filesystem_id = isolated_context->RegisterFileSystemForPath( |
| 308 fileapi::kFileSystemTypeNativeForPlatformApp, path, | 308 fileapi::kFileSystemTypeNativeForPlatformApp, path, |
| 309 &result.registered_name); | 309 &result.registered_name); |
| 310 | 310 |
| 311 content::ChildProcessSecurityPolicy* policy = | 311 content::ChildProcessSecurityPolicy* policy = |
| 312 content::ChildProcessSecurityPolicy::GetInstance(); | 312 content::ChildProcessSecurityPolicy::GetInstance(); |
| 313 policy->GrantReadFileSystem(renderer_id, result.filesystem_id); | 313 policy->GrantReadFileSystem(renderer_id, result.filesystem_id); |
| 314 if (HasFileSystemWritePermission(extension)) { | 314 if (HasFileSystemWritePermission(extension)) { |
| 315 policy->GrantWriteFileSystem(renderer_id, result.filesystem_id); | 315 policy->GrantWriteFileSystem(renderer_id, result.filesystem_id); |
| 316 policy->GrantDeleteFromFileSystem(renderer_id, result.filesystem_id); |
| 316 if (is_directory) | 317 if (is_directory) |
| 317 policy->GrantCreateFileForFileSystem(renderer_id, result.filesystem_id); | 318 policy->GrantCreateFileForFileSystem(renderer_id, result.filesystem_id); |
| 318 } | 319 } |
| 319 | 320 |
| 320 result.id = result.filesystem_id + ":" + result.registered_name; | 321 result.id = result.filesystem_id + ":" + result.registered_name; |
| 321 return result; | 322 return result; |
| 322 } | 323 } |
| 323 | 324 |
| 324 void CheckWritableFiles( | 325 void CheckWritableFiles( |
| 325 const std::vector<base::FilePath>& paths, | 326 const std::vector<base::FilePath>& paths, |
| 326 Profile* profile, | 327 Profile* profile, |
| 327 bool is_directory, | 328 bool is_directory, |
| 328 const base::Closure& on_success, | 329 const base::Closure& on_success, |
| 329 const base::Callback<void(const base::FilePath&)>& on_failure) { | 330 const base::Callback<void(const base::FilePath&)>& on_failure) { |
| 330 scoped_refptr<WritableFileChecker> checker(new WritableFileChecker( | 331 scoped_refptr<WritableFileChecker> checker(new WritableFileChecker( |
| 331 paths, profile, is_directory, on_success, on_failure)); | 332 paths, profile, is_directory, on_success, on_failure)); |
| 332 checker->Check(); | 333 checker->Check(); |
| 333 } | 334 } |
| 334 | 335 |
| 335 GrantedFileEntry::GrantedFileEntry() {} | 336 GrantedFileEntry::GrantedFileEntry() {} |
| 336 | 337 |
| 337 bool HasFileSystemWritePermission(const Extension* extension) { | 338 bool HasFileSystemWritePermission(const Extension* extension) { |
| 338 return extension->HasAPIPermission(APIPermission::kFileSystemWrite); | 339 return extension->HasAPIPermission(APIPermission::kFileSystemWrite); |
| 339 } | 340 } |
| 340 | 341 |
| 341 } // namespace app_file_handler_util | 342 } // namespace app_file_handler_util |
| 342 | 343 |
| 343 } // namespace extensions | 344 } // namespace extensions |
| OLD | NEW |