| 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_internal_file_ref_backend.
h" | 5 #include "content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.
h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 scoped_refptr<fileapi::FileSystemContext> | 79 scoped_refptr<fileapi::FileSystemContext> |
| 80 PepperInternalFileRefBackend::GetFileSystemContext() const { | 80 PepperInternalFileRefBackend::GetFileSystemContext() const { |
| 81 if (!fs_host_.get()) | 81 if (!fs_host_.get()) |
| 82 return NULL; | 82 return NULL; |
| 83 return fs_host_->GetFileSystemContext(); | 83 return fs_host_->GetFileSystemContext(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void PepperInternalFileRefBackend::DidFinish( | 86 void PepperInternalFileRefBackend::DidFinish( |
| 87 ppapi::host::ReplyMessageContext context, | 87 ppapi::host::ReplyMessageContext context, |
| 88 const IPC::Message& msg, | 88 const IPC::Message& msg, |
| 89 base::PlatformFileError error) { | 89 base::File::Error error) { |
| 90 context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); | 90 context.params.set_result(ppapi::FileErrorToPepperError(error)); |
| 91 host_->SendReply(context, msg); | 91 host_->SendReply(context, msg); |
| 92 } | 92 } |
| 93 | 93 |
| 94 int32_t PepperInternalFileRefBackend::MakeDirectory( | 94 int32_t PepperInternalFileRefBackend::MakeDirectory( |
| 95 ppapi::host::ReplyMessageContext reply_context, | 95 ppapi::host::ReplyMessageContext reply_context, |
| 96 int32_t make_directory_flags) { | 96 int32_t make_directory_flags) { |
| 97 if (!GetFileSystemURL().is_valid()) | 97 if (!GetFileSystemURL().is_valid()) |
| 98 return PP_ERROR_FAILED; | 98 return PP_ERROR_FAILED; |
| 99 | 99 |
| 100 GetFileSystemContext()->operation_runner()->CreateDirectory( | 100 GetFileSystemContext()->operation_runner()->CreateDirectory( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 GetFileSystemContext()->operation_runner()->GetMetadata( | 172 GetFileSystemContext()->operation_runner()->GetMetadata( |
| 173 GetFileSystemURL(), | 173 GetFileSystemURL(), |
| 174 base::Bind(&PepperInternalFileRefBackend::GetMetadataComplete, | 174 base::Bind(&PepperInternalFileRefBackend::GetMetadataComplete, |
| 175 weak_factory_.GetWeakPtr(), | 175 weak_factory_.GetWeakPtr(), |
| 176 reply_context)); | 176 reply_context)); |
| 177 return PP_OK_COMPLETIONPENDING; | 177 return PP_OK_COMPLETIONPENDING; |
| 178 } | 178 } |
| 179 | 179 |
| 180 void PepperInternalFileRefBackend::GetMetadataComplete( | 180 void PepperInternalFileRefBackend::GetMetadataComplete( |
| 181 ppapi::host::ReplyMessageContext reply_context, | 181 ppapi::host::ReplyMessageContext reply_context, |
| 182 base::PlatformFileError error, | 182 base::File::Error error, |
| 183 const base::PlatformFileInfo& file_info) { | 183 const base::File::Info& file_info) { |
| 184 reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); | 184 reply_context.params.set_result(ppapi::FileErrorToPepperError(error)); |
| 185 | 185 |
| 186 PP_FileInfo pp_file_info; | 186 PP_FileInfo pp_file_info; |
| 187 if (error == base::PLATFORM_FILE_OK) | 187 if (error == base::File::FILE_OK) |
| 188 ppapi::PlatformFileInfoToPepperFileInfo(file_info, fs_type_, &pp_file_info); | 188 ppapi::FileInfoToPepperFileInfo(file_info, fs_type_, &pp_file_info); |
| 189 else | 189 else |
| 190 memset(&pp_file_info, 0, sizeof(pp_file_info)); | 190 memset(&pp_file_info, 0, sizeof(pp_file_info)); |
| 191 | 191 |
| 192 host_->SendReply(reply_context, | 192 host_->SendReply(reply_context, |
| 193 PpapiPluginMsg_FileRef_QueryReply(pp_file_info)); | 193 PpapiPluginMsg_FileRef_QueryReply(pp_file_info)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 int32_t PepperInternalFileRefBackend::ReadDirectoryEntries( | 196 int32_t PepperInternalFileRefBackend::ReadDirectoryEntries( |
| 197 ppapi::host::ReplyMessageContext reply_context) { | 197 ppapi::host::ReplyMessageContext reply_context) { |
| 198 if (!GetFileSystemURL().is_valid()) | 198 if (!GetFileSystemURL().is_valid()) |
| 199 return PP_ERROR_FAILED; | 199 return PP_ERROR_FAILED; |
| 200 | 200 |
| 201 GetFileSystemContext()->operation_runner()->ReadDirectory( | 201 GetFileSystemContext()->operation_runner()->ReadDirectory( |
| 202 GetFileSystemURL(), | 202 GetFileSystemURL(), |
| 203 base::Bind(&PepperInternalFileRefBackend::ReadDirectoryComplete, | 203 base::Bind(&PepperInternalFileRefBackend::ReadDirectoryComplete, |
| 204 weak_factory_.GetWeakPtr(), | 204 weak_factory_.GetWeakPtr(), |
| 205 reply_context)); | 205 reply_context)); |
| 206 return PP_OK_COMPLETIONPENDING; | 206 return PP_OK_COMPLETIONPENDING; |
| 207 } | 207 } |
| 208 | 208 |
| 209 void PepperInternalFileRefBackend::ReadDirectoryComplete( | 209 void PepperInternalFileRefBackend::ReadDirectoryComplete( |
| 210 ppapi::host::ReplyMessageContext context, | 210 ppapi::host::ReplyMessageContext context, |
| 211 base::PlatformFileError error, | 211 base::File::Error error, |
| 212 const fileapi::FileSystemOperation::FileEntryList& file_list, | 212 const fileapi::FileSystemOperation::FileEntryList& file_list, |
| 213 bool has_more) { | 213 bool has_more) { |
| 214 // The current filesystem backend always returns false. | 214 // The current filesystem backend always returns false. |
| 215 DCHECK(!has_more); | 215 DCHECK(!has_more); |
| 216 | 216 |
| 217 context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); | 217 context.params.set_result(ppapi::FileErrorToPepperError(error)); |
| 218 | 218 |
| 219 std::vector<ppapi::FileRefCreateInfo> infos; | 219 std::vector<ppapi::FileRefCreateInfo> infos; |
| 220 std::vector<PP_FileType> file_types; | 220 std::vector<PP_FileType> file_types; |
| 221 if (error == base::PLATFORM_FILE_OK && fs_host_.get()) { | 221 if (error == base::File::FILE_OK && fs_host_.get()) { |
| 222 std::string dir_path = path_; | 222 std::string dir_path = path_; |
| 223 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/') | 223 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/') |
| 224 dir_path += '/'; | 224 dir_path += '/'; |
| 225 | 225 |
| 226 for (fileapi::FileSystemOperation::FileEntryList::const_iterator it = | 226 for (fileapi::FileSystemOperation::FileEntryList::const_iterator it = |
| 227 file_list.begin(); it != file_list.end(); ++it) { | 227 file_list.begin(); it != file_list.end(); ++it) { |
| 228 if (it->is_directory) | 228 if (it->is_directory) |
| 229 file_types.push_back(PP_FILETYPE_DIRECTORY); | 229 file_types.push_back(PP_FILETYPE_DIRECTORY); |
| 230 else | 230 else |
| 231 file_types.push_back(PP_FILETYPE_REGULAR); | 231 file_types.push_back(PP_FILETYPE_REGULAR); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 ChildProcessSecurityPolicyImpl* policy = | 292 ChildProcessSecurityPolicyImpl* policy = |
| 293 ChildProcessSecurityPolicyImpl::GetInstance(); | 293 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 294 if (!policy->CanReadFileSystemFile(render_process_id_, url) || | 294 if (!policy->CanReadFileSystemFile(render_process_id_, url) || |
| 295 !policy->CanWriteFileSystemFile(render_process_id_, url)) { | 295 !policy->CanWriteFileSystemFile(render_process_id_, url)) { |
| 296 return PP_ERROR_NOACCESS; | 296 return PP_ERROR_NOACCESS; |
| 297 } | 297 } |
| 298 return PP_OK; | 298 return PP_OK; |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace content | 301 } // namespace content |
| OLD | NEW |