| 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/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/memory/scoped_callback_factory.h" | 9 #include "base/memory/scoped_callback_factory.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 file_message_loop, | 47 file_message_loop, |
| 48 profile_path)) { | 48 profile_path)) { |
| 49 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
| 50 external_provider_.reset( | 50 external_provider_.reset( |
| 51 new chromeos::CrosMountPointProvider(special_storage_policy)); | 51 new chromeos::CrosMountPointProvider(special_storage_policy)); |
| 52 #endif | 52 #endif |
| 53 } | 53 } |
| 54 | 54 |
| 55 FileSystemPathManager::~FileSystemPathManager() {} | 55 FileSystemPathManager::~FileSystemPathManager() {} |
| 56 | 56 |
| 57 void FileSystemPathManager::GetFileSystemRootPath( | 57 void FileSystemPathManager::ValidateFileSystemRootAndGetURL( |
| 58 const GURL& origin_url, fileapi::FileSystemType type, | 58 const GURL& origin_url, fileapi::FileSystemType type, |
| 59 bool create, GetRootPathCallback* callback_ptr) { | 59 bool create, GetRootPathCallback* callback_ptr) { |
| 60 | 60 |
| 61 switch (type) { | 61 switch (type) { |
| 62 case kFileSystemTypeTemporary: | 62 case kFileSystemTypeTemporary: |
| 63 case kFileSystemTypePersistent: | 63 case kFileSystemTypePersistent: |
| 64 sandbox_provider_->GetFileSystemRootPath( | 64 sandbox_provider_->ValidateFileSystemRootAndGetURL( |
| 65 origin_url, type, create, callback_ptr); | 65 origin_url, type, create, callback_ptr); |
| 66 break; | 66 break; |
| 67 case kFileSystemTypeExternal: | 67 case kFileSystemTypeExternal: |
| 68 if (external_provider_.get()) { | 68 if (external_provider_.get()) { |
| 69 external_provider_->GetFileSystemRootPath( | 69 external_provider_->ValidateFileSystemRootAndGetURL( |
| 70 origin_url, type, create, callback_ptr); | 70 origin_url, type, create, callback_ptr); |
| 71 } else { | 71 } else { |
| 72 callback_ptr->Run(false, FilePath(), std::string()); | 72 callback_ptr->Run(false, FilePath(), std::string()); |
| 73 } | 73 } |
| 74 break; | 74 break; |
| 75 case kFileSystemTypeUnknown: | 75 case kFileSystemTypeUnknown: |
| 76 default: | 76 default: |
| 77 NOTREACHED(); | 77 NOTREACHED(); |
| 78 callback_ptr->Run(false, FilePath(), std::string()); | 78 callback_ptr->Run(false, FilePath(), std::string()); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 FilePath FileSystemPathManager::GetFileSystemRootPathOnFileThread( | 82 FilePath FileSystemPathManager::ValidateFileSystemRootAndGetPathOnFileThread( |
| 83 const GURL& origin_url, FileSystemType type, const FilePath& virtual_path, | 83 const GURL& origin_url, FileSystemType type, const FilePath& virtual_path, |
| 84 bool create) { | 84 bool create) { |
| 85 switch (type) { | 85 switch (type) { |
| 86 case kFileSystemTypeTemporary: | 86 case kFileSystemTypeTemporary: |
| 87 case kFileSystemTypePersistent: | 87 case kFileSystemTypePersistent: |
| 88 return sandbox_provider_->GetFileSystemRootPathOnFileThread( | 88 return sandbox_provider_->ValidateFileSystemRootAndGetPathOnFileThread( |
| 89 origin_url, type, virtual_path, create); | 89 origin_url, type, virtual_path, create); |
| 90 break; | 90 break; |
| 91 case kFileSystemTypeExternal: | 91 case kFileSystemTypeExternal: |
| 92 return external_provider_.get() ? | 92 return external_provider_.get() ? |
| 93 external_provider_->GetFileSystemRootPathOnFileThread( | 93 external_provider_->ValidateFileSystemRootAndGetPathOnFileThread( |
| 94 origin_url, type, virtual_path, create) : | 94 origin_url, type, virtual_path, create) : |
| 95 FilePath(); | 95 FilePath(); |
| 96 case kFileSystemTypeUnknown: | 96 case kFileSystemTypeUnknown: |
| 97 default: | 97 default: |
| 98 NOTREACHED(); | 98 NOTREACHED(); |
| 99 return FilePath(); | 99 return FilePath(); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { | 103 bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace fileapi | 163 } // namespace fileapi |
| 164 | 164 |
| 165 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ | 165 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ |
| 166 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); | 166 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); |
| 167 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ | 167 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ |
| 168 int(fileapi::kFileSystemTypePersistent), mismatching_enums); | 168 int(fileapi::kFileSystemTypePersistent), mismatching_enums); |
| 169 COMPILE_ASSERT(int(WebFileSystem::TypeExternal) == \ | 169 COMPILE_ASSERT(int(WebFileSystem::TypeExternal) == \ |
| 170 int(fileapi::kFileSystemTypeExternal), mismatching_enums); | 170 int(fileapi::kFileSystemTypeExternal), mismatching_enums); |
| OLD | NEW |