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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 namespace gfx { | 44 namespace gfx { |
45 class Canvas; | 45 class Canvas; |
46 class Image; | 46 class Image; |
47 } | 47 } |
48 | 48 |
49 namespace download_util { | 49 namespace download_util { |
50 | 50 |
51 // Download temporary file creation -------------------------------------------- | 51 // Download temporary file creation -------------------------------------------- |
52 | 52 |
53 // Return the default download directory. | 53 // Chooses a writable directory from |website_save_dir|, |download_save_dir| |
54 const FilePath& GetDefaultDownloadDirectory(); | 54 // and |default_download_dir| in this order of priority. |
| 55 // If none of them is writable, creates |download_save_dir| and |
| 56 // chooses |download_save_dir|. The choosed directory is stored to |save_dir|. |
| 57 // Returns true if neither |website_save_dir| nor |download_save_dir| |
| 58 // is writable, which indicates the select file dialog should be displayed. |
| 59 bool ChooseSavableDirectory(const FilePath& website_save_dir, |
| 60 const FilePath& download_save_dir, |
| 61 const FilePath& default_download_dir, |
| 62 FilePath* save_dir); |
55 | 63 |
56 // Create a temporary file for a download in the user's default download | 64 // Returns the user's default "Downloads" folder provided by PathService. |
57 // directory and return true if was successful in creating the file. | 65 // This method returns the folder provided by PathService. |
58 bool CreateTemporaryFileForDownload(FilePath* path); | 66 FilePath GetDefaultDownloadDirectoryFromPathService(); |
59 | 67 |
60 // Return true if the |download_path| is dangerous path. | 68 // Return true if the |download_path| is dangerous path. |
61 bool DownloadPathIsDangerous(const FilePath& download_path); | 69 bool DownloadPathIsDangerous(const FilePath& download_path); |
62 | 70 |
63 // Create an extension based on the file name and mime type. | 71 // Create an extension based on the file name and mime type. |
64 void GenerateExtension(const FilePath& file_name, | 72 void GenerateExtension(const FilePath& file_name, |
65 const std::string& mime_type, | 73 const std::string& mime_type, |
66 FilePath::StringType* generated_extension); | 74 FilePath::StringType* generated_extension); |
67 | 75 |
68 // Create a file name based on the response from the server. | 76 // Create a file name based on the response from the server. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // Erases all downloaded files with the specified path and name prefix. | 278 // Erases all downloaded files with the specified path and name prefix. |
271 // Used by download UI tests to clean up the download directory. | 279 // Used by download UI tests to clean up the download directory. |
272 void EraseUniqueDownloadFiles(const FilePath& path_prefix); | 280 void EraseUniqueDownloadFiles(const FilePath& path_prefix); |
273 | 281 |
274 // Returns a .crdownload intermediate path for the |suggested_path|. | 282 // Returns a .crdownload intermediate path for the |suggested_path|. |
275 FilePath GetCrDownloadPath(const FilePath& suggested_path); | 283 FilePath GetCrDownloadPath(const FilePath& suggested_path); |
276 | 284 |
277 } // namespace download_util | 285 } // namespace download_util |
278 | 286 |
279 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 287 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
OLD | NEW |