| 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 // Generate a filename based on the response from the server. Similar | 71 // Generate a filename based on the response from the server. Similar |
| 64 // in operation to net::GenerateFileName(), but uses a localized | 72 // in operation to net::GenerateFileName(), but uses a localized |
| 65 // default name. | 73 // default name. |
| 66 void GenerateFileNameFromRequest(const DownloadItem& download_item, | 74 void GenerateFileNameFromRequest(const DownloadItem& download_item, |
| 67 FilePath* generated_name); | 75 FilePath* generated_name); |
| 68 | 76 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // If |path| does not exist, 0 is returned. If it fails to find such | 266 // If |path| does not exist, 0 is returned. If it fails to find such |
| 259 // a number, -1 is returned. | 267 // a number, -1 is returned. |
| 260 int GetUniquePathNumberWithCrDownload(const FilePath& path); | 268 int GetUniquePathNumberWithCrDownload(const FilePath& path); |
| 261 | 269 |
| 262 // Returns a .crdownload intermediate path for the |suggested_path|. | 270 // Returns a .crdownload intermediate path for the |suggested_path|. |
| 263 FilePath GetCrDownloadPath(const FilePath& suggested_path); | 271 FilePath GetCrDownloadPath(const FilePath& suggested_path); |
| 264 | 272 |
| 265 } // namespace download_util | 273 } // namespace download_util |
| 266 | 274 |
| 267 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 275 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
| OLD | NEW |