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/file_system_path_manager.h" | 5 #include "webkit/fileapi/file_system_path_manager.h" |
6 | 6 |
7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { | 283 bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { |
284 // Basically we only accept http or https. We allow file:// URLs | 284 // Basically we only accept http or https. We allow file:// URLs |
285 // only if --allow-file-access-from-files flag is given. | 285 // only if --allow-file-access-from-files flag is given. |
286 return url.SchemeIs("http") || url.SchemeIs("https") || | 286 return url.SchemeIs("http") || url.SchemeIs("https") || |
287 url.SchemeIs(kExtensionScheme) || | 287 url.SchemeIs(kExtensionScheme) || |
288 (url.SchemeIsFile() && allow_file_access_from_files_); | 288 (url.SchemeIsFile() && allow_file_access_from_files_); |
289 } | 289 } |
290 | 290 |
291 // static | 291 // static |
292 bool FileSystemPathManager::IsRestrictedFileName(const FilePath& filename) { | 292 bool FileSystemPathManager::IsRestrictedFileName(const FilePath& filename) { |
293 if (filename.value().size() == 0) | 293 if (filename.value().empty()) |
294 return false; | 294 return false; |
295 | 295 |
296 if (IsWhitespace(filename.value()[filename.value().size() - 1]) || | 296 if (IsWhitespace(filename.value()[filename.value().size() - 1]) || |
297 filename.value()[filename.value().size() - 1] == '.') | 297 filename.value()[filename.value().size() - 1] == '.') |
298 return true; | 298 return true; |
299 | 299 |
300 std::string filename_lower = StringToLowerASCII( | 300 std::string filename_lower = StringToLowerASCII( |
301 FilePathStringToASCII(filename.value())); | 301 FilePathStringToASCII(filename.value())); |
302 | 302 |
303 for (size_t i = 0; i < arraysize(kRestrictedNames); ++i) { | 303 for (size_t i = 0; i < arraysize(kRestrictedNames); ++i) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 return !current_.empty() && file_util::DirectoryExists(current_.AppendASCII( | 371 return !current_.empty() && file_util::DirectoryExists(current_.AppendASCII( |
372 FileSystemPathManager::kPersistentName)); | 372 FileSystemPathManager::kPersistentName)); |
373 } | 373 } |
374 | 374 |
375 } // namespace fileapi | 375 } // namespace fileapi |
376 | 376 |
377 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ | 377 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ |
378 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); | 378 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); |
379 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ | 379 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ |
380 int(fileapi::kFileSystemTypePersistent), mismatching_enums); | 380 int(fileapi::kFileSystemTypePersistent), mismatching_enums); |
OLD | NEW |