| 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 12 matching lines...) Expand all Loading... |
| 23 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 24 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" | 24 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 // We use some of WebKit types for conversions between origin identifiers | 27 // We use some of WebKit types for conversions between origin identifiers |
| 28 // and origin URLs. | 28 // and origin URLs. |
| 29 using WebKit::WebFileSystem; | 29 using WebKit::WebFileSystem; |
| 30 | 30 |
| 31 using base::PlatformFileError; | 31 using base::PlatformFileError; |
| 32 | 32 |
| 33 static const char kChromeScheme[] = "chrome"; |
| 33 static const char kExtensionScheme[] = "chrome-extension"; | 34 static const char kExtensionScheme[] = "chrome-extension"; |
| 34 | 35 |
| 35 namespace fileapi { | 36 namespace fileapi { |
| 36 | 37 |
| 37 FileSystemPathManager::FileSystemPathManager( | 38 FileSystemPathManager::FileSystemPathManager( |
| 38 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 39 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
| 39 const FilePath& profile_path, | 40 const FilePath& profile_path, |
| 40 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, | 41 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, |
| 41 bool is_incognito, | 42 bool is_incognito, |
| 42 bool allow_file_access_from_files) | 43 bool allow_file_access_from_files) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 default: | 99 default: |
| 99 NOTREACHED(); | 100 NOTREACHED(); |
| 100 return FilePath(); | 101 return FilePath(); |
| 101 } | 102 } |
| 102 } | 103 } |
| 103 | 104 |
| 104 bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { | 105 bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { |
| 105 // Basically we only accept http or https. We allow file:// URLs | 106 // Basically we only accept http or https. We allow file:// URLs |
| 106 // only if --allow-file-access-from-files flag is given. | 107 // only if --allow-file-access-from-files flag is given. |
| 107 return url.SchemeIs("http") || url.SchemeIs("https") || | 108 return url.SchemeIs("http") || url.SchemeIs("https") || |
| 108 url.SchemeIs(kExtensionScheme) || | 109 url.SchemeIs(kExtensionScheme) || url.SchemeIs(kChromeScheme) || |
| 109 (url.SchemeIsFile() && allow_file_access_from_files_); | 110 (url.SchemeIsFile() && allow_file_access_from_files_); |
| 110 } | 111 } |
| 111 | 112 |
| 112 // static | 113 // static |
| 113 std::string FileSystemPathManager::GetFileSystemTypeString( | 114 std::string FileSystemPathManager::GetFileSystemTypeString( |
| 114 fileapi::FileSystemType type) { | 115 fileapi::FileSystemType type) { |
| 115 if (type == fileapi::kFileSystemTypeTemporary) | 116 if (type == fileapi::kFileSystemTypeTemporary) |
| 116 return fileapi::kTemporaryName; | 117 return fileapi::kTemporaryName; |
| 117 else if (type == fileapi::kFileSystemTypePersistent) | 118 else if (type == fileapi::kFileSystemTypePersistent) |
| 118 return fileapi::kPersistentName; | 119 return fileapi::kPersistentName; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 178 } |
| 178 | 179 |
| 179 } // namespace fileapi | 180 } // namespace fileapi |
| 180 | 181 |
| 181 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ | 182 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ |
| 182 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); | 183 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); |
| 183 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ | 184 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ |
| 184 int(fileapi::kFileSystemTypePersistent), mismatching_enums); | 185 int(fileapi::kFileSystemTypePersistent), mismatching_enums); |
| 185 COMPILE_ASSERT(int(WebFileSystem::TypeExternal) == \ | 186 COMPILE_ASSERT(int(WebFileSystem::TypeExternal) == \ |
| 186 int(fileapi::kFileSystemTypeExternal), mismatching_enums); | 187 int(fileapi::kFileSystemTypeExternal), mismatching_enums); |
| OLD | NEW |