summaryrefslogtreecommitdiffstats
path: root/chromium/webkit/browser/fileapi/file_system_url.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/webkit/browser/fileapi/file_system_url.cc')
-rw-r--r--chromium/webkit/browser/fileapi/file_system_url.cc70
1 files changed, 8 insertions, 62 deletions
diff --git a/chromium/webkit/browser/fileapi/file_system_url.cc b/chromium/webkit/browser/fileapi/file_system_url.cc
index b045ed3f5d3..7e879b3dbba 100644
--- a/chromium/webkit/browser/fileapi/file_system_url.cc
+++ b/chromium/webkit/browser/fileapi/file_system_url.cc
@@ -36,67 +36,6 @@ FileSystemURL FileSystemURL::CreateForTest(const GURL& origin,
return FileSystemURL(origin, mount_type, virtual_path);
}
-// static
-bool FileSystemURL::ParseFileSystemSchemeURL(
- const GURL& url,
- GURL* origin_url,
- FileSystemType* mount_type,
- base::FilePath* virtual_path) {
- GURL origin;
- FileSystemType file_system_type = kFileSystemTypeUnknown;
-
- if (!url.is_valid() || !url.SchemeIsFileSystem())
- return false;
-
- const struct {
- FileSystemType type;
- const char* dir;
- } kValidTypes[] = {
- { kFileSystemTypePersistent, kPersistentDir },
- { kFileSystemTypeTemporary, kTemporaryDir },
- { kFileSystemTypeIsolated, kIsolatedDir },
- { kFileSystemTypeExternal, kExternalDir },
- { kFileSystemTypeTest, kTestDir },
- };
-
- // A path of the inner_url contains only mount type part (e.g. "/temporary").
- DCHECK(url.inner_url());
- std::string inner_path = url.inner_url()->path();
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kValidTypes); ++i) {
- if (inner_path == kValidTypes[i].dir) {
- file_system_type = kValidTypes[i].type;
- break;
- }
- }
-
- if (file_system_type == kFileSystemTypeUnknown)
- return false;
-
- std::string path = net::UnescapeURLComponent(url.path(),
- net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS |
- net::UnescapeRule::CONTROL_CHARS);
-
- // Ensure the path is relative.
- while (!path.empty() && path[0] == '/')
- path.erase(0, 1);
-
- base::FilePath converted_path = base::FilePath::FromUTF8Unsafe(path);
-
- // All parent references should have been resolved in the renderer.
- if (converted_path.ReferencesParent())
- return false;
-
- if (origin_url)
- *origin_url = url.GetOrigin();
- if (mount_type)
- *mount_type = file_system_type;
- if (virtual_path)
- *virtual_path = converted_path.NormalizePathSeparators().
- StripTrailingSeparators();
-
- return true;
-}
-
FileSystemURL::FileSystemURL(const GURL& url)
: mount_type_(kFileSystemTypeUnknown),
type_(kFileSystemTypeUnknown),
@@ -148,7 +87,14 @@ GURL FileSystemURL::ToGURL() const {
if (url.empty())
return GURL();
- url.append(virtual_path_.AsUTF8Unsafe());
+ // Exactly match with DOMFileSystemBase::createFileSystemURL()'s encoding
+ // behavior, where the path is escaped by KURL::encodeWithURLEscapeSequences
+ // which is essentially encodeURIComponent except '/'.
+ std::string escaped = net::EscapeQueryParamValue(
+ virtual_path_.NormalizePathSeparatorsTo('/').AsUTF8Unsafe(),
+ false /* use_plus */);
+ ReplaceSubstringsAfterOffset(&escaped, 0, "%2F", "/");
+ url.append(escaped);
// Build nested GURL.
return GURL(url);