Index: mojo/shell/filename_util.cc |
diff --git a/mojo/shell/filename_util.cc b/mojo/shell/filename_util.cc |
index 073bddaf19d6bc76c32a45d749b4a5a05d1d9ee5..93a62c2667b0c2d606179e4b2c9fd5f7b4672c3d 100644 |
--- a/mojo/shell/filename_util.cc |
+++ b/mojo/shell/filename_util.cc |
@@ -7,6 +7,7 @@ |
#include "base/files/file_path.h" |
#include "base/path_service.h" |
#include "base/strings/string_util.h" |
+#include "base/strings/utf_string_conversions.h" |
#include "url/gurl.h" |
#include "url/url_canon_internal.h" |
#include "url/url_util.h" |
@@ -68,5 +69,20 @@ GURL AddTrailingSlashIfNeeded(const GURL& url) { |
return url.ReplaceComponents(replacements); |
} |
+base::FilePath UrlToFilePath(const GURL& url) { |
+ DCHECK(url.SchemeIsFile()); |
+ url::RawCanonOutputW<1024> output; |
+ url::DecodeURLEscapeSequences(url.path().data(), |
+ static_cast<int>(url.path().length()), &output); |
+ base::string16 decoded_path = base::string16(output.data(), output.length()); |
+#if defined(OS_WIN) |
+ base::TrimString(decoded_path, L"/", &decoded_path); |
+ base::FilePath path(decoded_path); |
+#else |
+ base::FilePath path(base::UTF16ToUTF8(decoded_path)); |
+#endif |
+ return path; |
+} |
+ |
} // namespace shell |
} // namespace mojo |