OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download utilities. | 5 // Download utilities. |
6 | 6 |
7 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 7 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
8 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 8 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Return true if the |download_path| is dangerous path. | 55 // Return true if the |download_path| is dangerous path. |
56 bool DownloadPathIsDangerous(const FilePath& download_path); | 56 bool DownloadPathIsDangerous(const FilePath& download_path); |
57 | 57 |
58 // Create an extension based on the file name and mime type. | 58 // Create an extension based on the file name and mime type. |
59 void GenerateExtension(const FilePath& file_name, | 59 void GenerateExtension(const FilePath& file_name, |
60 const std::string& mime_type, | 60 const std::string& mime_type, |
61 FilePath::StringType* generated_extension); | 61 FilePath::StringType* generated_extension); |
62 | 62 |
63 // Create a file name based on the response from the server. | 63 // Create a file name based on the response from the server. |
64 void GenerateFileNameFromInfo(DownloadCreateInfo* info, | 64 void GenerateFileNameFromRequest(const GURL& url, |
65 FilePath* generated_name); | 65 const std::string& content_disposition, |
| 66 const std::string& referrer_charset, |
| 67 const std::string& mime_type, |
| 68 FilePath* generated_name); |
66 | 69 |
67 void GenerateFileNameFromSuggestedName(const GURL& url, | 70 void GenerateFileNameFromSuggestedName(const GURL& url, |
68 const std::string& suggested_name, | 71 const std::string& suggested_name, |
69 const std::string& mime_type, | 72 const std::string& mime_type, |
70 FilePath* generated_name); | 73 FilePath* generated_name); |
71 | 74 |
72 void GenerateFileName(const GURL& url, | 75 void GenerateFileName(const GURL& url, |
73 const std::string& content_disposition, | 76 const std::string& content_disposition, |
74 const std::string& referrer_charset, | 77 const std::string& referrer_charset, |
75 const std::string& mime_type, | 78 const std::string& mime_type, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 // a number, -1 is returned. | 265 // a number, -1 is returned. |
263 int GetUniquePathNumberWithCrDownload(const FilePath& path); | 266 int GetUniquePathNumberWithCrDownload(const FilePath& path); |
264 | 267 |
265 // Erases all downloaded files with the specified path and name prefix. | 268 // Erases all downloaded files with the specified path and name prefix. |
266 // Used by download UI tests to clean up the download directory. | 269 // Used by download UI tests to clean up the download directory. |
267 void EraseUniqueDownloadFiles(const FilePath& path_prefix); | 270 void EraseUniqueDownloadFiles(const FilePath& path_prefix); |
268 | 271 |
269 // Returns a .crdownload intermediate path for the |suggested_path|. | 272 // Returns a .crdownload intermediate path for the |suggested_path|. |
270 FilePath GetCrDownloadPath(const FilePath& suggested_path); | 273 FilePath GetCrDownloadPath(const FilePath& suggested_path); |
271 | 274 |
272 // Returns true if this download should show the "dangerous file" warning. | |
273 // Various factors are considered, such as the type of the file, whether a | |
274 // user action initiated the download, and whether the user has explictly | |
275 // marked the file type as "auto open". | |
276 bool IsDangerous(DownloadCreateInfo* info, Profile* profile, bool auto_open); | |
277 | |
278 } // namespace download_util | 275 } // namespace download_util |
279 | 276 |
280 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 277 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
OLD | NEW |