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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 origin_url, type, virtual_path, create) : | 93 origin_url, type, virtual_path, create) : |
94 FilePath(); | 94 FilePath(); |
95 case kFileSystemTypeUnknown: | 95 case kFileSystemTypeUnknown: |
96 default: | 96 default: |
97 NOTREACHED(); | 97 NOTREACHED(); |
98 return FilePath(); | 98 return FilePath(); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { | 102 bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { |
103 // Basically we only accept http or https. We allow file:// URLs | 103 // Basically we only accept http, https, or extensions. We allow file:// URLs |
104 // only if --allow-file-access-from-files flag is given. | 104 // only if --allow-file-access-from-files flag is given. And we allow |
| 105 // filesystem: urls if the URL's inner scheme is one we allow. |
105 return url.SchemeIs("http") || url.SchemeIs("https") || | 106 return url.SchemeIs("http") || url.SchemeIs("https") || |
106 url.SchemeIs(kExtensionScheme) || url.SchemeIs(kChromeScheme) || | 107 url.SchemeIs(kExtensionScheme) || url.SchemeIs(kChromeScheme) || |
107 (url.SchemeIsFile() && allow_file_access_from_files_); | 108 (url.SchemeIsFile() && allow_file_access_from_files_) || |
| 109 (url.SchemeIsFileSystem() && url.inner_url() && |
| 110 IsAllowedScheme(*url.inner_url())); |
108 } | 111 } |
109 | 112 |
110 // static | 113 // static |
111 std::string FileSystemPathManager::GetFileSystemTypeString( | 114 std::string FileSystemPathManager::GetFileSystemTypeString( |
112 fileapi::FileSystemType type) { | 115 fileapi::FileSystemType type) { |
113 if (type == fileapi::kFileSystemTypeTemporary) | 116 if (type == fileapi::kFileSystemTypeTemporary) |
114 return fileapi::kTemporaryName; | 117 return fileapi::kTemporaryName; |
115 else if (type == fileapi::kFileSystemTypePersistent) | 118 else if (type == fileapi::kFileSystemTypePersistent) |
116 return fileapi::kPersistentName; | 119 return fileapi::kPersistentName; |
117 else if (type == fileapi::kFileSystemTypeExternal) | 120 else if (type == fileapi::kFileSystemTypeExternal) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 183 } |
181 | 184 |
182 } // namespace fileapi | 185 } // namespace fileapi |
183 | 186 |
184 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ | 187 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ |
185 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); | 188 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); |
186 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ | 189 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ |
187 int(fileapi::kFileSystemTypePersistent), mismatching_enums); | 190 int(fileapi::kFileSystemTypePersistent), mismatching_enums); |
188 COMPILE_ASSERT(int(WebFileSystem::TypeExternal) == \ | 191 COMPILE_ASSERT(int(WebFileSystem::TypeExternal) == \ |
189 int(fileapi::kFileSystemTypeExternal), mismatching_enums); | 192 int(fileapi::kFileSystemTypeExternal), mismatching_enums); |
OLD | NEW |