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

Side by Side Diff: net/base/net_util.h

Issue 271056: Do some cleanup of file path name handling. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/tab_contents/tab_contents_view_win.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_NET_UTIL_H__ 5 #ifndef NET_BASE_NET_UTIL_H_
6 #define NET_BASE_NET_UTIL_H__ 6 #define NET_BASE_NET_UTIL_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #ifdef OS_WIN 10 #ifdef OS_WIN
11 #include <windows.h> 11 #include <windows.h>
12 #endif 12 #endif
13 13
14 #include <string> 14 #include <string>
15 #include <set> 15 #include <set>
16 16
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // another means to get a filename (e.g. url). 119 // another means to get a filename (e.g. url).
120 // 120 //
121 // This function does not do any escaping and callers are responsible for 121 // This function does not do any escaping and callers are responsible for
122 // escaping 'unsafe' characters (e.g. (back)slash, colon) as they see fit. 122 // escaping 'unsafe' characters (e.g. (back)slash, colon) as they see fit.
123 // 123 //
124 // TODO(jungshik): revisit this issue. At the moment, the only caller 124 // TODO(jungshik): revisit this issue. At the moment, the only caller
125 // net_util::GetSuggestedFilename and it calls ReplaceIllegalCharacters. The 125 // net_util::GetSuggestedFilename and it calls ReplaceIllegalCharacters. The
126 // other caller is a unit test. Need to figure out expose this function only to 126 // other caller is a unit test. Need to figure out expose this function only to
127 // net_util_unittest. 127 // net_util_unittest.
128 // 128 //
129 std::wstring GetFileNameFromCD(const std::string& header, 129 std::string GetFileNameFromCD(const std::string& header,
130 const std::string& referrer_charset); 130 const std::string& referrer_charset);
131 131
132 // Converts the given host name to unicode characters, APPENDING them to the 132 // Converts the given host name to unicode characters, APPENDING them to the
133 // the given output string. This can be called for any host name, if the 133 // the given output string. This can be called for any host name, if the
134 // input is not IDN or is invalid in some way, we'll just append the ASCII 134 // input is not IDN or is invalid in some way, we'll just append the ASCII
135 // source to the output so it is still usable. 135 // source to the output so it is still usable.
136 // 136 //
137 // The input should be the canonicalized ASCII host name from GURL. This 137 // The input should be the canonicalized ASCII host name from GURL. This
138 // function does NOT accept UTF-8! Its length must also be given (this is 138 // function does NOT accept UTF-8! Its length must also be given (this is
139 // designed to work on the substring of the host out of a URL spec). 139 // designed to work on the substring of the host out of a URL spec).
140 // 140 //
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 const std::string& raw_bytes, 187 const std::string& raw_bytes,
188 bool is_dir, int64 size, 188 bool is_dir, int64 size,
189 base::Time modified); 189 base::Time modified);
190 190
191 // If text starts with "www." it is removed, otherwise text is returned 191 // If text starts with "www." it is removed, otherwise text is returned
192 // unmodified. 192 // unmodified.
193 std::wstring StripWWW(const std::wstring& text); 193 std::wstring StripWWW(const std::wstring& text);
194 194
195 // Gets the filename from the raw Content-Disposition header (as read from the 195 // Gets the filename from the raw Content-Disposition header (as read from the
196 // network). Otherwise uses the last path component name or hostname from 196 // network). Otherwise uses the last path component name or hostname from
197 // |url|. Note: it's possible for the suggested filename to be empty (e.g., 197 // |url|. If there is no filename or it can't be used, the given default name
198 // will be used if specified.
199
200 // Note: it's possible for the suggested filename to be empty (e.g.,
198 // file:///). referrer_charset is used as one of charsets 201 // file:///). referrer_charset is used as one of charsets
199 // to interpret a raw 8bit string in C-D header (after interpreting 202 // to interpret a raw 8bit string in C-D header (after interpreting
200 // as UTF-8 fails). See the comment for GetFilenameFromCD for more details. 203 // as UTF-8 fails). See the comment for GetFilenameFromCD for more details.
201 std::wstring GetSuggestedFilename(const GURL& url, 204 FilePath GetSuggestedFilename(const GURL& url,
202 const std::string& content_disposition, 205 const std::string& content_disposition,
203 const std::string& referrer_charset, 206 const std::string& referrer_charset,
204 const std::wstring& default_name); 207 const char* default_name);
205 208
206 // Checks the given port against a list of ports which are restricted by 209 // Checks the given port against a list of ports which are restricted by
207 // default. Returns true if the port is allowed, false if it is restricted. 210 // default. Returns true if the port is allowed, false if it is restricted.
208 bool IsPortAllowedByDefault(int port); 211 bool IsPortAllowedByDefault(int port);
209 212
210 // Checks the given port against a list of ports which are restricted by the 213 // Checks the given port against a list of ports which are restricted by the
211 // FTP protocol. Returns true if the port is allowed, false if it is 214 // FTP protocol. Returns true if the port is allowed, false if it is
212 // restricted. 215 // restricted.
213 bool IsPortAllowedByFtp(int port); 216 bool IsPortAllowedByFtp(int port);
214 217
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 255
253 // Strip the portions of |url| that aren't core to the network request. 256 // Strip the portions of |url| that aren't core to the network request.
254 // - user name / password 257 // - user name / password
255 // - reference section 258 // - reference section
256 GURL SimplifyUrlForRequest(const GURL& url); 259 GURL SimplifyUrlForRequest(const GURL& url);
257 260
258 void SetExplicitlyAllowedPorts(const std::wstring& allowed_ports); 261 void SetExplicitlyAllowedPorts(const std::wstring& allowed_ports);
259 262
260 } // namespace net 263 } // namespace net
261 264
262 #endif // NET_BASE_NET_UTIL_H__ 265 #endif // NET_BASE_NET_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/tab_contents/tab_contents_view_win.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698