| 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 // Chooses a writable directory from |website_save_dir|, |download_save_dir| | 53 // Return the default download directory. |
| 54 // and |default_download_dir| in this order of priority. | 54 const FilePath& GetDefaultDownloadDirectory(); |
| 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); | |
| 63 | 55 |
| 64 // Returns the user's default "Downloads" folder provided by PathService. | 56 // Create a temporary file for a download in the user's default download |
| 65 // This method returns the folder provided by PathService. | 57 // directory and return true if was successful in creating the file. |
| 66 FilePath GetDefaultDownloadDirectoryFromPathService(); | 58 bool CreateTemporaryFileForDownload(FilePath* path); |
| 67 | 59 |
| 68 // Return true if the |download_path| is dangerous path. | 60 // Return true if the |download_path| is dangerous path. |
| 69 bool DownloadPathIsDangerous(const FilePath& download_path); | 61 bool DownloadPathIsDangerous(const FilePath& download_path); |
| 70 | 62 |
| 71 // Create an extension based on the file name and mime type. | 63 // Create an extension based on the file name and mime type. |
| 72 void GenerateExtension(const FilePath& file_name, | 64 void GenerateExtension(const FilePath& file_name, |
| 73 const std::string& mime_type, | 65 const std::string& mime_type, |
| 74 FilePath::StringType* generated_extension); | 66 FilePath::StringType* generated_extension); |
| 75 | 67 |
| 76 // Create a file name based on the response from the server. | 68 // Create a file name based on the response from the server. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 // Erases all downloaded files with the specified path and name prefix. | 273 // Erases all downloaded files with the specified path and name prefix. |
| 282 // Used by download UI tests to clean up the download directory. | 274 // Used by download UI tests to clean up the download directory. |
| 283 void EraseUniqueDownloadFiles(const FilePath& path_prefix); | 275 void EraseUniqueDownloadFiles(const FilePath& path_prefix); |
| 284 | 276 |
| 285 // Returns a .crdownload intermediate path for the |suggested_path|. | 277 // Returns a .crdownload intermediate path for the |suggested_path|. |
| 286 FilePath GetCrDownloadPath(const FilePath& suggested_path); | 278 FilePath GetCrDownloadPath(const FilePath& suggested_path); |
| 287 | 279 |
| 288 } // namespace download_util | 280 } // namespace download_util |
| 289 | 281 |
| 290 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 282 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
| OLD | NEW |