Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1079)

Unified Diff: mojo/util/filename_util.cc

Issue 1109993002: Adds support for mojo apps to live in their own directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to trunk and move filename_util to own dir Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/util/filename_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/util/filename_util.cc
diff --git a/mojo/runner/filename_util.cc b/mojo/util/filename_util.cc
similarity index 79%
rename from mojo/runner/filename_util.cc
rename to mojo/util/filename_util.cc
index 3f8a82b91b5d5ee2a184b68d34908dfa808ceaa7..1a694e1e9bb828784662b8e4a32172e7dde32c01 100644
--- a/mojo/runner/filename_util.cc
+++ b/mojo/util/filename_util.cc
@@ -2,17 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mojo/runner/filename_util.h"
+#include "mojo/util/filename_util.h"
#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"
namespace mojo {
-namespace shell {
+namespace util {
// Prefix to prepend to get a file URL.
static const base::FilePath::CharType kFileURLPrefix[] =
@@ -68,5 +69,20 @@ GURL AddTrailingSlashIfNeeded(const GURL& url) {
return url.ReplaceComponents(replacements);
}
-} // namespace shell
+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 util
} // namespace mojo
« no previous file with comments | « mojo/util/filename_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698