Chromium Code Reviews| Index: content/browser/renderer_host/pepper/pepper_security_helper.cc |
| diff --git a/content/browser/renderer_host/pepper/pepper_security_helper.cc b/content/browser/renderer_host/pepper/pepper_security_helper.cc |
| index 5402823f01e56f68d815fc2a3bd1238e2518f07f..617f75787e08d50a8013ce628ece095646ef35c8 100644 |
| --- a/content/browser/renderer_host/pepper/pepper_security_helper.cc |
| +++ b/content/browser/renderer_host/pepper/pepper_security_helper.cc |
| @@ -28,11 +28,9 @@ bool CanOpenWithPepperFlags(int pp_open_flags, int child_id, |
| if (pp_write && !policy->CanWriteFile(child_id, file)) |
| return false; |
| - if (pp_append) { |
| - // Given ChildSecurityPolicyImpl's current definition of permissions, |
| - // APPEND is never supported. |
| + // TODO(tommycli): Maybe tighten up required permission. crbug.com/284792 |
| + if (pp_append && !policy->CanCreateWriteFile(child_id, file)) |
| return false; |
| - } |
| if (pp_truncate && !pp_write) |
| return false; |
| @@ -51,4 +49,43 @@ bool CanOpenWithPepperFlags(int pp_open_flags, int child_id, |
| return true; |
| } |
| +bool CanOpenFileSystemURLWithPepperFlags(int pp_open_flags, int child_id, |
| + const fileapi::FileSystemURL& url) { |
| + ChildProcessSecurityPolicyImpl* policy = |
| + ChildProcessSecurityPolicyImpl::GetInstance(); |
| + |
| + bool pp_read = !!(pp_open_flags & PP_FILEOPENFLAG_READ); |
|
Tom Sepez
2013/09/04 22:22:45
Seems a shame to have this same logic here and abo
tommycli
2013/09/04 23:21:27
I agree it's a shame. The only obvious way I saw t
kinuko
2013/09/05 03:49:43
Could we make the common logic a template? I thin
tommycli
2013/09/06 01:41:43
Done. I had no idea you could do this with templat
|
| + bool pp_write = !!(pp_open_flags & PP_FILEOPENFLAG_WRITE); |
| + bool pp_create = !!(pp_open_flags & PP_FILEOPENFLAG_CREATE); |
| + bool pp_truncate = !!(pp_open_flags & PP_FILEOPENFLAG_TRUNCATE); |
| + bool pp_exclusive = !!(pp_open_flags & PP_FILEOPENFLAG_EXCLUSIVE); |
| + bool pp_append = !!(pp_open_flags & PP_FILEOPENFLAG_APPEND); |
| + |
| + if (pp_read && !policy->CanReadFileSystemFile(child_id, url)) |
| + return false; |
| + |
| + if (pp_write && !policy->CanWriteFileSystemFile(child_id, url)) |
| + return false; |
| + |
| + // TODO(tommycli): Maybe tighten up required permission. crbug.com/284792 |
| + if (pp_append && !policy->CanCreateWriteFileSystemFile(child_id, url)) |
| + return false; |
| + |
| + if (pp_truncate && !pp_write) |
| + return false; |
| + |
| + if (pp_create) { |
| + if (pp_exclusive) { |
| + return policy->CanCreateFileSystemFile(child_id, url); |
| + } else { |
| + // Asks for too much, but this is the only grant that allows overwrite. |
| + return policy->CanCreateWriteFileSystemFile(child_id, url); |
| + } |
| + } else if (pp_truncate) { |
| + return policy->CanCreateWriteFileSystemFile(child_id, url); |
| + } |
| + |
| + return true; |
| +} |
| + |
| } // namespace content |