| OLD | NEW |
| 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/sandbox_mount_point_provider.h" | 5 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_callback_factory.h" | 10 #include "base/memory/scoped_callback_factory.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
| 20 #include "webkit/fileapi/file_system_operation_context.h" | 20 #include "webkit/fileapi/file_system_operation_context.h" |
| 21 #include "webkit/fileapi/file_system_path_manager.h" | 21 #include "webkit/fileapi/file_system_options.h" |
| 22 #include "webkit/fileapi/file_system_types.h" | 22 #include "webkit/fileapi/file_system_types.h" |
| 23 #include "webkit/fileapi/file_system_usage_cache.h" | 23 #include "webkit/fileapi/file_system_usage_cache.h" |
| 24 #include "webkit/fileapi/file_system_util.h" | 24 #include "webkit/fileapi/file_system_util.h" |
| 25 #include "webkit/fileapi/obfuscated_file_util.h" | 25 #include "webkit/fileapi/obfuscated_file_util.h" |
| 26 #include "webkit/fileapi/quota_file_util.h" | 26 #include "webkit/fileapi/quota_file_util.h" |
| 27 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
| 28 #include "webkit/quota/quota_manager.h" | 28 #include "webkit/quota/quota_manager.h" |
| 29 | 29 |
| 30 using quota::QuotaManagerProxy; | 30 using quota::QuotaManagerProxy; |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 static const FilePath::CharType kOldFileSystemUniqueNamePrefix[] = | 34 const char kChromeScheme[] = "chrome"; |
| 35 const char kExtensionScheme[] = "chrome-extension"; |
| 36 |
| 37 const FilePath::CharType kOldFileSystemUniqueNamePrefix[] = |
| 35 FILE_PATH_LITERAL("chrome-"); | 38 FILE_PATH_LITERAL("chrome-"); |
| 36 static const int kOldFileSystemUniqueLength = 16; | 39 const size_t kOldFileSystemUniqueLength = 16; |
| 37 static const unsigned kOldFileSystemUniqueDirectoryNameLength = | 40 const size_t kOldFileSystemUniqueDirectoryNameLength = |
| 38 kOldFileSystemUniqueLength + arraysize(kOldFileSystemUniqueNamePrefix) - 1; | 41 kOldFileSystemUniqueLength + arraysize(kOldFileSystemUniqueNamePrefix) - 1; |
| 39 | 42 |
| 40 const char kOpenFileSystem[] = "FileSystem.OpenFileSystem"; | 43 const char kOpenFileSystem[] = "FileSystem.OpenFileSystem"; |
| 41 enum FileSystemError { | 44 enum FileSystemError { |
| 42 kOK = 0, | 45 kOK = 0, |
| 43 kIncognito, | 46 kIncognito, |
| 44 kInvalidScheme, | 47 kInvalidScheme, |
| 45 kCreateDirectoryError, | 48 kCreateDirectoryError, |
| 46 kFileSystemErrorMax, | 49 kFileSystemErrorMax, |
| 47 }; | 50 }; |
| 48 | 51 |
| 49 // Restricted names. | 52 // Restricted names. |
| 50 // http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#naming-restrictions | 53 // http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#naming-restrictions |
| 51 static const char* const kRestrictedNames[] = { | 54 const FilePath::CharType* const kRestrictedNames[] = { |
| 52 ".", "..", | 55 FILE_PATH_LITERAL("."), FILE_PATH_LITERAL(".."), |
| 53 }; | 56 }; |
| 54 | 57 |
| 55 // Restricted chars. | 58 // Restricted chars. |
| 56 static const FilePath::CharType kRestrictedChars[] = { | 59 const FilePath::CharType kRestrictedChars[] = { |
| 57 '/', '\\', | 60 FILE_PATH_LITERAL('/'), FILE_PATH_LITERAL('\\'), |
| 58 }; | 61 }; |
| 59 | 62 |
| 60 inline std::string FilePathStringToASCII( | |
| 61 const FilePath::StringType& path_string) { | |
| 62 #if defined(OS_WIN) | |
| 63 return WideToASCII(path_string); | |
| 64 #elif defined(OS_POSIX) | |
| 65 return path_string; | |
| 66 #endif | |
| 67 } | |
| 68 | |
| 69 FilePath::StringType OldCreateUniqueDirectoryName(const GURL& origin_url) { | 63 FilePath::StringType OldCreateUniqueDirectoryName(const GURL& origin_url) { |
| 70 // This can be anything but need to be unpredictable. | 64 // This can be anything but need to be unpredictable. |
| 71 static const FilePath::CharType letters[] = FILE_PATH_LITERAL( | 65 static const FilePath::CharType letters[] = FILE_PATH_LITERAL( |
| 72 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); | 66 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); |
| 73 FilePath::StringType unique(kOldFileSystemUniqueNamePrefix); | 67 FilePath::StringType unique(kOldFileSystemUniqueNamePrefix); |
| 74 for (int i = 0; i < kOldFileSystemUniqueLength; ++i) | 68 for (size_t i = 0; i < kOldFileSystemUniqueLength; ++i) |
| 75 unique += letters[base::RandInt(0, arraysize(letters) - 2)]; | 69 unique += letters[base::RandInt(0, arraysize(letters) - 2)]; |
| 76 return unique; | 70 return unique; |
| 77 } | 71 } |
| 78 | 72 |
| 79 base::PlatformFileError OldReadOriginDirectory(const FilePath& base_path, | 73 base::PlatformFileError OldReadOriginDirectory(const FilePath& base_path, |
| 80 FilePath* unique) { | 74 FilePath* unique) { |
| 81 file_util::FileEnumerator file_enum( | 75 file_util::FileEnumerator file_enum( |
| 82 base_path, false /* recursive */, | 76 base_path, false /* recursive */, |
| 83 file_util::FileEnumerator::DIRECTORIES, | 77 file_util::FileEnumerator::DIRECTORIES, |
| 84 FilePath::StringType(kOldFileSystemUniqueNamePrefix) + | 78 FilePath::StringType(kOldFileSystemUniqueNamePrefix) + |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 explicit OldSandboxOriginEnumerator(const FilePath& base_path) | 123 explicit OldSandboxOriginEnumerator(const FilePath& base_path) |
| 130 : enumerator_(base_path, false /* recursive */, | 124 : enumerator_(base_path, false /* recursive */, |
| 131 file_util::FileEnumerator::DIRECTORIES) {} | 125 file_util::FileEnumerator::DIRECTORIES) {} |
| 132 virtual ~OldSandboxOriginEnumerator() {} | 126 virtual ~OldSandboxOriginEnumerator() {} |
| 133 | 127 |
| 134 virtual GURL Next() OVERRIDE { | 128 virtual GURL Next() OVERRIDE { |
| 135 current_ = enumerator_.Next(); | 129 current_ = enumerator_.Next(); |
| 136 if (current_.empty()) | 130 if (current_.empty()) |
| 137 return GURL(); | 131 return GURL(); |
| 138 return fileapi::GetOriginURLFromIdentifier( | 132 return fileapi::GetOriginURLFromIdentifier( |
| 139 FilePathStringToASCII(current_.BaseName().value())); | 133 current_.BaseName().MaybeAsASCII()); |
| 140 } | 134 } |
| 141 | 135 |
| 142 virtual bool HasFileSystemType(fileapi::FileSystemType type) const OVERRIDE { | 136 virtual bool HasFileSystemType(fileapi::FileSystemType type) const OVERRIDE { |
| 143 if (current_.empty()) | 137 if (current_.empty()) |
| 144 return false; | 138 return false; |
| 145 std::string directory = | 139 std::string directory = GetFileSystemTypeString(type); |
| 146 fileapi::FileSystemPathManager::GetFileSystemTypeString(type); | |
| 147 DCHECK(!directory.empty()); | 140 DCHECK(!directory.empty()); |
| 148 return file_util::DirectoryExists(current_.AppendASCII(directory)); | 141 return file_util::DirectoryExists(current_.AppendASCII(directory)); |
| 149 } | 142 } |
| 150 | 143 |
| 151 private: | 144 private: |
| 152 file_util::FileEnumerator enumerator_; | 145 file_util::FileEnumerator enumerator_; |
| 153 FilePath current_; | 146 FilePath current_; |
| 154 }; | 147 }; |
| 155 | 148 |
| 156 FilePath OldGetBaseDirectoryForOrigin( | 149 FilePath OldGetBaseDirectoryForOrigin( |
| 157 const FilePath& old_base_path, | 150 const FilePath& old_base_path, |
| 158 const GURL& origin_url) { | 151 const GURL& origin_url) { |
| 159 std::string id = fileapi::GetOriginIdentifierFromURL(origin_url); | 152 std::string id = fileapi::GetOriginIdentifierFromURL(origin_url); |
| 160 if (!id.empty()) | 153 if (!id.empty()) |
| 161 return old_base_path.AppendASCII(id); | 154 return old_base_path.AppendASCII(id); |
| 162 return FilePath(); | 155 return FilePath(); |
| 163 } | 156 } |
| 164 | 157 |
| 165 FilePath OldGetBaseDirectoryForOriginAndType( | 158 FilePath OldGetBaseDirectoryForOriginAndType( |
| 166 const FilePath& old_base_path, | 159 const FilePath& old_base_path, |
| 167 const GURL& origin_url, fileapi::FileSystemType type) { | 160 const GURL& origin_url, fileapi::FileSystemType type) { |
| 168 std::string type_string = | 161 std::string type_string = GetFileSystemTypeString(type); |
| 169 fileapi::FileSystemPathManager::GetFileSystemTypeString(type); | |
| 170 if (type_string.empty()) { | 162 if (type_string.empty()) { |
| 171 NOTREACHED(); | 163 NOTREACHED(); |
| 172 return FilePath(); | 164 return FilePath(); |
| 173 } | 165 } |
| 174 FilePath base_path = OldGetBaseDirectoryForOrigin( | 166 FilePath base_path = OldGetBaseDirectoryForOrigin( |
| 175 old_base_path, origin_url); | 167 old_base_path, origin_url); |
| 176 if (base_path.empty()) { | 168 if (base_path.empty()) { |
| 177 NOTREACHED(); | 169 NOTREACHED(); |
| 178 return FilePath(); | 170 return FilePath(); |
| 179 } | 171 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 class SandboxMountPointProvider::GetFileSystemRootPathTask | 274 class SandboxMountPointProvider::GetFileSystemRootPathTask |
| 283 : public base::RefCountedThreadSafe< | 275 : public base::RefCountedThreadSafe< |
| 284 SandboxMountPointProvider::GetFileSystemRootPathTask> { | 276 SandboxMountPointProvider::GetFileSystemRootPathTask> { |
| 285 public: | 277 public: |
| 286 GetFileSystemRootPathTask( | 278 GetFileSystemRootPathTask( |
| 287 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 279 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
| 288 const GURL& origin_url, | 280 const GURL& origin_url, |
| 289 FileSystemType type, | 281 FileSystemType type, |
| 290 ObfuscatedFileUtil* file_util, | 282 ObfuscatedFileUtil* file_util, |
| 291 const FilePath& old_base_path, | 283 const FilePath& old_base_path, |
| 292 const FileSystemPathManager::GetRootPathCallback& callback) | 284 const FileSystemMountPointProvider::GetRootPathCallback& callback) |
| 293 : file_message_loop_(file_message_loop), | 285 : file_message_loop_(file_message_loop), |
| 294 origin_message_loop_proxy_( | 286 origin_message_loop_proxy_( |
| 295 base::MessageLoopProxy::current()), | 287 base::MessageLoopProxy::current()), |
| 296 origin_url_(origin_url), | 288 origin_url_(origin_url), |
| 297 type_(type), | 289 type_(type), |
| 298 file_util_(file_util), | 290 file_util_(file_util), |
| 299 old_base_path_(old_base_path), | 291 old_base_path_(old_base_path), |
| 300 callback_(callback) { | 292 callback_(callback) { |
| 301 } | 293 } |
| 302 | 294 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 331 kFileSystemErrorMax); | 323 kFileSystemErrorMax); |
| 332 } | 324 } |
| 333 origin_message_loop_proxy_->PostTask( | 325 origin_message_loop_proxy_->PostTask( |
| 334 FROM_HERE, | 326 FROM_HERE, |
| 335 base::Bind(&GetFileSystemRootPathTask::DispatchCallback, this, | 327 base::Bind(&GetFileSystemRootPathTask::DispatchCallback, this, |
| 336 root_path)); | 328 root_path)); |
| 337 } | 329 } |
| 338 | 330 |
| 339 void DispatchCallback(const FilePath& root_path) { | 331 void DispatchCallback(const FilePath& root_path) { |
| 340 std::string origin_identifier = GetOriginIdentifierFromURL(origin_url_); | 332 std::string origin_identifier = GetOriginIdentifierFromURL(origin_url_); |
| 341 std::string type_string = | 333 std::string type_string = GetFileSystemTypeString(type_); |
| 342 FileSystemPathManager::GetFileSystemTypeString(type_); | |
| 343 DCHECK(!type_string.empty()); | 334 DCHECK(!type_string.empty()); |
| 344 std::string name = origin_identifier + ":" + type_string; | 335 std::string name = origin_identifier + ":" + type_string; |
| 345 | 336 |
| 346 if (!root_path.empty()) | 337 if (!root_path.empty()) |
| 347 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystem, kOK, kFileSystemErrorMax); | 338 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystem, kOK, kFileSystemErrorMax); |
| 348 | 339 |
| 349 callback_.Run(!root_path.empty(), root_path, name); | 340 callback_.Run(!root_path.empty(), root_path, name); |
| 350 callback_.Reset(); | 341 callback_.Reset(); |
| 351 } | 342 } |
| 352 | 343 |
| 353 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | 344 scoped_refptr<base::MessageLoopProxy> file_message_loop_; |
| 354 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; | 345 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; |
| 355 GURL origin_url_; | 346 GURL origin_url_; |
| 356 FileSystemType type_; | 347 FileSystemType type_; |
| 357 scoped_refptr<ObfuscatedFileUtil> file_util_; | 348 scoped_refptr<ObfuscatedFileUtil> file_util_; |
| 358 FilePath old_base_path_; | 349 FilePath old_base_path_; |
| 359 FileSystemPathManager::GetRootPathCallback callback_; | 350 FileSystemMountPointProvider::GetRootPathCallback callback_; |
| 360 }; | 351 }; |
| 361 | 352 |
| 362 SandboxMountPointProvider::SandboxMountPointProvider( | 353 SandboxMountPointProvider::SandboxMountPointProvider( |
| 363 FileSystemPathManager* path_manager, | |
| 364 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 354 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
| 365 const FilePath& profile_path) | 355 const FilePath& profile_path, |
| 356 const FileSystemOptions& file_system_options) |
| 366 : FileSystemQuotaUtil(file_message_loop), | 357 : FileSystemQuotaUtil(file_message_loop), |
| 367 path_manager_(path_manager), | |
| 368 file_message_loop_(file_message_loop), | 358 file_message_loop_(file_message_loop), |
| 369 profile_path_(profile_path), | 359 profile_path_(profile_path), |
| 360 file_system_options_(file_system_options), |
| 370 sandbox_file_util_( | 361 sandbox_file_util_( |
| 371 new ObfuscatedFileUtil( | 362 new ObfuscatedFileUtil( |
| 372 profile_path.Append(kNewFileSystemDirectory), | 363 profile_path.Append(kNewFileSystemDirectory), |
| 373 QuotaFileUtil::CreateDefault())) { | 364 QuotaFileUtil::CreateDefault())) { |
| 374 } | 365 } |
| 375 | 366 |
| 376 SandboxMountPointProvider::~SandboxMountPointProvider() { | 367 SandboxMountPointProvider::~SandboxMountPointProvider() { |
| 377 if (!file_message_loop_->BelongsToCurrentThread()) | 368 if (!file_message_loop_->BelongsToCurrentThread()) |
| 378 file_message_loop_->ReleaseSoon(FROM_HERE, sandbox_file_util_.release()); | 369 file_message_loop_->ReleaseSoon(FROM_HERE, sandbox_file_util_.release()); |
| 379 } | 370 } |
| 380 | 371 |
| 381 bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url, | 372 bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url, |
| 382 FileSystemType type, | 373 FileSystemType type, |
| 383 const FilePath& unused) { | 374 const FilePath& unused) { |
| 384 if (type != kFileSystemTypeTemporary && type != kFileSystemTypePersistent) | 375 if (type != kFileSystemTypeTemporary && type != kFileSystemTypePersistent) |
| 385 return false; | 376 return false; |
| 386 // We essentially depend on quota to do our access controls. | 377 // We essentially depend on quota to do our access controls, so here |
| 387 return path_manager_->IsAllowedScheme(origin_url); | 378 // we only check if the requested scheme is allowed or not. |
| 379 return IsAllowedScheme(origin_url); |
| 388 } | 380 } |
| 389 | 381 |
| 390 void SandboxMountPointProvider::ValidateFileSystemRootAndGetURL( | 382 void SandboxMountPointProvider::ValidateFileSystemRootAndGetURL( |
| 391 const GURL& origin_url, fileapi::FileSystemType type, bool create, | 383 const GURL& origin_url, fileapi::FileSystemType type, bool create, |
| 392 const FileSystemPathManager::GetRootPathCallback& callback) { | 384 const FileSystemMountPointProvider::GetRootPathCallback& callback) { |
| 393 FilePath origin_base_path; | 385 FilePath origin_base_path; |
| 394 | 386 |
| 395 if (path_manager_->is_incognito()) { | 387 if (file_system_options_.is_incognito()) { |
| 396 // TODO(kinuko): return an isolated temporary directory. | 388 // TODO(kinuko): return an isolated temporary directory. |
| 397 callback.Run(false, FilePath(), std::string()); | 389 callback.Run(false, FilePath(), std::string()); |
| 398 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystem, | 390 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystem, |
| 399 kIncognito, | 391 kIncognito, |
| 400 kFileSystemErrorMax); | 392 kFileSystemErrorMax); |
| 401 return; | 393 return; |
| 402 } | 394 } |
| 403 | 395 |
| 404 if (!path_manager_->IsAllowedScheme(origin_url)) { | 396 if (!IsAllowedScheme(origin_url)) { |
| 405 callback.Run(false, FilePath(), std::string()); | 397 callback.Run(false, FilePath(), std::string()); |
| 406 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystem, | 398 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystem, |
| 407 kInvalidScheme, | 399 kInvalidScheme, |
| 408 kFileSystemErrorMax); | 400 kFileSystemErrorMax); |
| 409 return; | 401 return; |
| 410 } | 402 } |
| 411 | 403 |
| 412 scoped_refptr<GetFileSystemRootPathTask> task( | 404 scoped_refptr<GetFileSystemRootPathTask> task( |
| 413 new GetFileSystemRootPathTask( | 405 new GetFileSystemRootPathTask( |
| 414 file_message_loop_, origin_url, type, sandbox_file_util_.get(), | 406 file_message_loop_, origin_url, type, sandbox_file_util_.get(), |
| 415 old_base_path(), callback)); | 407 old_base_path(), callback)); |
| 416 task->Start(create); | 408 task->Start(create); |
| 417 }; | 409 }; |
| 418 | 410 |
| 419 FilePath | 411 FilePath |
| 420 SandboxMountPointProvider::ValidateFileSystemRootAndGetPathOnFileThread( | 412 SandboxMountPointProvider::ValidateFileSystemRootAndGetPathOnFileThread( |
| 421 const GURL& origin_url, FileSystemType type, const FilePath& unused, | 413 const GURL& origin_url, FileSystemType type, const FilePath& unused, |
| 422 bool create) { | 414 bool create) { |
| 423 if (path_manager_->is_incognito()) | 415 if (file_system_options_.is_incognito()) |
| 424 // TODO(kinuko): return an isolated temporary directory. | 416 // TODO(kinuko): return an isolated temporary directory. |
| 425 return FilePath(); | 417 return FilePath(); |
| 426 | 418 |
| 427 if (!path_manager_->IsAllowedScheme(origin_url)) | 419 if (!IsAllowedScheme(origin_url)) |
| 428 return FilePath(); | 420 return FilePath(); |
| 429 | 421 |
| 430 MigrateIfNeeded(sandbox_file_util_, old_base_path()); | 422 MigrateIfNeeded(sandbox_file_util_, old_base_path()); |
| 431 | 423 |
| 432 return sandbox_file_util_->GetDirectoryForOriginAndType( | 424 return sandbox_file_util_->GetDirectoryForOriginAndType( |
| 433 origin_url, type, create); | 425 origin_url, type, create); |
| 434 } | 426 } |
| 435 | 427 |
| 436 bool SandboxMountPointProvider::IsRestrictedFileName(const FilePath& filename) | 428 bool SandboxMountPointProvider::IsRestrictedFileName(const FilePath& filename) |
| 437 const { | 429 const { |
| 438 if (filename.value().empty()) | 430 if (filename.value().empty()) |
| 439 return false; | 431 return false; |
| 440 | 432 |
| 441 std::string filename_lower = StringToLowerASCII( | |
| 442 FilePathStringToASCII(filename.value())); | |
| 443 | |
| 444 for (size_t i = 0; i < arraysize(kRestrictedNames); ++i) { | 433 for (size_t i = 0; i < arraysize(kRestrictedNames); ++i) { |
| 445 // Exact match. | 434 // Exact match. |
| 446 if (filename_lower == kRestrictedNames[i]) | 435 if (filename.value() == kRestrictedNames[i]) |
| 447 return true; | 436 return true; |
| 448 } | 437 } |
| 449 | 438 |
| 450 for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) { | 439 for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) { |
| 451 if (filename.value().find(kRestrictedChars[i]) != | 440 if (filename.value().find(kRestrictedChars[i]) != |
| 452 FilePath::StringType::npos) | 441 FilePath::StringType::npos) |
| 453 return true; | 442 return true; |
| 454 } | 443 } |
| 455 | 444 |
| 456 return false; | 445 return false; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 return FilePath(); | 660 return FilePath(); |
| 672 | 661 |
| 673 // Creates the root directory. | 662 // Creates the root directory. |
| 674 root = origin_base_path.Append(OldCreateUniqueDirectoryName(origin_url)); | 663 root = origin_base_path.Append(OldCreateUniqueDirectoryName(origin_url)); |
| 675 if (!file_util::CreateDirectory(root)) | 664 if (!file_util::CreateDirectory(root)) |
| 676 return FilePath(); | 665 return FilePath(); |
| 677 | 666 |
| 678 return root; | 667 return root; |
| 679 } | 668 } |
| 680 | 669 |
| 670 bool SandboxMountPointProvider::IsAllowedScheme(const GURL& url) const { |
| 671 // Basically we only accept http or https. We allow file:// URLs |
| 672 // only if --allow-file-access-from-files flag is given. |
| 673 if (url.SchemeIs("http") || url.SchemeIs("https")) |
| 674 return true; |
| 675 for (size_t i = 0; |
| 676 i < file_system_options_.additional_allowed_schemes().size(); |
| 677 ++i) { |
| 678 if (url.SchemeIs( |
| 679 file_system_options_.additional_allowed_schemes()[i].c_str())) |
| 680 return true; |
| 681 } |
| 682 return false; |
| 683 } |
| 684 |
| 681 } // namespace fileapi | 685 } // namespace fileapi |
| OLD | NEW |