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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 namespace gfx { | 45 namespace gfx { |
46 class Canvas; | 46 class Canvas; |
47 class Image; | 47 class Image; |
48 } | 48 } |
49 | 49 |
50 namespace download_util { | 50 namespace download_util { |
51 | 51 |
52 // Download temporary file creation -------------------------------------------- | 52 // Download temporary file creation -------------------------------------------- |
53 | 53 |
54 // Return the default download directory. | 54 class DefaultDownloadDirectory { |
55 const FilePath& GetDefaultDownloadDirectory(); | 55 public: |
| 56 // Returns the path of the default download folder. |
| 57 // If the path is being overridden, returns the overridden path. |
| 58 static bool Get(FilePath* path); |
| 59 |
| 60 // Overrides the path of the default download folder. |
| 61 // WARNING: We can use this method only on testing context (e.g. download |
| 62 // tests) for temporarily switching the default download folder. |
| 63 // WARNING: In order to override the path, we must use |
| 64 // this method instead of using PathService::Override(), |
| 65 // since PathService::Override() can cause many problems: |
| 66 // http://codereview.chromium.org/2805100 |
| 67 static void Override(const FilePath& override_path); |
| 68 |
| 69 // Invalidate the overriding of the default download folder. |
| 70 static void UnOverride(); |
| 71 |
| 72 private: |
| 73 static FilePath override_path_; |
| 74 }; |
56 | 75 |
57 // Create a temporary file for a download in the user's default download | 76 // Create a temporary file for a download in the user's default download |
58 // directory and return true if was successful in creating the file. | 77 // directory and return true if was successful in creating the file. |
59 bool CreateTemporaryFileForDownload(FilePath* path); | 78 bool CreateTemporaryFileForDownload(FilePath* path); |
60 | 79 |
61 // Return true if the |download_path| is dangerous path. | 80 // Return true if the |download_path| is dangerous path. |
62 bool DownloadPathIsDangerous(const FilePath& download_path); | 81 bool DownloadPathIsDangerous(const FilePath& download_path); |
63 | 82 |
64 // Create an extension based on the file name and mime type. | 83 // Create an extension based on the file name and mime type. |
65 void GenerateExtension(const FilePath& file_name, | 84 void GenerateExtension(const FilePath& file_name, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // Erases all downloaded files with the specified path and name prefix. | 308 // Erases all downloaded files with the specified path and name prefix. |
290 // Used by download UI tests to clean up the download directory. | 309 // Used by download UI tests to clean up the download directory. |
291 void EraseUniqueDownloadFiles(const FilePath& path_prefix); | 310 void EraseUniqueDownloadFiles(const FilePath& path_prefix); |
292 | 311 |
293 // Returns a .crdownload intermediate path for the |suggested_path|. | 312 // Returns a .crdownload intermediate path for the |suggested_path|. |
294 FilePath GetCrDownloadPath(const FilePath& suggested_path); | 313 FilePath GetCrDownloadPath(const FilePath& suggested_path); |
295 | 314 |
296 } // namespace download_util | 315 } // namespace download_util |
297 | 316 |
298 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 317 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
OLD | NEW |