OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 FileSystemOperation::Write(url_request_context, path, blob_url, offset); | 108 FileSystemOperation::Write(url_request_context, path, blob_url, offset); |
109 } | 109 } |
110 | 110 |
111 void SandboxedFileSystemOperation::Truncate( | 111 void SandboxedFileSystemOperation::Truncate( |
112 const FilePath& path, int64 length) { | 112 const FilePath& path, int64 length) { |
113 if (!VerifyFileSystemPathForWrite(path, false /* create */, 0)) | 113 if (!VerifyFileSystemPathForWrite(path, false /* create */, 0)) |
114 return; | 114 return; |
115 FileSystemOperation::Truncate(path, length); | 115 FileSystemOperation::Truncate(path, length); |
116 } | 116 } |
117 | 117 |
118 void SandboxedFileSystemOperation::TouchFile(const FilePath& path, | 118 void SandboxedFileSystemOperation::TouchFile( |
119 const base::Time& last_access_time, | 119 const FilePath& path, |
120 const base::Time& last_modified_time) { | 120 const base::Time& last_access_time, |
| 121 const base::Time& last_modified_time) { |
121 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) | 122 if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) |
122 return; | 123 return; |
123 FileSystemOperation::TouchFile(path, last_access_time, last_modified_time); | 124 FileSystemOperation::TouchFile(path, last_access_time, last_modified_time); |
124 } | 125 } |
125 | 126 |
126 void SandboxedFileSystemOperation::DidGetRootPath( | 127 void SandboxedFileSystemOperation::DidGetRootPath( |
127 bool success, const FilePath& path, const std::string& name) { | 128 bool success, const FilePath& path, const std::string& name) { |
128 DCHECK(success || path.empty()); | 129 DCHECK(success || path.empty()); |
129 dispatcher()->DidOpenFileSystem(name, path); | 130 dispatcher()->DidOpenFileSystem(name, path); |
130 } | 131 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // TODO(kinuko): For operations with kUnknownSize we'll eventually | 165 // TODO(kinuko): For operations with kUnknownSize we'll eventually |
165 // need to resolve what amount of size it's going to write. | 166 // need to resolve what amount of size it's going to write. |
166 if (!file_system_context_->quota_manager()->CheckOriginQuota( | 167 if (!file_system_context_->quota_manager()->CheckOriginQuota( |
167 origin_url, growth)) { | 168 origin_url, growth)) { |
168 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE); | 169 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_NO_SPACE); |
169 return false; | 170 return false; |
170 } | 171 } |
171 return true; | 172 return true; |
172 } | 173 } |
173 | 174 |
174 bool SandboxedFileSystemOperation::CheckIfFilePathIsSafe( | |
175 const FilePath& path) { | |
176 if (file_system_context_->path_manager()->IsRestrictedFileName( | |
177 path.BaseName())) { | |
178 dispatcher()->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | |
179 return false; | |
180 } | |
181 return true; | |
182 } | |
183 | |
184 } // namespace fileapi | 175 } // namespace fileapi |
OLD | NEW |