| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/renderer_host/pepper/pepper_external_file_ref_backend.
h" | 5 #include "content/browser/renderer_host/pepper/pepper_external_file_ref_backend.
h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util_proxy.h" | 8 #include "base/files/file_util_proxy.h" |
| 9 #include "content/browser/child_process_security_policy_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 std::string PepperExternalFileRefBackend::GetFileSystemURLSpec() const { | 100 std::string PepperExternalFileRefBackend::GetFileSystemURLSpec() const { |
| 101 return std::string(); | 101 return std::string(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 base::FilePath PepperExternalFileRefBackend::GetExternalPath() const { | 104 base::FilePath PepperExternalFileRefBackend::GetExternalPath() const { |
| 105 return path_; | 105 return path_; |
| 106 } | 106 } |
| 107 | 107 |
| 108 int32_t PepperExternalFileRefBackend::HasPermissions( | 108 int32_t PepperExternalFileRefBackend::CanRead() const { |
| 109 int permissions) const { | 109 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> |
| 110 if (!ChildProcessSecurityPolicyImpl::GetInstance()->HasPermissionsForFile( | 110 CanReadFile(render_process_id_, path_)) { |
| 111 render_process_id_, path_, permissions)) { | |
| 112 return PP_ERROR_NOACCESS; | 111 return PP_ERROR_NOACCESS; |
| 113 } | 112 } |
| 114 return PP_OK; | 113 return PP_OK; |
| 114 } |
| 115 |
| 116 int32_t PepperExternalFileRefBackend::CanWrite() const { |
| 117 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> |
| 118 CanWriteFile(render_process_id_, path_)) { |
| 119 return PP_ERROR_NOACCESS; |
| 120 } |
| 121 return PP_OK; |
| 122 } |
| 123 |
| 124 int32_t PepperExternalFileRefBackend::CanCreate() const { |
| 125 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> |
| 126 CanCreateFile(render_process_id_, path_)) { |
| 127 return PP_ERROR_NOACCESS; |
| 128 } |
| 129 return PP_OK; |
| 130 } |
| 131 |
| 132 int32_t PepperExternalFileRefBackend::CanReadWrite() const { |
| 133 ChildProcessSecurityPolicyImpl* policy = |
| 134 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 135 if (!policy->CanReadFile(render_process_id_, path_) || |
| 136 !policy->CanWriteFile(render_process_id_, path_)) { |
| 137 return PP_ERROR_NOACCESS; |
| 138 } |
| 139 return PP_OK; |
| 115 } | 140 } |
| 116 | 141 |
| 117 void PepperExternalFileRefBackend::DidFinish( | 142 void PepperExternalFileRefBackend::DidFinish( |
| 118 ppapi::host::ReplyMessageContext reply_context, | 143 ppapi::host::ReplyMessageContext reply_context, |
| 119 const IPC::Message& msg, | 144 const IPC::Message& msg, |
| 120 base::PlatformFileError error) { | 145 base::PlatformFileError error) { |
| 121 reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); | 146 reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); |
| 122 host_->SendReply(reply_context, msg); | 147 host_->SendReply(reply_context, msg); |
| 123 } | 148 } |
| 124 | 149 |
| 125 void PepperExternalFileRefBackend::GetMetadataComplete( | 150 void PepperExternalFileRefBackend::GetMetadataComplete( |
| 126 ppapi::host::ReplyMessageContext reply_context, | 151 ppapi::host::ReplyMessageContext reply_context, |
| 127 const base::PlatformFileError error, | 152 const base::PlatformFileError error, |
| 128 const base::PlatformFileInfo& file_info) { | 153 const base::PlatformFileInfo& file_info) { |
| 129 reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); | 154 reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); |
| 130 | 155 |
| 131 PP_FileInfo pp_file_info; | 156 PP_FileInfo pp_file_info; |
| 132 if (error == base::PLATFORM_FILE_OK) { | 157 if (error == base::PLATFORM_FILE_OK) { |
| 133 ppapi::PlatformFileInfoToPepperFileInfo( | 158 ppapi::PlatformFileInfoToPepperFileInfo( |
| 134 file_info, PP_FILESYSTEMTYPE_EXTERNAL, &pp_file_info); | 159 file_info, PP_FILESYSTEMTYPE_EXTERNAL, &pp_file_info); |
| 135 } else { | 160 } else { |
| 136 memset(&pp_file_info, 0, sizeof(pp_file_info)); | 161 memset(&pp_file_info, 0, sizeof(pp_file_info)); |
| 137 } | 162 } |
| 138 | 163 |
| 139 host_->SendReply(reply_context, | 164 host_->SendReply(reply_context, |
| 140 PpapiPluginMsg_FileRef_QueryReply(pp_file_info)); | 165 PpapiPluginMsg_FileRef_QueryReply(pp_file_info)); |
| 141 } | 166 } |
| 142 | 167 |
| 143 } // namespace content | 168 } // namespace content |
| OLD | NEW |