Chromium Code Reviews| 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 "net/base/filename_util.h" | 5 #include "net/base/filename_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 HttpContentDisposition header(content_disposition, referrer_charset); | 238 HttpContentDisposition header(content_disposition, referrer_charset); |
| 239 filename = header.filename(); | 239 filename = header.filename(); |
| 240 if (!filename.empty()) | 240 if (!filename.empty()) |
| 241 is_name_from_content_disposition = true; | 241 is_name_from_content_disposition = true; |
| 242 } | 242 } |
| 243 | 243 |
| 244 // Then try to use the suggested name. | 244 // Then try to use the suggested name. |
| 245 if (filename.empty() && !suggested_name.empty()) | 245 if (filename.empty() && !suggested_name.empty()) |
| 246 filename = suggested_name; | 246 filename = suggested_name; |
| 247 | 247 |
| 248 if (filename.empty() && mime_type == "application/x-x509-user-cert") | |
| 249 filename = "user.crt"; | |
|
asanka
2016/01/11 21:16:34
Let's move this logic to DownloadTargetDeterminer
svaldez
2016/01/11 21:34:55
Done.
| |
| 250 | |
| 248 // Now try extracting the filename from the URL. GetFileNameFromURL() only | 251 // Now try extracting the filename from the URL. GetFileNameFromURL() only |
| 249 // looks at the last component of the URL and doesn't return the hostname as a | 252 // looks at the last component of the URL and doesn't return the hostname as a |
| 250 // failover. | 253 // failover. |
| 251 if (filename.empty()) | 254 if (filename.empty()) |
| 252 filename = GetFileNameFromURL(url, referrer_charset, &overwrite_extension); | 255 filename = GetFileNameFromURL(url, referrer_charset, &overwrite_extension); |
| 253 | 256 |
| 254 // Finally try the URL hostname, but only if there's no default specified in | 257 // Finally try the URL hostname, but only if there's no default specified in |
| 255 // |default_name|. Some schemes (e.g.: file:, about:, data:) do not have a | 258 // |default_name|. Some schemes (e.g.: file:, about:, data:) do not have a |
| 256 // host name. | 259 // host name. |
| 257 if (filename.empty() && default_name.empty() && url.is_valid() && | 260 if (filename.empty() && default_name.empty() && url.is_valid() && |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 base::FilePath generated_name( | 325 base::FilePath generated_name( |
| 323 base::SysWideToNativeMB(base::UTF16ToWide(file_name))); | 326 base::SysWideToNativeMB(base::UTF16ToWide(file_name))); |
| 324 #endif | 327 #endif |
| 325 | 328 |
| 326 DCHECK(!generated_name.empty()); | 329 DCHECK(!generated_name.empty()); |
| 327 | 330 |
| 328 return generated_name; | 331 return generated_name; |
| 329 } | 332 } |
| 330 | 333 |
| 331 } // namespace net | 334 } // namespace net |
| OLD | NEW |