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

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, 5 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 int32_t PepperFileIOHost::OnHostMsgOpen( 109 int32_t PepperFileIOHost::OnHostMsgOpen(
110 ppapi::host::HostMessageContext* context, 110 ppapi::host::HostMessageContext* context,
111 PP_Resource file_ref_resource, 111 PP_Resource file_ref_resource,
112 int32_t open_flags) { 112 int32_t open_flags) {
113 int32_t rv = state_manager_.CheckOperationState( 113 int32_t rv = state_manager_.CheckOperationState(
114 FileIOStateManager::OPERATION_EXCLUSIVE, false); 114 FileIOStateManager::OPERATION_EXCLUSIVE, false);
115 if (rv != PP_OK) 115 if (rv != PP_OK)
116 return rv; 116 return rv;
117 117
118 int flags = 0;
119 open_flags_ = open_flags; 118 open_flags_ = open_flags;
120 if (!::ppapi::PepperFileOpenFlagsToPlatformFileFlags(open_flags, &flags))
121 return PP_ERROR_BADARGUMENT;
122 119
123 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref_resource, true); 120 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref_resource, true);
124 if (enter.failed()) 121 if (enter.failed())
125 return PP_ERROR_BADRESOURCE; 122 return PP_ERROR_BADRESOURCE;
126 123
127 PPB_FileRef_API* file_ref_api = enter.object(); 124 PPB_FileRef_API* file_ref_api = enter.object();
128 PP_FileSystemType type = file_ref_api->GetFileSystemType(); 125 PP_FileSystemType type = file_ref_api->GetFileSystemType();
129 if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && 126 if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
130 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY && 127 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
131 type != PP_FILESYSTEMTYPE_EXTERNAL && 128 type != PP_FILESYSTEMTYPE_EXTERNAL &&
132 type != PP_FILESYSTEMTYPE_ISOLATED) 129 type != PP_FILESYSTEMTYPE_ISOLATED)
133 return PP_ERROR_FAILED; 130 return PP_ERROR_FAILED;
134 file_system_type_ = type; 131 file_system_type_ = type;
135 132
136 if (!plugin_delegate_) 133 if (!plugin_delegate_)
137 return PP_ERROR_FAILED; 134 return PP_ERROR_FAILED;
138 135
139 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(file_ref_api); 136 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(file_ref_api);
140 if (file_ref->HasValidFileSystem()) { 137 if (file_ref->HasValidFileSystem()) {
141 file_system_url_ = file_ref->GetFileSystemURL(); 138 file_system_url_ = file_ref->GetFileSystemURL();
142 plugin_delegate_->AsyncOpenFileSystemURL( 139 plugin_delegate_->AsyncOpenFileSystemURL(
143 file_system_url_, flags, 140 file_system_url_, open_flags,
144 base::Bind( 141 base::Bind(
145 &PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback, 142 &PepperFileIOHost::ExecutePlatformOpenFileSystemURLCallback,
146 weak_factory_.GetWeakPtr(), 143 weak_factory_.GetWeakPtr(),
147 context->MakeReplyMessageContext())); 144 context->MakeReplyMessageContext()));
148 } else { 145 } else {
149 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) 146 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
150 return PP_ERROR_FAILED; 147 return PP_ERROR_FAILED;
151 if (!plugin_delegate_->AsyncOpenFile( 148 if (!plugin_delegate_->AsyncOpenFile(
152 file_ref->GetSystemPath(), flags, 149 file_ref->GetSystemPath(), open_flags,
153 base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback, 150 base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback,
154 weak_factory_.GetWeakPtr(), 151 weak_factory_.GetWeakPtr(),
155 context->MakeReplyMessageContext()))) 152 context->MakeReplyMessageContext())))
156 return PP_ERROR_FAILED; 153 return PP_ERROR_FAILED;
157 } 154 }
158 155
159 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); 156 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
160 return PP_OK_COMPLETIONPENDING; 157 return PP_OK_COMPLETIONPENDING;
161 } 158 }
162 159
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // On the plugin side, the callback expects a parameter with different meaning 534 // On the plugin side, the callback expects a parameter with different meaning
538 // depends on whether is negative or not. It is the result here. We translate 535 // depends on whether is negative or not. It is the result here. We translate
539 // for the callback. 536 // for the callback.
540 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); 537 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code);
541 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); 538 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written));
542 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); 539 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply());
543 state_manager_.SetOperationFinished(); 540 state_manager_.SetOperationFinished();
544 } 541 }
545 542
546 } // namespace content 543 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698