OLD | NEW |
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 "shell/filename_util.h" | 5 #include "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 "url/gurl.h" | 10 #include "url/gurl.h" |
11 #include "url/url_canon_internal.h" | 11 #include "url/url_canon_internal.h" |
12 #include "url/url_util.h" | 12 #include "url/url_util.h" |
13 | 13 |
14 namespace mojo { | |
15 namespace shell { | 14 namespace shell { |
16 | 15 |
17 // Prefix to prepend to get a file URL. | 16 // Prefix to prepend to get a file URL. |
18 static const base::FilePath::CharType kFileURLPrefix[] = | 17 static const base::FilePath::CharType kFileURLPrefix[] = |
19 FILE_PATH_LITERAL("file://"); | 18 FILE_PATH_LITERAL("file://"); |
20 | 19 |
21 GURL FilePathToFileURL(const base::FilePath& path) { | 20 GURL FilePathToFileURL(const base::FilePath& path) { |
22 // Produce a URL like "file:///C:/foo" for a regular file, or | 21 // Produce a URL like "file:///C:/foo" for a regular file, or |
23 // "file://///server/path" for UNC. The URL canonicalizer will fix up the | 22 // "file://///server/path" for UNC. The URL canonicalizer will fix up the |
24 // latter case to be the canonical UNC form: "file://server/path" | 23 // latter case to be the canonical UNC form: "file://server/path" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 if (!url.has_path() || *url.path().rbegin() == '/') | 59 if (!url.has_path() || *url.path().rbegin() == '/') |
61 return url; | 60 return url; |
62 | 61 |
63 std::string path(url.path() + '/'); | 62 std::string path(url.path() + '/'); |
64 GURL::Replacements replacements; | 63 GURL::Replacements replacements; |
65 replacements.SetPathStr(path); | 64 replacements.SetPathStr(path); |
66 return url.ReplaceComponents(replacements); | 65 return url.ReplaceComponents(replacements); |
67 } | 66 } |
68 | 67 |
69 } // namespace shell | 68 } // namespace shell |
70 } // namespace mojo | |
OLD | NEW |