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

Side by Side Diff: mojo/shell/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: rename 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/shell/filename_util.h" 5 #include "mojo/shell/filename_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h"
10 #include "url/gurl.h" 11 #include "url/gurl.h"
11 #include "url/url_canon_internal.h" 12 #include "url/url_canon_internal.h"
12 #include "url/url_util.h" 13 #include "url/url_util.h"
13 14
14 namespace mojo { 15 namespace mojo {
15 namespace shell { 16 namespace shell {
16 17
17 // Prefix to prepend to get a file URL. 18 // Prefix to prepend to get a file URL.
18 static const base::FilePath::CharType kFileURLPrefix[] = 19 static const base::FilePath::CharType kFileURLPrefix[] =
19 FILE_PATH_LITERAL("file://"); 20 FILE_PATH_LITERAL("file://");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 GURL AddTrailingSlashIfNeeded(const GURL& url) { 62 GURL AddTrailingSlashIfNeeded(const GURL& url) {
62 if (!url.has_path() || *url.path().rbegin() == '/') 63 if (!url.has_path() || *url.path().rbegin() == '/')
63 return url; 64 return url;
64 65
65 std::string path(url.path() + '/'); 66 std::string path(url.path() + '/');
66 GURL::Replacements replacements; 67 GURL::Replacements replacements;
67 replacements.SetPathStr(path); 68 replacements.SetPathStr(path);
68 return url.ReplaceComponents(replacements); 69 return url.ReplaceComponents(replacements);
69 } 70 }
70 71
72 base::FilePath UrlToFilePath(const GURL& url) {
73 DCHECK(url.SchemeIsFile());
74 url::RawCanonOutputW<1024> output;
75 url::DecodeURLEscapeSequences(url.path().data(),
76 static_cast<int>(url.path().length()), &output);
77 base::string16 decoded_path = base::string16(output.data(), output.length());
78 #if defined(OS_WIN)
79 base::TrimString(decoded_path, L"/", &decoded_path);
80 base::FilePath path(decoded_path);
81 #else
82 base::FilePath path(base::UTF16ToUTF8(decoded_path));
83 #endif
84 return path;
85 }
86
71 } // namespace shell 87 } // namespace shell
72 } // namespace mojo 88 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698