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

Side by Side Diff: webkit/fileapi/sandboxed_file_system_operation.cc

Issue 6286038: Add initial code to do filename munging in the FileSystem.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/fileapi/sandboxed_file_system_operation.h" 5 #include "webkit/fileapi/sandboxed_file_system_operation.h"
6 6
7 #include "net/url_request/url_request_context.h" 7 #include "net/url_request/url_request_context.h"
8 #include "webkit/fileapi/file_system_callback_dispatcher.h" 8 #include "webkit/fileapi/file_system_callback_dispatcher.h"
9 #include "webkit/fileapi/file_system_path_manager.h" 9 #include "webkit/fileapi/file_system_path_manager.h"
10 #include "webkit/fileapi/file_system_quota_manager.h" 10 #include "webkit/fileapi/file_system_quota_manager.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const FilePath& path, 143 const FilePath& path,
144 const base::Time& last_access_time, 144 const base::Time& last_access_time,
145 const base::Time& last_modified_time) { 145 const base::Time& last_modified_time) {
146 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) { 146 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) {
147 delete this; 147 delete this;
148 return; 148 return;
149 } 149 }
150 FileSystemOperation::TouchFile(path, last_access_time, last_modified_time); 150 FileSystemOperation::TouchFile(path, last_access_time, last_modified_time);
151 } 151 }
152 152
153 base::FileUtilProxyBase* SandboxedFileSystemOperation::file_util_proxy() const {
154 return file_system_context_->file_util_proxy();
155 }
156
153 void SandboxedFileSystemOperation::DidGetRootPath( 157 void SandboxedFileSystemOperation::DidGetRootPath(
154 bool success, const FilePath& path, const std::string& name) { 158 bool success, const FilePath& path, const std::string& name) {
155 DCHECK(success || path.empty()); 159 DCHECK(success || path.empty());
156 dispatcher()->DidOpenFileSystem(name, path); 160 dispatcher()->DidOpenFileSystem(name, path);
157 delete this; 161 delete this;
158 } 162 }
159 163
160 bool SandboxedFileSystemOperation::VerifyFileSystemPathForRead( 164 bool SandboxedFileSystemOperation::VerifyFileSystemPathForRead(
161 const FilePath& path) { 165 const FilePath& path) {
162 // We may want do more checks, but for now it just checks if the given 166 // We may want do more checks, but for now it just checks if the given
163 // |path| is under the valid FileSystem root path for this host context. 167 // |path| is under the valid FileSystem root path for this host context.
164 if (!file_system_context_->path_manager()->CrackFileSystemPath( 168 if (!file_system_context_->path_manager()->CrackFileSystemPath(
165 path, NULL, NULL, NULL)) { 169 path, NULL, NULL, NULL, NULL)) {
166 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 170 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
167 return false; 171 return false;
168 } 172 }
169 return true; 173 return true;
170 } 174 }
171 175
172 bool SandboxedFileSystemOperation::VerifyFileSystemPathForWrite( 176 bool SandboxedFileSystemOperation::VerifyFileSystemPathForWrite(
173 const FilePath& path, bool create, int64 growth) { 177 const FilePath& path, bool create, int64 growth) {
174 GURL origin_url; 178 GURL origin_url;
175 FilePath virtual_path; 179 FilePath virtual_path;
176 if (!file_system_context_->path_manager()->CrackFileSystemPath( 180 if (!file_system_context_->path_manager()->CrackFileSystemPath(
177 path, &origin_url, NULL, &virtual_path)) { 181 path, &origin_url, NULL, NULL, &virtual_path)) {
178 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 182 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
179 return false; 183 return false;
180 } 184 }
181 // Any write access is disallowed on the root path. 185 // Any write access is disallowed on the root path.
182 if (virtual_path.value().length() == 0 || 186 if (virtual_path.value().length() == 0 ||
183 virtual_path.DirName().value() == virtual_path.value()) { 187 virtual_path.DirName().value() == virtual_path.value()) {
184 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 188 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
185 return false; 189 return false;
186 } 190 }
187 if (create && file_system_context_->path_manager()->IsRestrictedFileName( 191 if (create && file_system_context_->path_manager()->IsRestrictedFileName(
188 path.BaseName())) { 192 path.BaseName())) {
189 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 193 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
190 return false; 194 return false;
191 } 195 }
192 // TODO(kinuko): For operations with kUnknownSize we'll eventually 196 // TODO(kinuko): For operations with kUnknownSize we'll eventually
193 // need to resolve what amount of size it's going to write. 197 // need to resolve what amount of size it's going to write.
194 if (!file_system_context_->quota_manager()->CheckOriginQuota( 198 if (!file_system_context_->quota_manager()->CheckOriginQuota(
195 origin_url, growth)) { 199 origin_url, growth)) {
196 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE); 200 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE);
197 return false; 201 return false;
198 } 202 }
199 return true; 203 return true;
200 } 204 }
201 205
202 } // namespace fileapi 206 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698