Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: content/renderer/pepper/pepper_file_io_host.cc

Issue 19723010: Pepper Message Filters: Port to use explicit permission grants in ChildProcessSecurityPolicy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0044-write-support-remove-child-process-security-policy-bitmask-usage
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/pepper/pepper_file_io_host.h" 5 #include "content/renderer/pepper/pepper_file_io_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 int32_t PepperFileIOHost::OnHostMsgOpen( 154 int32_t PepperFileIOHost::OnHostMsgOpen(
155 ppapi::host::HostMessageContext* context, 155 ppapi::host::HostMessageContext* context,
156 PP_Resource file_ref_resource, 156 PP_Resource file_ref_resource,
157 int32_t open_flags) { 157 int32_t open_flags) {
158 int32_t rv = state_manager_.CheckOperationState( 158 int32_t rv = state_manager_.CheckOperationState(
159 FileIOStateManager::OPERATION_EXCLUSIVE, false); 159 FileIOStateManager::OPERATION_EXCLUSIVE, false);
160 if (rv != PP_OK) 160 if (rv != PP_OK)
161 return rv; 161 return rv;
162 162
163 int flags = 0;
164 open_flags_ = open_flags; 163 open_flags_ = open_flags;
165 if (!::ppapi::PepperFileOpenFlagsToPlatformFileFlags(open_flags, &flags)) 164 if (!::ppapi::PepperFileOpenFlagsToPlatformFileFlags(open_flags, NULL))
166 return PP_ERROR_BADARGUMENT; 165 return PP_ERROR_BADARGUMENT;
167 166
168 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref_resource, true); 167 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref_resource, true);
169 if (enter.failed()) 168 if (enter.failed())
170 return PP_ERROR_BADRESOURCE; 169 return PP_ERROR_BADRESOURCE;
171 170
172 PPB_FileRef_API* file_ref_api = enter.object(); 171 PPB_FileRef_API* file_ref_api = enter.object();
173 PP_FileSystemType type = file_ref_api->GetFileSystemType(); 172 PP_FileSystemType type = file_ref_api->GetFileSystemType();
174 if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && 173 if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
175 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY && 174 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
176 type != PP_FILESYSTEMTYPE_EXTERNAL && 175 type != PP_FILESYSTEMTYPE_EXTERNAL &&
177 type != PP_FILESYSTEMTYPE_ISOLATED) 176 type != PP_FILESYSTEMTYPE_ISOLATED)
178 return PP_ERROR_FAILED; 177 return PP_ERROR_FAILED;
179 file_system_type_ = type; 178 file_system_type_ = type;
180 179
181 if (!plugin_delegate_) 180 if (!plugin_delegate_)
182 return PP_ERROR_FAILED; 181 return PP_ERROR_FAILED;
183 182
184 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(file_ref_api); 183 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(file_ref_api);
185 if (file_ref->HasValidFileSystem()) { 184 if (file_ref->HasValidFileSystem()) {
186 file_system_url_ = file_ref->GetFileSystemURL(); 185 file_system_url_ = file_ref->GetFileSystemURL();
187 plugin_delegate_->AsyncOpenFileSystemURL( 186 plugin_delegate_->AsyncOpenFileSystemURL(
188 file_system_url_, flags, 187 file_system_url_, open_flags,
189 base::Bind( 188 base::Bind(
190 &PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback, 189 &PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback,
191 weak_factory_.GetWeakPtr(), 190 weak_factory_.GetWeakPtr(),
192 context->MakeReplyMessageContext())); 191 context->MakeReplyMessageContext()));
193 } else { 192 } else {
194 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) 193 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
195 return PP_ERROR_FAILED; 194 return PP_ERROR_FAILED;
196 if (!plugin_delegate_->AsyncOpenFile( 195 if (!plugin_delegate_->AsyncOpenFile(
197 file_ref->GetSystemPath(), flags, 196 file_ref->GetSystemPath(), open_flags,
198 base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback, 197 base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback,
199 weak_factory_.GetWeakPtr(), 198 weak_factory_.GetWeakPtr(),
200 context->MakeReplyMessageContext()))) 199 context->MakeReplyMessageContext())))
201 return PP_ERROR_FAILED; 200 return PP_ERROR_FAILED;
202 } 201 }
203 202
204 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); 203 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
205 return PP_OK_COMPLETIONPENDING; 204 return PP_OK_COMPLETIONPENDING;
206 } 205 }
207 206
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // On the plugin side, the callback expects a parameter with different meaning 581 // On the plugin side, the callback expects a parameter with different meaning
583 // depends on whether is negative or not. It is the result here. We translate 582 // depends on whether is negative or not. It is the result here. We translate
584 // for the callback. 583 // for the callback.
585 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); 584 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code);
586 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); 585 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written));
587 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); 586 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply());
588 state_manager_.SetOperationFinished(); 587 state_manager_.SetOperationFinished();
589 } 588 }
590 589
591 } // namespace content 590 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698