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 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "chrome/browser/download/download_process_handle.h" |
16 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
17 | 18 |
18 #if defined(TOOLKIT_VIEWS) | 19 #if defined(TOOLKIT_VIEWS) |
19 #include "views/view.h" | 20 #include "views/view.h" |
20 #endif | 21 #endif |
21 | 22 |
22 namespace gfx { | 23 namespace gfx { |
23 class Canvas; | 24 class Canvas; |
24 class Image; | 25 class Image; |
25 } | 26 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 const GURL& referrer, | 236 const GURL& referrer, |
236 const std::string& referrer_charset, | 237 const std::string& referrer_charset, |
237 const DownloadSaveInfo& save_info, | 238 const DownloadSaveInfo& save_info, |
238 ResourceDispatcherHost* rdh, | 239 ResourceDispatcherHost* rdh, |
239 int render_process_host_id, | 240 int render_process_host_id, |
240 int render_view_id, | 241 int render_view_id, |
241 net::URLRequestContextGetter* request_context_getter); | 242 net::URLRequestContextGetter* request_context_getter); |
242 | 243 |
243 // Tells the resource dispatcher host to cancel a download request. | 244 // Tells the resource dispatcher host to cancel a download request. |
244 // Must be called on the IO thread. | 245 // Must be called on the IO thread. |
| 246 // |process_handle| is passed by value because it is ultimately passed to |
| 247 // other threads, and this way we don't have to worry about object lifetimes. |
245 void CancelDownloadRequest(ResourceDispatcherHost* rdh, | 248 void CancelDownloadRequest(ResourceDispatcherHost* rdh, |
246 int render_process_id, | 249 DownloadProcessHandle process_handle); |
247 int request_id); | |
248 | 250 |
249 // Sends a notification on downloads being initiated | 251 // Sends a notification on downloads being initiated |
250 // Must be called on the UI thread. | 252 // Must be called on the UI thread. |
251 void NotifyDownloadInitiated(int render_process_id, int render_view_id); | 253 void NotifyDownloadInitiated(int render_process_id, int render_view_id); |
252 | 254 |
253 // Same as GetUniquePathNumber, except that it also checks the existence | 255 // Same as GetUniquePathNumber, except that it also checks the existence |
254 // of its .crdownload intermediate path. | 256 // of its .crdownload intermediate path. |
255 // If |path| does not exist, 0 is returned. If it fails to find such | 257 // If |path| does not exist, 0 is returned. If it fails to find such |
256 // a number, -1 is returned. | 258 // a number, -1 is returned. |
257 int GetUniquePathNumberWithCrDownload(const FilePath& path); | 259 int GetUniquePathNumberWithCrDownload(const FilePath& path); |
258 | 260 |
259 // Erases all downloaded files with the specified path and name prefix. | 261 // Erases all downloaded files with the specified path and name prefix. |
260 // Used by download UI tests to clean up the download directory. | 262 // Used by download UI tests to clean up the download directory. |
261 void EraseUniqueDownloadFiles(const FilePath& path_prefix); | 263 void EraseUniqueDownloadFiles(const FilePath& path_prefix); |
262 | 264 |
263 // Returns a .crdownload intermediate path for the |suggested_path|. | 265 // Returns a .crdownload intermediate path for the |suggested_path|. |
264 FilePath GetCrDownloadPath(const FilePath& suggested_path); | 266 FilePath GetCrDownloadPath(const FilePath& suggested_path); |
265 | 267 |
266 // Returns true if this download should show the "dangerous file" warning. | 268 // Returns true if this download should show the "dangerous file" warning. |
267 // Various factors are considered, such as the type of the file, whether a | 269 // Various factors are considered, such as the type of the file, whether a |
268 // user action initiated the download, and whether the user has explictly | 270 // user action initiated the download, and whether the user has explictly |
269 // marked the file type as "auto open". | 271 // marked the file type as "auto open". |
270 bool IsDangerous(DownloadCreateInfo* info, Profile* profile, bool auto_open); | 272 bool IsDangerous(DownloadCreateInfo* info, Profile* profile, bool auto_open); |
271 | 273 |
272 } // namespace download_util | 274 } // namespace download_util |
273 | 275 |
274 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 276 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
OLD | NEW |