| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 // Helper function for download views to use when acting as a drag source for a | 146 // Helper function for download views to use when acting as a drag source for a |
| 147 // DownloadItem. If |icon| is NULL, no image will be accompany the drag. |view| | 147 // DownloadItem. If |icon| is NULL, no image will be accompany the drag. |view| |
| 148 // is only required for Mac OS X, elsewhere it can be NULL. | 148 // is only required for Mac OS X, elsewhere it can be NULL. |
| 149 void DragDownload(const DownloadItem* download, | 149 void DragDownload(const DownloadItem* download, |
| 150 SkBitmap* icon, | 150 SkBitmap* icon, |
| 151 gfx::NativeView view); | 151 gfx::NativeView view); |
| 152 | 152 |
| 153 // Executable file support ----------------------------------------------------- | 153 // Executable file support ----------------------------------------------------- |
| 154 | 154 |
| 155 // Tests if a file is considered executable, based on its type. | 155 enum DownloadDangerLevel { |
| 156 bool IsExecutableFile(const FilePath& path); | 156 NotDangerous, |
| 157 AllowOnUserGesture, |
| 158 Dangerous |
| 159 }; |
| 157 | 160 |
| 158 // Determine if the specified extension is an executable extension. | 161 // Determine the download danger level of a file. |
| 159 bool IsExecutableExtension(const FilePath::StringType& extension); | 162 DownloadDangerLevel GetFileDangerLevel(const FilePath& path); |
| 163 |
| 164 // Determine the download danger level using a file extension. |
| 165 DownloadDangerLevel GetFileExtensionDangerLevel( |
| 166 const FilePath::StringType& extension); |
| 167 |
| 168 // True if the download danger level of the file is NotDangerous. |
| 169 bool IsFileSafe(const FilePath& path); |
| 170 |
| 171 // True if the download danger level of the extension is NotDangerous. |
| 172 bool IsFileExtensionSafe(const FilePath::StringType& extension); |
| 160 | 173 |
| 161 // Tests if we think the server means for this mime_type to be executable. | 174 // Tests if we think the server means for this mime_type to be executable. |
| 162 bool IsExecutableMimeType(const std::string& mime_type); | 175 bool IsExecutableMimeType(const std::string& mime_type); |
| 163 | 176 |
| 164 // Helpers --------------------------------------------------------------------- | 177 // Helpers --------------------------------------------------------------------- |
| 165 | 178 |
| 166 // Creates a representation of a download in a format that the downloads | 179 // Creates a representation of a download in a format that the downloads |
| 167 // HTML page can understand. | 180 // HTML page can understand. |
| 168 DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id); | 181 DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id); |
| 169 | 182 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 229 |
| 217 // Returns a .crdownload intermediate path for the |suggested_path|. | 230 // Returns a .crdownload intermediate path for the |suggested_path|. |
| 218 FilePath GetCrDownloadPath(const FilePath& suggested_path); | 231 FilePath GetCrDownloadPath(const FilePath& suggested_path); |
| 219 | 232 |
| 220 // Whether a given download should be considered potentially dangerous. | 233 // Whether a given download should be considered potentially dangerous. |
| 221 bool IsDangerous(DownloadCreateInfo *info, Profile* profile); | 234 bool IsDangerous(DownloadCreateInfo *info, Profile* profile); |
| 222 | 235 |
| 223 } // namespace download_util | 236 } // namespace download_util |
| 224 | 237 |
| 225 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 238 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
| OLD | NEW |