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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 GURL fs_path = fs_host_->GetRootUrl().Resolve( | 64 GURL fs_path = fs_host_->GetRootUrl().Resolve( |
65 net::EscapePath(path_.substr(1))); | 65 net::EscapePath(path_.substr(1))); |
66 scoped_refptr<fileapi::FileSystemContext> fs_context = | 66 scoped_refptr<fileapi::FileSystemContext> fs_context = |
67 GetFileSystemContext(); | 67 GetFileSystemContext(); |
68 if (fs_context.get()) | 68 if (fs_context.get()) |
69 fs_url_ = fs_context->CrackURL(fs_path); | 69 fs_url_ = fs_context->CrackURL(fs_path); |
70 } | 70 } |
71 return fs_url_; | 71 return fs_url_; |
72 } | 72 } |
73 | 73 |
74 std::string PepperInternalFileRefBackend::GetFileSystemURLSpec() const { | |
75 if (fs_host_.get() && fs_host_->IsOpened() && | |
76 fs_host_->GetRootUrl().is_valid()) { | |
77 return fs_host_->GetRootUrl().Resolve( | |
78 net::EscapePath(path_.substr(1))).spec(); | |
79 } | |
80 return std::string(); | |
81 } | |
82 | |
83 base::FilePath PepperInternalFileRefBackend::GetExternalPath() const { | |
84 return base::FilePath(); | |
85 } | |
86 | |
87 scoped_refptr<fileapi::FileSystemContext> | 74 scoped_refptr<fileapi::FileSystemContext> |
88 PepperInternalFileRefBackend::GetFileSystemContext() const { | 75 PepperInternalFileRefBackend::GetFileSystemContext() const { |
89 if (!fs_host_.get()) | 76 if (!fs_host_.get()) |
90 return NULL; | 77 return NULL; |
91 return fs_host_->GetFileSystemContext(); | 78 return fs_host_->GetFileSystemContext(); |
92 } | 79 } |
93 | 80 |
94 void PepperInternalFileRefBackend::DidFinish( | 81 void PepperInternalFileRefBackend::DidFinish( |
95 ppapi::host::ReplyMessageContext context, | 82 ppapi::host::ReplyMessageContext context, |
96 const IPC::Message& msg, | 83 const IPC::Message& msg, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 void PepperInternalFileRefBackend::ReadDirectoryComplete( | 203 void PepperInternalFileRefBackend::ReadDirectoryComplete( |
217 ppapi::host::ReplyMessageContext context, | 204 ppapi::host::ReplyMessageContext context, |
218 base::PlatformFileError error, | 205 base::PlatformFileError error, |
219 const fileapi::FileSystemOperation::FileEntryList& file_list, | 206 const fileapi::FileSystemOperation::FileEntryList& file_list, |
220 bool has_more) { | 207 bool has_more) { |
221 // The current filesystem backend always returns false. | 208 // The current filesystem backend always returns false. |
222 DCHECK(!has_more); | 209 DCHECK(!has_more); |
223 | 210 |
224 context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); | 211 context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); |
225 | 212 |
226 std::vector<ppapi::FileRef_CreateInfo> infos; | 213 std::vector<ppapi::FileRefCreateInfo> infos; |
227 std::vector<PP_FileType> file_types; | 214 std::vector<PP_FileType> file_types; |
228 if (error == base::PLATFORM_FILE_OK && fs_host_.get()) { | 215 if (error == base::PLATFORM_FILE_OK && fs_host_.get()) { |
229 std::string dir_path = path_; | 216 std::string dir_path = path_; |
230 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/') | 217 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/') |
231 dir_path += '/'; | 218 dir_path += '/'; |
232 | 219 |
233 for (fileapi::FileSystemOperation::FileEntryList::const_iterator it = | 220 for (fileapi::FileSystemOperation::FileEntryList::const_iterator it = |
234 file_list.begin(); it != file_list.end(); ++it) { | 221 file_list.begin(); it != file_list.end(); ++it) { |
235 if (it->is_directory) | 222 if (it->is_directory) |
236 file_types.push_back(PP_FILETYPE_DIRECTORY); | 223 file_types.push_back(PP_FILETYPE_DIRECTORY); |
237 else | 224 else |
238 file_types.push_back(PP_FILETYPE_REGULAR); | 225 file_types.push_back(PP_FILETYPE_REGULAR); |
239 | 226 |
240 ppapi::FileRef_CreateInfo info; | 227 ppapi::FileRefCreateInfo info; |
241 info.file_system_type = fs_type_; | 228 info.file_system_type = fs_type_; |
242 info.file_system_plugin_resource = fs_host_->pp_resource(); | 229 info.file_system_plugin_resource = fs_host_->pp_resource(); |
243 std::string path = | 230 std::string path = |
244 dir_path + fileapi::FilePathToString(base::FilePath(it->name)); | 231 dir_path + fileapi::FilePathToString(base::FilePath(it->name)); |
245 info.internal_path = path; | 232 info.internal_path = path; |
246 info.display_name = ppapi::GetNameForInternalFilePath(path); | 233 info.display_name = ppapi::GetNameForInternalFilePath(path); |
247 infos.push_back(info); | 234 infos.push_back(info); |
248 } | 235 } |
249 } | 236 } |
250 | 237 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 ChildProcessSecurityPolicyImpl* policy = | 286 ChildProcessSecurityPolicyImpl* policy = |
300 ChildProcessSecurityPolicyImpl::GetInstance(); | 287 ChildProcessSecurityPolicyImpl::GetInstance(); |
301 if (!policy->CanReadFileSystemFile(render_process_id_, url) || | 288 if (!policy->CanReadFileSystemFile(render_process_id_, url) || |
302 !policy->CanWriteFileSystemFile(render_process_id_, url)) { | 289 !policy->CanWriteFileSystemFile(render_process_id_, url)) { |
303 return PP_ERROR_NOACCESS; | 290 return PP_ERROR_NOACCESS; |
304 } | 291 } |
305 return PP_OK; | 292 return PP_OK; |
306 } | 293 } |
307 | 294 |
308 } // namespace content | 295 } // namespace content |
OLD | NEW |