| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 kNotFound, | 56 kNotFound, |
| 57 kUnknownError, | 57 kUnknownError, |
| 58 kFileSystemErrorMax, | 58 kFileSystemErrorMax, |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 const char kTemporaryOriginsCountLabel[] = "FileSystem.TemporaryOriginsCount"; | 61 const char kTemporaryOriginsCountLabel[] = "FileSystem.TemporaryOriginsCount"; |
| 62 const char kPersistentOriginsCountLabel[] = "FileSystem.PersistentOriginsCount"; | 62 const char kPersistentOriginsCountLabel[] = "FileSystem.PersistentOriginsCount"; |
| 63 | 63 |
| 64 // Restricted names. | 64 // Restricted names. |
| 65 // http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#naming-restrictions | 65 // http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#naming-restrictions |
| 66 const FilePath::CharType* const kRestrictedNames[] = { | 66 const base::FilePath::CharType* const kRestrictedNames[] = { |
| 67 FILE_PATH_LITERAL("."), FILE_PATH_LITERAL(".."), | 67 FILE_PATH_LITERAL("."), FILE_PATH_LITERAL(".."), |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // Restricted chars. | 70 // Restricted chars. |
| 71 const FilePath::CharType kRestrictedChars[] = { | 71 const base::FilePath::CharType kRestrictedChars[] = { |
| 72 FILE_PATH_LITERAL('/'), FILE_PATH_LITERAL('\\'), | 72 FILE_PATH_LITERAL('/'), FILE_PATH_LITERAL('\\'), |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 class ObfuscatedOriginEnumerator | 75 class ObfuscatedOriginEnumerator |
| 76 : public SandboxMountPointProvider::OriginEnumerator { | 76 : public SandboxMountPointProvider::OriginEnumerator { |
| 77 public: | 77 public: |
| 78 explicit ObfuscatedOriginEnumerator(ObfuscatedFileUtil* file_util) { | 78 explicit ObfuscatedOriginEnumerator(ObfuscatedFileUtil* file_util) { |
| 79 enum_.reset(file_util->CreateOriginEnumerator()); | 79 enum_.reset(file_util->CreateOriginEnumerator()); |
| 80 } | 80 } |
| 81 virtual ~ObfuscatedOriginEnumerator() {} | 81 virtual ~ObfuscatedOriginEnumerator() {} |
| (...skipping 20 matching lines...) Expand all Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 void ValidateRootOnFileThread( | 104 void ValidateRootOnFileThread( |
| 105 ObfuscatedFileUtil* file_util, | 105 ObfuscatedFileUtil* file_util, |
| 106 const GURL& origin_url, | 106 const GURL& origin_url, |
| 107 FileSystemType type, | 107 FileSystemType type, |
| 108 bool create, | 108 bool create, |
| 109 base::PlatformFileError* error_ptr) { | 109 base::PlatformFileError* error_ptr) { |
| 110 DCHECK(error_ptr); | 110 DCHECK(error_ptr); |
| 111 | 111 |
| 112 FilePath root_path = | 112 base::FilePath root_path = |
| 113 file_util->GetDirectoryForOriginAndType( | 113 file_util->GetDirectoryForOriginAndType( |
| 114 origin_url, type, create, error_ptr); | 114 origin_url, type, create, error_ptr); |
| 115 if (*error_ptr != base::PLATFORM_FILE_OK) { | 115 if (*error_ptr != base::PLATFORM_FILE_OK) { |
| 116 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, | 116 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, |
| 117 kCreateDirectoryError, | 117 kCreateDirectoryError, |
| 118 kFileSystemErrorMax); | 118 kFileSystemErrorMax); |
| 119 } else { | 119 } else { |
| 120 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, kOK, kFileSystemErrorMax); | 120 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, kOK, kFileSystemErrorMax); |
| 121 } | 121 } |
| 122 // The reference of file_util will be derefed on the FILE thread | 122 // The reference of file_util will be derefed on the FILE thread |
| 123 // when the storage of this callback gets deleted regardless of whether | 123 // when the storage of this callback gets deleted regardless of whether |
| 124 // this method is called or not. | 124 // this method is called or not. |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // anonymous namespace | 127 } // anonymous namespace |
| 128 | 128 |
| 129 const FilePath::CharType SandboxMountPointProvider::kFileSystemDirectory[] = | 129 const base::FilePath::CharType SandboxMountPointProvider::kFileSystemDirectory[]
= |
| 130 FILE_PATH_LITERAL("File System"); | 130 FILE_PATH_LITERAL("File System"); |
| 131 | 131 |
| 132 // static | 132 // static |
| 133 bool SandboxMountPointProvider::CanHandleType(FileSystemType type) { | 133 bool SandboxMountPointProvider::CanHandleType(FileSystemType type) { |
| 134 return type == kFileSystemTypeTemporary || | 134 return type == kFileSystemTypeTemporary || |
| 135 type == kFileSystemTypePersistent || | 135 type == kFileSystemTypePersistent || |
| 136 type == kFileSystemTypeSyncable; | 136 type == kFileSystemTypeSyncable; |
| 137 } | 137 } |
| 138 | 138 |
| 139 SandboxMountPointProvider::SandboxMountPointProvider( | 139 SandboxMountPointProvider::SandboxMountPointProvider( |
| 140 quota::QuotaManagerProxy* quota_manager_proxy, | 140 quota::QuotaManagerProxy* quota_manager_proxy, |
| 141 base::SequencedTaskRunner* file_task_runner, | 141 base::SequencedTaskRunner* file_task_runner, |
| 142 const FilePath& profile_path, | 142 const base::FilePath& profile_path, |
| 143 const FileSystemOptions& file_system_options) | 143 const FileSystemOptions& file_system_options) |
| 144 : file_task_runner_(file_task_runner), | 144 : file_task_runner_(file_task_runner), |
| 145 profile_path_(profile_path), | 145 profile_path_(profile_path), |
| 146 file_system_options_(file_system_options), | 146 file_system_options_(file_system_options), |
| 147 sandbox_file_util_( | 147 sandbox_file_util_( |
| 148 new AsyncFileUtilAdapter( | 148 new AsyncFileUtilAdapter( |
| 149 new ObfuscatedFileUtil( | 149 new ObfuscatedFileUtil( |
| 150 profile_path.Append(kFileSystemDirectory)))), | 150 profile_path.Append(kFileSystemDirectory)))), |
| 151 quota_observer_(new SandboxQuotaObserver( | 151 quota_observer_(new SandboxQuotaObserver( |
| 152 quota_manager_proxy, | 152 quota_manager_proxy, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 FROM_HERE, | 204 FROM_HERE, |
| 205 base::Bind(&ValidateRootOnFileThread, | 205 base::Bind(&ValidateRootOnFileThread, |
| 206 sandbox_sync_file_util(), | 206 sandbox_sync_file_util(), |
| 207 origin_url, type, create, | 207 origin_url, type, create, |
| 208 base::Unretained(error_ptr)), | 208 base::Unretained(error_ptr)), |
| 209 base::Bind(&DidValidateFileSystemRoot, | 209 base::Bind(&DidValidateFileSystemRoot, |
| 210 weak_factory_.GetWeakPtr(), | 210 weak_factory_.GetWeakPtr(), |
| 211 callback, base::Owned(error_ptr))); | 211 callback, base::Owned(error_ptr))); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 FilePath | 214 base::FilePath |
| 215 SandboxMountPointProvider::GetFileSystemRootPathOnFileThread( | 215 SandboxMountPointProvider::GetFileSystemRootPathOnFileThread( |
| 216 const FileSystemURL& url, | 216 const FileSystemURL& url, |
| 217 bool create) { | 217 bool create) { |
| 218 if (file_system_options_.is_incognito()) | 218 if (file_system_options_.is_incognito()) |
| 219 // TODO(kinuko): return an isolated temporary directory. | 219 // TODO(kinuko): return an isolated temporary directory. |
| 220 return FilePath(); | 220 return base::FilePath(); |
| 221 | 221 |
| 222 if (!IsAllowedScheme(url.origin())) | 222 if (!IsAllowedScheme(url.origin())) |
| 223 return FilePath(); | 223 return base::FilePath(); |
| 224 | 224 |
| 225 return GetBaseDirectoryForOriginAndType(url.origin(), url.type(), create); | 225 return GetBaseDirectoryForOriginAndType(url.origin(), url.type(), create); |
| 226 } | 226 } |
| 227 | 227 |
| 228 bool SandboxMountPointProvider::IsAccessAllowed(const FileSystemURL& url) { | 228 bool SandboxMountPointProvider::IsAccessAllowed(const FileSystemURL& url) { |
| 229 if (!CanHandleType(url.type())) | 229 if (!CanHandleType(url.type())) |
| 230 return false; | 230 return false; |
| 231 // We essentially depend on quota to do our access controls, so here | 231 // We essentially depend on quota to do our access controls, so here |
| 232 // we only check if the requested scheme is allowed or not. | 232 // we only check if the requested scheme is allowed or not. |
| 233 return IsAllowedScheme(url.origin()); | 233 return IsAllowedScheme(url.origin()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool SandboxMountPointProvider::IsRestrictedFileName(const FilePath& filename) | 236 bool SandboxMountPointProvider::IsRestrictedFileName(const base::FilePath& filen
ame) |
| 237 const { | 237 const { |
| 238 if (filename.value().empty()) | 238 if (filename.value().empty()) |
| 239 return false; | 239 return false; |
| 240 | 240 |
| 241 for (size_t i = 0; i < arraysize(kRestrictedNames); ++i) { | 241 for (size_t i = 0; i < arraysize(kRestrictedNames); ++i) { |
| 242 // Exact match. | 242 // Exact match. |
| 243 if (filename.value() == kRestrictedNames[i]) | 243 if (filename.value() == kRestrictedNames[i]) |
| 244 return true; | 244 return true; |
| 245 } | 245 } |
| 246 | 246 |
| 247 for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) { | 247 for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) { |
| 248 if (filename.value().find(kRestrictedChars[i]) != | 248 if (filename.value().find(kRestrictedChars[i]) != |
| 249 FilePath::StringType::npos) | 249 base::FilePath::StringType::npos) |
| 250 return true; | 250 return true; |
| 251 } | 251 } |
| 252 | 252 |
| 253 return false; | 253 return false; |
| 254 } | 254 } |
| 255 | 255 |
| 256 FileSystemFileUtil* SandboxMountPointProvider::GetFileUtil( | 256 FileSystemFileUtil* SandboxMountPointProvider::GetFileUtil( |
| 257 FileSystemType type) { | 257 FileSystemType type) { |
| 258 DCHECK(sandbox_file_util_.get()); | 258 DCHECK(sandbox_file_util_.get()); |
| 259 return sandbox_file_util_->sync_file_util(); | 259 return sandbox_file_util_->sync_file_util(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 origin_url, | 334 origin_url, |
| 335 type), | 335 type), |
| 336 callback); | 336 callback); |
| 337 } | 337 } |
| 338 | 338 |
| 339 SandboxMountPointProvider::OriginEnumerator* | 339 SandboxMountPointProvider::OriginEnumerator* |
| 340 SandboxMountPointProvider::CreateOriginEnumerator() { | 340 SandboxMountPointProvider::CreateOriginEnumerator() { |
| 341 return new ObfuscatedOriginEnumerator(sandbox_sync_file_util()); | 341 return new ObfuscatedOriginEnumerator(sandbox_sync_file_util()); |
| 342 } | 342 } |
| 343 | 343 |
| 344 FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType( | 344 base::FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType( |
| 345 const GURL& origin_url, fileapi::FileSystemType type, bool create) { | 345 const GURL& origin_url, fileapi::FileSystemType type, bool create) { |
| 346 | 346 |
| 347 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 347 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| 348 FilePath path = sandbox_sync_file_util()->GetDirectoryForOriginAndType( | 348 base::FilePath path = sandbox_sync_file_util()->GetDirectoryForOriginAndType( |
| 349 origin_url, type, create, &error); | 349 origin_url, type, create, &error); |
| 350 if (error != base::PLATFORM_FILE_OK) | 350 if (error != base::PLATFORM_FILE_OK) |
| 351 return FilePath(); | 351 return base::FilePath(); |
| 352 return path; | 352 return path; |
| 353 } | 353 } |
| 354 | 354 |
| 355 base::PlatformFileError | 355 base::PlatformFileError |
| 356 SandboxMountPointProvider::DeleteOriginDataOnFileThread( | 356 SandboxMountPointProvider::DeleteOriginDataOnFileThread( |
| 357 FileSystemContext* file_system_context, | 357 FileSystemContext* file_system_context, |
| 358 QuotaManagerProxy* proxy, | 358 QuotaManagerProxy* proxy, |
| 359 const GURL& origin_url, | 359 const GURL& origin_url, |
| 360 fileapi::FileSystemType type) { | 360 fileapi::FileSystemType type) { |
| 361 | 361 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 enumerator->HasFileSystemType(type)) | 411 enumerator->HasFileSystemType(type)) |
| 412 origins->insert(origin); | 412 origins->insert(origin); |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 | 415 |
| 416 int64 SandboxMountPointProvider::GetOriginUsageOnFileThread( | 416 int64 SandboxMountPointProvider::GetOriginUsageOnFileThread( |
| 417 FileSystemContext* file_system_context, | 417 FileSystemContext* file_system_context, |
| 418 const GURL& origin_url, | 418 const GURL& origin_url, |
| 419 fileapi::FileSystemType type) { | 419 fileapi::FileSystemType type) { |
| 420 DCHECK(CanHandleType(type)); | 420 DCHECK(CanHandleType(type)); |
| 421 FilePath base_path = | 421 base::FilePath base_path = |
| 422 GetBaseDirectoryForOriginAndType(origin_url, type, false); | 422 GetBaseDirectoryForOriginAndType(origin_url, type, false); |
| 423 if (base_path.empty() || !file_util::DirectoryExists(base_path)) return 0; | 423 if (base_path.empty() || !file_util::DirectoryExists(base_path)) return 0; |
| 424 FilePath usage_file_path = | 424 base::FilePath usage_file_path = |
| 425 base_path.Append(FileSystemUsageCache::kUsageFileName); | 425 base_path.Append(FileSystemUsageCache::kUsageFileName); |
| 426 | 426 |
| 427 bool is_valid = FileSystemUsageCache::IsValid(usage_file_path); | 427 bool is_valid = FileSystemUsageCache::IsValid(usage_file_path); |
| 428 int32 dirty_status = FileSystemUsageCache::GetDirty(usage_file_path); | 428 int32 dirty_status = FileSystemUsageCache::GetDirty(usage_file_path); |
| 429 bool visited = (visited_origins_.find(origin_url) != visited_origins_.end()); | 429 bool visited = (visited_origins_.find(origin_url) != visited_origins_.end()); |
| 430 visited_origins_.insert(origin_url); | 430 visited_origins_.insert(origin_url); |
| 431 if (is_valid && (dirty_status == 0 || (dirty_status > 0 && visited))) { | 431 if (is_valid && (dirty_status == 0 || (dirty_status > 0 && visited))) { |
| 432 // The usage cache is clean (dirty == 0) or the origin is already | 432 // The usage cache is clean (dirty == 0) or the origin is already |
| 433 // initialized and running. Read the cache file to get the usage. | 433 // initialized and running. Read the cache file to get the usage. |
| 434 return FileSystemUsageCache::GetUsage(usage_file_path); | 434 return FileSystemUsageCache::GetUsage(usage_file_path); |
| 435 } | 435 } |
| 436 // The usage cache has not been initialized or the cache is dirty. | 436 // The usage cache has not been initialized or the cache is dirty. |
| 437 // Get the directory size now and update the cache. | 437 // Get the directory size now and update the cache. |
| 438 FileSystemUsageCache::Delete(usage_file_path); | 438 FileSystemUsageCache::Delete(usage_file_path); |
| 439 | 439 |
| 440 FileSystemOperationContext context(file_system_context); | 440 FileSystemOperationContext context(file_system_context); |
| 441 FileSystemURL url = file_system_context->CreateCrackedFileSystemURL( | 441 FileSystemURL url = file_system_context->CreateCrackedFileSystemURL( |
| 442 origin_url, type, FilePath()); | 442 origin_url, type, base::FilePath()); |
| 443 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( | 443 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( |
| 444 sandbox_sync_file_util()->CreateFileEnumerator(&context, url, true)); | 444 sandbox_sync_file_util()->CreateFileEnumerator(&context, url, true)); |
| 445 | 445 |
| 446 FilePath file_path_each; | 446 base::FilePath file_path_each; |
| 447 int64 usage = 0; | 447 int64 usage = 0; |
| 448 | 448 |
| 449 while (!(file_path_each = enumerator->Next()).empty()) { | 449 while (!(file_path_each = enumerator->Next()).empty()) { |
| 450 usage += enumerator->Size(); | 450 usage += enumerator->Size(); |
| 451 usage += ObfuscatedFileUtil::ComputeFilePathCost(file_path_each); | 451 usage += ObfuscatedFileUtil::ComputeFilePathCost(file_path_each); |
| 452 } | 452 } |
| 453 // This clears the dirty flag too. | 453 // This clears the dirty flag too. |
| 454 FileSystemUsageCache::UpdateUsage(usage_file_path, usage); | 454 FileSystemUsageCache::UpdateUsage(usage_file_path, usage); |
| 455 return usage; | 455 return usage; |
| 456 } | 456 } |
| 457 | 457 |
| 458 void SandboxMountPointProvider::InvalidateUsageCache( | 458 void SandboxMountPointProvider::InvalidateUsageCache( |
| 459 const GURL& origin_url, fileapi::FileSystemType type) { | 459 const GURL& origin_url, fileapi::FileSystemType type) { |
| 460 DCHECK(CanHandleType(type)); | 460 DCHECK(CanHandleType(type)); |
| 461 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 461 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| 462 FilePath usage_file_path = GetUsageCachePathForOriginAndType( | 462 base::FilePath usage_file_path = GetUsageCachePathForOriginAndType( |
| 463 sandbox_sync_file_util(), origin_url, type, &error); | 463 sandbox_sync_file_util(), origin_url, type, &error); |
| 464 if (error != base::PLATFORM_FILE_OK) | 464 if (error != base::PLATFORM_FILE_OK) |
| 465 return; | 465 return; |
| 466 FileSystemUsageCache::IncrementDirty(usage_file_path); | 466 FileSystemUsageCache::IncrementDirty(usage_file_path); |
| 467 } | 467 } |
| 468 | 468 |
| 469 void SandboxMountPointProvider::CollectOpenFileSystemMetrics( | 469 void SandboxMountPointProvider::CollectOpenFileSystemMetrics( |
| 470 base::PlatformFileError error_code) { | 470 base::PlatformFileError error_code) { |
| 471 base::Time now = base::Time::Now(); | 471 base::Time now = base::Time::Now(); |
| 472 bool throttled = now < next_release_time_for_open_filesystem_stat_; | 472 bool throttled = now < next_release_time_for_open_filesystem_stat_; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 SandboxMountPointProvider::CreateFileSystemOperationForSync( | 533 SandboxMountPointProvider::CreateFileSystemOperationForSync( |
| 534 FileSystemContext* file_system_context) { | 534 FileSystemContext* file_system_context) { |
| 535 scoped_ptr<FileSystemOperationContext> operation_context( | 535 scoped_ptr<FileSystemOperationContext> operation_context( |
| 536 new FileSystemOperationContext(file_system_context)); | 536 new FileSystemOperationContext(file_system_context)); |
| 537 operation_context->set_update_observers(update_observers_); | 537 operation_context->set_update_observers(update_observers_); |
| 538 operation_context->set_access_observers(access_observers_); | 538 operation_context->set_access_observers(access_observers_); |
| 539 return new LocalFileSystemOperation(file_system_context, | 539 return new LocalFileSystemOperation(file_system_context, |
| 540 operation_context.Pass()); | 540 operation_context.Pass()); |
| 541 } | 541 } |
| 542 | 542 |
| 543 FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType( | 543 base::FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType( |
| 544 const GURL& origin_url, | 544 const GURL& origin_url, |
| 545 FileSystemType type) { | 545 FileSystemType type) { |
| 546 base::PlatformFileError error; | 546 base::PlatformFileError error; |
| 547 FilePath path = GetUsageCachePathForOriginAndType( | 547 base::FilePath path = GetUsageCachePathForOriginAndType( |
| 548 sandbox_sync_file_util(), origin_url, type, &error); | 548 sandbox_sync_file_util(), origin_url, type, &error); |
| 549 if (error != base::PLATFORM_FILE_OK) | 549 if (error != base::PLATFORM_FILE_OK) |
| 550 return FilePath(); | 550 return base::FilePath(); |
| 551 return path; | 551 return path; |
| 552 } | 552 } |
| 553 | 553 |
| 554 // static | 554 // static |
| 555 FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType( | 555 base::FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType( |
| 556 ObfuscatedFileUtil* sandbox_file_util, | 556 ObfuscatedFileUtil* sandbox_file_util, |
| 557 const GURL& origin_url, | 557 const GURL& origin_url, |
| 558 fileapi::FileSystemType type, | 558 fileapi::FileSystemType type, |
| 559 base::PlatformFileError* error_out) { | 559 base::PlatformFileError* error_out) { |
| 560 DCHECK(error_out); | 560 DCHECK(error_out); |
| 561 *error_out = base::PLATFORM_FILE_OK; | 561 *error_out = base::PLATFORM_FILE_OK; |
| 562 FilePath base_path = sandbox_file_util->GetDirectoryForOriginAndType( | 562 base::FilePath base_path = sandbox_file_util->GetDirectoryForOriginAndType( |
| 563 origin_url, type, false /* create */, error_out); | 563 origin_url, type, false /* create */, error_out); |
| 564 if (*error_out != base::PLATFORM_FILE_OK) | 564 if (*error_out != base::PLATFORM_FILE_OK) |
| 565 return FilePath(); | 565 return base::FilePath(); |
| 566 return base_path.Append(FileSystemUsageCache::kUsageFileName); | 566 return base_path.Append(FileSystemUsageCache::kUsageFileName); |
| 567 } | 567 } |
| 568 | 568 |
| 569 bool SandboxMountPointProvider::IsAllowedScheme(const GURL& url) const { | 569 bool SandboxMountPointProvider::IsAllowedScheme(const GURL& url) const { |
| 570 // Basically we only accept http or https. We allow file:// URLs | 570 // Basically we only accept http or https. We allow file:// URLs |
| 571 // only if --allow-file-access-from-files flag is given. | 571 // only if --allow-file-access-from-files flag is given. |
| 572 if (url.SchemeIs("http") || url.SchemeIs("https")) | 572 if (url.SchemeIs("http") || url.SchemeIs("https")) |
| 573 return true; | 573 return true; |
| 574 if (url.SchemeIsFileSystem()) | 574 if (url.SchemeIsFileSystem()) |
| 575 return url.inner_url() && IsAllowedScheme(*url.inner_url()); | 575 return url.inner_url() && IsAllowedScheme(*url.inner_url()); |
| 576 | 576 |
| 577 for (size_t i = 0; | 577 for (size_t i = 0; |
| 578 i < file_system_options_.additional_allowed_schemes().size(); | 578 i < file_system_options_.additional_allowed_schemes().size(); |
| 579 ++i) { | 579 ++i) { |
| 580 if (url.SchemeIs( | 580 if (url.SchemeIs( |
| 581 file_system_options_.additional_allowed_schemes()[i].c_str())) | 581 file_system_options_.additional_allowed_schemes()[i].c_str())) |
| 582 return true; | 582 return true; |
| 583 } | 583 } |
| 584 return false; | 584 return false; |
| 585 } | 585 } |
| 586 | 586 |
| 587 ObfuscatedFileUtil* SandboxMountPointProvider::sandbox_sync_file_util() { | 587 ObfuscatedFileUtil* SandboxMountPointProvider::sandbox_sync_file_util() { |
| 588 DCHECK(sandbox_file_util_.get()); | 588 DCHECK(sandbox_file_util_.get()); |
| 589 return static_cast<ObfuscatedFileUtil*>(sandbox_file_util_->sync_file_util()); | 589 return static_cast<ObfuscatedFileUtil*>(sandbox_file_util_->sync_file_util()); |
| 590 } | 590 } |
| 591 | 591 |
| 592 } // namespace fileapi | 592 } // namespace fileapi |
| OLD | NEW |