| 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 "storage/common/fileapi/file_system_util.h" | 5 #include "storage/common/fileapi/file_system_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } kValidTypes[] = { | 165 } kValidTypes[] = { |
| 166 { kFileSystemTypePersistent, kPersistentDir }, | 166 { kFileSystemTypePersistent, kPersistentDir }, |
| 167 { kFileSystemTypeTemporary, kTemporaryDir }, | 167 { kFileSystemTypeTemporary, kTemporaryDir }, |
| 168 { kFileSystemTypeIsolated, kIsolatedDir }, | 168 { kFileSystemTypeIsolated, kIsolatedDir }, |
| 169 { kFileSystemTypeExternal, kExternalDir }, | 169 { kFileSystemTypeExternal, kExternalDir }, |
| 170 { kFileSystemTypeTest, kTestDir }, | 170 { kFileSystemTypeTest, kTestDir }, |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 // A path of the inner_url contains only mount type part (e.g. "/temporary"). | 173 // A path of the inner_url contains only mount type part (e.g. "/temporary"). |
| 174 DCHECK(url.inner_url()); | 174 DCHECK(url.inner_url()); |
| 175 std::string inner_path = url.inner_url()->path(); | 175 base::StringPiece inner_path = url.inner_url()->path(); |
| 176 for (size_t i = 0; i < arraysize(kValidTypes); ++i) { | 176 for (size_t i = 0; i < arraysize(kValidTypes); ++i) { |
| 177 if (inner_path == kValidTypes[i].dir) { | 177 if (inner_path == kValidTypes[i].dir) { |
| 178 file_system_type = kValidTypes[i].type; | 178 file_system_type = kValidTypes[i].type; |
| 179 break; | 179 break; |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 if (file_system_type == kFileSystemTypeUnknown) | 183 if (file_system_type == kFileSystemTypeUnknown) |
| 184 return false; | 184 return false; |
| 185 | 185 |
| 186 std::string path = net::UnescapeURLComponent(url.path(), | 186 std::string path = net::UnescapeURLComponent( |
| 187 url.path().as_string(), |
| 187 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | | 188 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | |
| 188 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | | 189 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | |
| 189 net::UnescapeRule::SPOOFING_AND_CONTROL_CHARS); | 190 net::UnescapeRule::SPOOFING_AND_CONTROL_CHARS); |
| 190 | 191 |
| 191 // Ensure the path is relative. | 192 // Ensure the path is relative. |
| 192 while (!path.empty() && path[0] == '/') | 193 while (!path.empty() && path[0] == '/') |
| 193 path.erase(0, 1); | 194 path.erase(0, 1); |
| 194 | 195 |
| 195 base::FilePath converted_path = base::FilePath::FromUTF8Unsafe(path); | 196 base::FilePath converted_path = base::FilePath::FromUTF8Unsafe(path); |
| 196 | 197 |
| 197 // All parent references should have been resolved in the renderer. | 198 // All parent references should have been resolved in the renderer. |
| 198 if (converted_path.ReferencesParent()) | 199 if (converted_path.ReferencesParent()) |
| 199 return false; | 200 return false; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 return base::File::FILE_ERROR_ABORT; | 504 return base::File::FILE_ERROR_ABORT; |
| 504 case net::ERR_ADDRESS_INVALID: | 505 case net::ERR_ADDRESS_INVALID: |
| 505 case net::ERR_INVALID_URL: | 506 case net::ERR_INVALID_URL: |
| 506 return base::File::FILE_ERROR_INVALID_URL; | 507 return base::File::FILE_ERROR_INVALID_URL; |
| 507 default: | 508 default: |
| 508 return base::File::FILE_ERROR_FAILED; | 509 return base::File::FILE_ERROR_FAILED; |
| 509 } | 510 } |
| 510 } | 511 } |
| 511 | 512 |
| 512 } // namespace storage | 513 } // namespace storage |
| OLD | NEW |