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 #ifndef NET_BASE_FILENAME_UTIL_H_ | 5 #ifndef NET_BASE_FILENAME_UTIL_H_ |
6 #define NET_BASE_FILENAME_UTIL_H_ | 6 #define NET_BASE_FILENAME_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
12 | 12 |
13 class GURL; | 13 class GURL; |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class FilePath; | 16 class FilePath; |
17 } | 17 } |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 // Given the full path to a file name, creates a file: URL. The returned URL | 21 // Given the full path to a file name, creates a file: URL. The returned URL |
22 // may not be valid if the input is malformed. | 22 // may not be valid if the input is malformed. |
23 // Can be used only in IO thread because if adding current diretory to path | |
24 // will indirectly do AssertIOAllowed | |
davidben
2015/04/14 16:26:22
I think there may be some confusion here. AssertIO
| |
23 NET_EXPORT GURL FilePathToFileURL(const base::FilePath& path); | 25 NET_EXPORT GURL FilePathToFileURL(const base::FilePath& path); |
24 | 26 |
27 // Variant of FilePathToFileURL, that doesn't add current direstory fo paths | |
28 // that are recognized as relarive. Can be used on any thread. | |
29 NET_EXPORT GURL FilePathToFileURLNoCWD(const base::FilePath& path); | |
30 | |
25 // Converts a file: URL back to a filename that can be passed to the OS. The | 31 // Converts a file: URL back to a filename that can be passed to the OS. The |
26 // file URL must be well-formed (GURL::is_valid() must return true); we don't | 32 // file URL must be well-formed (GURL::is_valid() must return true); we don't |
27 // handle degenerate cases here. Returns true on success, false if it isn't a | 33 // handle degenerate cases here. Returns true on success, false if it isn't a |
28 // valid file URL. On failure, *file_path will be empty. | 34 // valid file URL. On failure, *file_path will be empty. |
29 NET_EXPORT bool FileURLToFilePath(const GURL& url, base::FilePath* file_path); | 35 NET_EXPORT bool FileURLToFilePath(const GURL& url, base::FilePath* file_path); |
30 | 36 |
31 // Generates a filename using the first successful method from the following (in | 37 // Generates a filename using the first successful method from the following (in |
32 // order): | 38 // order): |
33 // | 39 // |
34 // 1) The raw Content-Disposition header in |content_disposition| as read from | 40 // 1) The raw Content-Disposition header in |content_disposition| as read from |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 // | 113 // |
108 // Note: |mime_type| should only be non-empty if this function is called from a | 114 // Note: |mime_type| should only be non-empty if this function is called from a |
109 // thread that allows IO. | 115 // thread that allows IO. |
110 NET_EXPORT void GenerateSafeFileName(const std::string& mime_type, | 116 NET_EXPORT void GenerateSafeFileName(const std::string& mime_type, |
111 bool ignore_extension, | 117 bool ignore_extension, |
112 base::FilePath* file_path); | 118 base::FilePath* file_path); |
113 | 119 |
114 } // namespace net | 120 } // namespace net |
115 | 121 |
116 #endif // NET_BASE_FILENAME_UTIL_H_ | 122 #endif // NET_BASE_FILENAME_UTIL_H_ |
OLD | NEW |