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

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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 scoped_refptr<GetFileSystemRootPathTask> task( 216 scoped_refptr<GetFileSystemRootPathTask> task(
217 new GetFileSystemRootPathTask(file_message_loop_, 217 new GetFileSystemRootPathTask(file_message_loop_,
218 GetFileSystemName(origin_url, type), 218 GetFileSystemName(origin_url, type),
219 callback.release())); 219 callback.release()));
220 task->Start(origin_url, origin_base_path, create); 220 task->Start(origin_url, origin_base_path, create);
221 } 221 }
222 222
223 bool FileSystemPathManager::CrackFileSystemPath( 223 bool FileSystemPathManager::CrackFileSystemPath(
224 const FilePath& path, GURL* origin_url, FileSystemType* type, 224 const FilePath& path, GURL* origin_url, FileSystemType* type,
225 FilePath* virtual_path) const { 225 FilePath* root, FilePath* virtual_path) const {
226 // Any paths that includes parent references are considered invalid. 226 // Any paths that includes parent references are considered invalid.
227 if (path.ReferencesParent()) 227 if (path.ReferencesParent())
228 return false; 228 return false;
229 229
230 // The path should be a child of the profile FileSystem path. 230 // The path should be a child of the profile FileSystem path.
231 FilePath relative; 231 FilePath relative;
232 if (!base_path_.AppendRelativePath(path, &relative)) 232 if (!base_path_.AppendRelativePath(path, &relative))
233 return false; 233 return false;
234 234
235 // The relative path from the profile FileSystem path should contain 235 // The relative path from the profile FileSystem path should contain
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // We need this work-around for file:/// URIs as 268 // We need this work-around for file:/// URIs as
269 // createFromDatabaseIdentifier returns empty origin_url for them. 269 // createFromDatabaseIdentifier returns empty origin_url for them.
270 if (allow_file_access_from_files_ && origin_url->spec().empty() && 270 if (allow_file_access_from_files_ && origin_url->spec().empty() &&
271 components[0].find(FILE_PATH_LITERAL("file")) == 0) 271 components[0].find(FILE_PATH_LITERAL("file")) == 0)
272 *origin_url = GURL("file:///"); 272 *origin_url = GURL("file:///");
273 } 273 }
274 274
275 if (type) 275 if (type)
276 *type = cracked_type; 276 *type = cracked_type;
277 277
278 if (root) {
279 FilePath temp = base_path_;
280 temp = temp.Append(components[0]);
281 temp = temp.Append(components[1]);
282 *root = temp.Append(components[2]);
283 }
284
278 if (virtual_path) { 285 if (virtual_path) {
279 virtual_path->clear(); 286 virtual_path->clear();
280 for (size_t i = 3; i < components.size(); ++i) 287 for (size_t i = 3; i < components.size(); ++i)
281 *virtual_path = virtual_path->Append(components[i]); 288 *virtual_path = virtual_path->Append(components[i]);
282 } 289 }
283 290
284 return true; 291 return true;
285 } 292 }
286 293
287 bool FileSystemPathManager::IsRestrictedFileName( 294 bool FileSystemPathManager::IsRestrictedFileName(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return base_path.AppendASCII(GetStorageIdentifierFromURL(origin_url)) 358 return base_path.AppendASCII(GetStorageIdentifierFromURL(origin_url))
352 .AppendASCII(type_string); 359 .AppendASCII(type_string);
353 } 360 }
354 361
355 } // namespace fileapi 362 } // namespace fileapi
356 363
357 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ 364 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \
358 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); 365 int(fileapi::kFileSystemTypeTemporary), mismatching_enums);
359 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ 366 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \
360 int(fileapi::kFileSystemTypePersistent), mismatching_enums); 367 int(fileapi::kFileSystemTypePersistent), mismatching_enums);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698