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

Side by Side Diff: webkit/fileapi/file_system_path_manager.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) 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/file_system_path_manager.h" 5 #include "webkit/fileapi/file_system_path_manager.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 std::string name = storage_identifier + ":" + type_string; 219 std::string name = storage_identifier + ":" + type_string;
220 220
221 scoped_refptr<GetFileSystemRootPathTask> task( 221 scoped_refptr<GetFileSystemRootPathTask> task(
222 new GetFileSystemRootPathTask(file_message_loop_, 222 new GetFileSystemRootPathTask(file_message_loop_,
223 name, callback.release())); 223 name, callback.release()));
224 task->Start(origin_url, origin_base_path, create); 224 task->Start(origin_url, origin_base_path, create);
225 } 225 }
226 226
227 bool FileSystemPathManager::CrackFileSystemPath( 227 bool FileSystemPathManager::CrackFileSystemPath(
228 const FilePath& path, GURL* origin_url, FileSystemType* type, 228 const FilePath& path, GURL* origin_url, FileSystemType* type,
229 FilePath* virtual_path) const { 229 FilePath* root, FilePath* virtual_path) const {
230 // Any paths that includes parent references are considered invalid. 230 // Any paths that includes parent references are considered invalid.
231 if (path.ReferencesParent()) 231 if (path.ReferencesParent())
232 return false; 232 return false;
233 233
234 // The path should be a child of the profile FileSystem path. 234 // The path should be a child of the profile FileSystem path.
235 FilePath relative; 235 FilePath relative;
236 if (!base_path_.AppendRelativePath(path, &relative)) 236 if (!base_path_.AppendRelativePath(path, &relative))
237 return false; 237 return false;
238 238
239 // The relative path from the profile FileSystem path should contain 239 // The relative path from the profile FileSystem path should contain
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // We need this work-around for file:/// URIs as 272 // We need this work-around for file:/// URIs as
273 // createFromDatabaseIdentifier returns empty origin_url for them. 273 // createFromDatabaseIdentifier returns empty origin_url for them.
274 if (allow_file_access_from_files_ && origin_url->spec().empty() && 274 if (allow_file_access_from_files_ && origin_url->spec().empty() &&
275 components[0].find(FILE_PATH_LITERAL("file")) == 0) 275 components[0].find(FILE_PATH_LITERAL("file")) == 0)
276 *origin_url = GURL("file:///"); 276 *origin_url = GURL("file:///");
277 } 277 }
278 278
279 if (type) 279 if (type)
280 *type = cracked_type; 280 *type = cracked_type;
281 281
282 if (root) {
283 FilePath temp = base_path_;
284 temp = temp.Append(components[0]);
285 temp = temp.Append(components[1]);
286 *root = temp.Append(components[2]);
287 }
288
282 if (virtual_path) { 289 if (virtual_path) {
283 virtual_path->clear(); 290 virtual_path->clear();
284 for (size_t i = 3; i < components.size(); ++i) 291 for (size_t i = 3; i < components.size(); ++i)
285 *virtual_path = virtual_path->Append(components[i]); 292 *virtual_path = virtual_path->Append(components[i]);
286 } 293 }
287 294
288 return true; 295 return true;
289 } 296 }
290 297
291 bool FileSystemPathManager::IsRestrictedFileName( 298 bool FileSystemPathManager::IsRestrictedFileName(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec())); 339 WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec()));
333 return web_security_origin.databaseIdentifier().utf8(); 340 return web_security_origin.databaseIdentifier().utf8();
334 } 341 }
335 342
336 } // namespace fileapi 343 } // namespace fileapi
337 344
338 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ 345 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \
339 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); 346 int(fileapi::kFileSystemTypeTemporary), mismatching_enums);
340 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ 347 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \
341 int(fileapi::kFileSystemTypePersistent), mismatching_enums); 348 int(fileapi::kFileSystemTypePersistent), mismatching_enums);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698