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 "webkit/browser/fileapi/file_system_url.h" | 5 #include "webkit/browser/fileapi/file_system_url.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | |
11 #include "net/base/escape.h" | |
10 #include "webkit/common/fileapi/file_system_types.h" | 12 #include "webkit/common/fileapi/file_system_types.h" |
11 #include "webkit/common/fileapi/file_system_util.h" | 13 #include "webkit/common/fileapi/file_system_util.h" |
12 | 14 |
13 namespace fileapi { | 15 namespace fileapi { |
14 | 16 |
15 namespace { | 17 namespace { |
16 | 18 |
17 } // namespace | 19 } // namespace |
18 | 20 |
19 FileSystemURL::FileSystemURL() | 21 FileSystemURL::FileSystemURL() |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 FileSystemURL::~FileSystemURL() {} | 80 FileSystemURL::~FileSystemURL() {} |
79 | 81 |
80 GURL FileSystemURL::ToGURL() const { | 82 GURL FileSystemURL::ToGURL() const { |
81 if (!is_valid_) | 83 if (!is_valid_) |
82 return GURL(); | 84 return GURL(); |
83 | 85 |
84 std::string url = GetFileSystemRootURI(origin_, mount_type_).spec(); | 86 std::string url = GetFileSystemRootURI(origin_, mount_type_).spec(); |
85 if (url.empty()) | 87 if (url.empty()) |
86 return GURL(); | 88 return GURL(); |
87 | 89 |
88 url.append(virtual_path_.AsUTF8Unsafe()); | 90 // To exactly match with DOMFileSystemBase::createFileSystemURL()'s encoding |
91 // behavior. There the path is escaped by KRUL::encodeWithURLEscapeSequences, | |
tzik
2014/06/17 02:19:27
KURL?
kinaba
2014/06/17 02:26:10
Done.
| |
92 // which is essentially encodeURIComponent except '/'. | |
93 std::string escaped = net::EscapeQueryParamValue( | |
94 virtual_path_.NormalizePathSeparatorsTo('/').AsUTF8Unsafe(), | |
95 false /* use_plus */); | |
96 ReplaceSubstringsAfterOffset(&escaped, 0, "%2F", "/"); | |
97 url.append(escaped); | |
89 | 98 |
90 // Build nested GURL. | 99 // Build nested GURL. |
91 return GURL(url); | 100 return GURL(url); |
92 } | 101 } |
93 | 102 |
94 std::string FileSystemURL::DebugString() const { | 103 std::string FileSystemURL::DebugString() const { |
95 if (!is_valid_) | 104 if (!is_valid_) |
96 return "invalid filesystem: URL"; | 105 return "invalid filesystem: URL"; |
97 std::ostringstream ss; | 106 std::ostringstream ss; |
98 ss << GetFileSystemRootURI(origin_, mount_type_); | 107 ss << GetFileSystemRootURI(origin_, mount_type_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 if (lhs.origin_ != rhs.origin_) | 144 if (lhs.origin_ != rhs.origin_) |
136 return lhs.origin_ < rhs.origin_; | 145 return lhs.origin_ < rhs.origin_; |
137 if (lhs.type_ != rhs.type_) | 146 if (lhs.type_ != rhs.type_) |
138 return lhs.type_ < rhs.type_; | 147 return lhs.type_ < rhs.type_; |
139 if (lhs.filesystem_id_ != rhs.filesystem_id_) | 148 if (lhs.filesystem_id_ != rhs.filesystem_id_) |
140 return lhs.filesystem_id_ < rhs.filesystem_id_; | 149 return lhs.filesystem_id_ < rhs.filesystem_id_; |
141 return lhs.path_ < rhs.path_; | 150 return lhs.path_ < rhs.path_; |
142 } | 151 } |
143 | 152 |
144 } // namespace fileapi | 153 } // namespace fileapi |
OLD | NEW |