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 |
Tom Sepez
2013/07/19 18:39:28
nit: extra blank line.
tommycli
2013/07/23 21:12:35
Done.
| |
109 int permissions) const { | 109 int32_t PepperExternalFileRefBackend::CanRead() const { |
110 if (!ChildProcessSecurityPolicyImpl::GetInstance()->HasPermissionsForFile( | 110 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> |
111 render_process_id_, path_, permissions)) { | 111 CanReadFile(render_process_id_, path_)) { |
112 return PP_ERROR_NOACCESS; | 112 return PP_ERROR_NOACCESS; |
113 } | 113 } |
114 return PP_OK; | 114 return PP_OK; |
115 } | |
116 | |
117 int32_t PepperExternalFileRefBackend::CanWrite() const { | |
118 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> | |
119 CanWriteFile(render_process_id_, path_)) { | |
120 return PP_ERROR_NOACCESS; | |
121 } | |
122 return PP_OK; | |
123 } | |
124 | |
125 int32_t PepperExternalFileRefBackend::CanCreate() const { | |
126 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> | |
127 CanCreateFile(render_process_id_, path_)) { | |
128 return PP_ERROR_NOACCESS; | |
129 } | |
130 return PP_OK; | |
115 } | 131 } |
116 | 132 |
117 void PepperExternalFileRefBackend::DidFinish( | 133 void PepperExternalFileRefBackend::DidFinish( |
118 ppapi::host::ReplyMessageContext reply_context, | 134 ppapi::host::ReplyMessageContext reply_context, |
119 const IPC::Message& msg, | 135 const IPC::Message& msg, |
120 base::PlatformFileError error) { | 136 base::PlatformFileError error) { |
121 reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); | 137 reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); |
122 host_->SendReply(reply_context, msg); | 138 host_->SendReply(reply_context, msg); |
123 } | 139 } |
124 | 140 |
125 void PepperExternalFileRefBackend::GetMetadataComplete( | 141 void PepperExternalFileRefBackend::GetMetadataComplete( |
126 ppapi::host::ReplyMessageContext reply_context, | 142 ppapi::host::ReplyMessageContext reply_context, |
127 const base::PlatformFileError error, | 143 const base::PlatformFileError error, |
128 const base::PlatformFileInfo& file_info) { | 144 const base::PlatformFileInfo& file_info) { |
129 reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); | 145 reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); |
130 | 146 |
131 PP_FileInfo pp_file_info; | 147 PP_FileInfo pp_file_info; |
132 if (error == base::PLATFORM_FILE_OK) { | 148 if (error == base::PLATFORM_FILE_OK) { |
133 ppapi::PlatformFileInfoToPepperFileInfo( | 149 ppapi::PlatformFileInfoToPepperFileInfo( |
134 file_info, PP_FILESYSTEMTYPE_EXTERNAL, &pp_file_info); | 150 file_info, PP_FILESYSTEMTYPE_EXTERNAL, &pp_file_info); |
135 } else { | 151 } else { |
136 memset(&pp_file_info, 0, sizeof(pp_file_info)); | 152 memset(&pp_file_info, 0, sizeof(pp_file_info)); |
137 } | 153 } |
138 | 154 |
139 host_->SendReply(reply_context, | 155 host_->SendReply(reply_context, |
140 PpapiPluginMsg_FileRef_QueryReply(pp_file_info)); | 156 PpapiPluginMsg_FileRef_QueryReply(pp_file_info)); |
141 } | 157 } |
142 | 158 |
143 } // namespace content | 159 } // namespace content |
OLD | NEW |