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

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

Issue 9317018: referrer_charset is a lie. It's really the user's default_charset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/shell/shell_download_manager_delegate.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 NET_EXPORT std::string GetHostOrSpecFromURL(const GURL& url); 127 NET_EXPORT std::string GetHostOrSpecFromURL(const GURL& url);
128 128
129 // Return the value of the HTTP response header with name 'name'. 'headers' 129 // Return the value of the HTTP response header with name 'name'. 'headers'
130 // should be in the format that URLRequest::GetResponseHeaders() returns. 130 // should be in the format that URLRequest::GetResponseHeaders() returns.
131 // Returns the empty string if the header is not found. 131 // Returns the empty string if the header is not found.
132 NET_EXPORT std::string GetSpecificHeader(const std::string& headers, 132 NET_EXPORT std::string GetSpecificHeader(const std::string& headers,
133 const std::string& name); 133 const std::string& name);
134 134
135 // TODO(abarth): Move these functions to http_content_disposition.cc. 135 // TODO(abarth): Move these functions to http_content_disposition.cc.
136 bool DecodeFilenameValue(const std::string& input, 136 bool DecodeFilenameValue(const std::string& input,
137 const std::string& referrer_charset, 137 const std::string& default_charset,
138 std::string* output); 138 std::string* output);
139 bool DecodeExtValue(const std::string& value, std::string* output); 139 bool DecodeExtValue(const std::string& value, std::string* output);
140 140
141 // Converts the given host name to unicode characters. This can be called for 141 // Converts the given host name to unicode characters. This can be called for
142 // any host name, if the input is not IDN or is invalid in some way, we'll just 142 // any host name, if the input is not IDN or is invalid in some way, we'll just
143 // return the ASCII source so it is still usable. 143 // return the ASCII source so it is still usable.
144 // 144 //
145 // The input should be the canonicalized ASCII host name from GURL. This 145 // The input should be the canonicalized ASCII host name from GURL. This
146 // function does NOT accept UTF-8! 146 // function does NOT accept UTF-8!
147 // 147 //
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 base::Time modified); 202 base::Time modified);
203 203
204 // If text starts with "www." it is removed, otherwise text is returned 204 // If text starts with "www." it is removed, otherwise text is returned
205 // unmodified. 205 // unmodified.
206 NET_EXPORT string16 StripWWW(const string16& text); 206 NET_EXPORT string16 StripWWW(const string16& text);
207 207
208 // Generates a filename using the first successful method from the following (in 208 // Generates a filename using the first successful method from the following (in
209 // order): 209 // order):
210 // 210 //
211 // 1) The raw Content-Disposition header in |content_disposition| (as read from 211 // 1) The raw Content-Disposition header in |content_disposition| (as read from
212 // the network. |referrer_charset| is used as described in the comment for 212 // the network. |default_charset| is used as described in the comment for
213 // GetFileNameFromCD(). 213 // GetFileNameFromCD().
214 // 2) |suggested_name| if specified. |suggested_name| is assumed to be in 214 // 2) |suggested_name| if specified. |suggested_name| is assumed to be in
215 // UTF-8. 215 // UTF-8.
216 // 3) The filename extracted from the |url|. |referrer_charset| will be used to 216 // 3) The filename extracted from the |url|. |default_charset| will be used to
217 // interpret the URL if there are non-ascii characters. 217 // interpret the URL if there are non-ascii characters.
218 // 4) |default_name|. If non-empty, |default_name| is assumed to be a filename 218 // 4) |default_name|. If non-empty, |default_name| is assumed to be a filename
219 // and shouldn't contain a path. |default_name| is not subject to validation 219 // and shouldn't contain a path. |default_name| is not subject to validation
220 // or sanitization, and therefore shouldn't be a user supplied string. 220 // or sanitization, and therefore shouldn't be a user supplied string.
221 // 5) The hostname portion from the |url| 221 // 5) The hostname portion from the |url|
222 // 222 //
223 // Then, leading and trailing '.'s will be removed. On Windows, trailing spaces 223 // Then, leading and trailing '.'s will be removed. On Windows, trailing spaces
224 // are also removed. The string "download" is the final fallback if no filename 224 // are also removed. The string "download" is the final fallback if no filename
225 // is found or the filename is empty. 225 // is found or the filename is empty.
226 // 226 //
227 // Any illegal characters in the filename will be replaced by '-'. If the 227 // Any illegal characters in the filename will be replaced by '-'. If the
228 // filename doesn't contain an extension, and a |mime_type| is specified, the 228 // filename doesn't contain an extension, and a |mime_type| is specified, the
229 // preferred extension for the |mime_type| will be appended to the filename. 229 // preferred extension for the |mime_type| will be appended to the filename.
230 // The resulting filename is then checked against a list of reserved names on 230 // The resulting filename is then checked against a list of reserved names on
231 // Windows. If the name is reserved, an underscore will be prepended to the 231 // Windows. If the name is reserved, an underscore will be prepended to the
232 // filename. 232 // filename.
233 // 233 //
234 // Note: |mime_type| should only be specified if this function is called from a 234 // Note: |mime_type| should only be specified if this function is called from a
235 // thread that allows IO. 235 // thread that allows IO.
236 NET_EXPORT string16 GetSuggestedFilename(const GURL& url, 236 NET_EXPORT string16 GetSuggestedFilename(const GURL& url,
237 const std::string& content_disposition, 237 const std::string& content_disposition,
238 const std::string& referrer_charset, 238 const std::string& default_charset,
239 const std::string& suggested_name, 239 const std::string& suggested_name,
240 const std::string& mime_type, 240 const std::string& mime_type,
241 const std::string& default_name); 241 const std::string& default_name);
242 242
243 // Similar to GetSuggestedFilename(), but returns a FilePath. 243 // Similar to GetSuggestedFilename(), but returns a FilePath.
244 NET_EXPORT FilePath GenerateFileName(const GURL& url, 244 NET_EXPORT FilePath GenerateFileName(const GURL& url,
245 const std::string& content_disposition, 245 const std::string& content_disposition,
246 const std::string& referrer_charset, 246 const std::string& default_charset,
247 const std::string& suggested_name, 247 const std::string& suggested_name,
248 const std::string& mime_type, 248 const std::string& mime_type,
249 const std::string& default_name); 249 const std::string& default_name);
250 250
251 // Ensures that the filename and extension is safe to use in the filesystem. 251 // Ensures that the filename and extension is safe to use in the filesystem.
252 // 252 //
253 // Assumes that |file_path| already contains a valid path or file name. On 253 // Assumes that |file_path| already contains a valid path or file name. On
254 // Windows if the extension causes the file to have an unsafe interaction with 254 // Windows if the extension causes the file to have an unsafe interaction with
255 // the shell (see net_util::IsShellIntegratedExtension()), then it will be 255 // the shell (see net_util::IsShellIntegratedExtension()), then it will be
256 // replaced by the string 'download'. If |file_path| doesn't contain an 256 // replaced by the string 'download'. If |file_path| doesn't contain an
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 467
468 // Returns list of network interfaces except loopback interface. If an 468 // Returns list of network interfaces except loopback interface. If an
469 // interface has more than one address, a separate entry is added to 469 // interface has more than one address, a separate entry is added to
470 // the list for each address. 470 // the list for each address.
471 // Can be called only on a thread that allows IO. 471 // Can be called only on a thread that allows IO.
472 NET_EXPORT bool GetNetworkList(NetworkInterfaceList* networks); 472 NET_EXPORT bool GetNetworkList(NetworkInterfaceList* networks);
473 473
474 } // namespace net 474 } // namespace net
475 475
476 #endif // NET_BASE_NET_UTIL_H_ 476 #endif // NET_BASE_NET_UTIL_H_
OLDNEW
« no previous file with comments | « content/shell/shell_download_manager_delegate.cc ('k') | net/base/net_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698