OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/file_path.h" |
| 14 #include "base/time.h" |
| 15 #include "chrome/browser/download/download_file.h" |
| 16 #include "chrome/browser/download/download_process_handle.h" |
| 17 #include "googleurl/src/gurl.h" |
| 18 |
| 19 // Used for informing the download manager of a new download, since we don't |
| 20 // want to pass |DownloadItem|s between threads. |
| 21 struct DownloadCreateInfo { |
| 22 DownloadCreateInfo(const FilePath& path, |
| 23 const GURL& url, |
| 24 const base::Time& start_time, |
| 25 int64 received_bytes, |
| 26 int64 total_bytes, |
| 27 int32 state, |
| 28 int32 download_id, |
| 29 bool has_user_gesture); |
| 30 DownloadCreateInfo(); |
| 31 ~DownloadCreateInfo(); |
| 32 |
| 33 std::string DebugString() const; |
| 34 |
| 35 // The URL from which we are downloading. This is the final URL after any |
| 36 // redirection by the server for |url_chain|. |
| 37 const GURL& url() const; |
| 38 |
| 39 // DownloadItem fields |
| 40 // The path where we want to save the download file. |
| 41 FilePath path; |
| 42 |
| 43 // The chain of redirects that leading up to and including the final URL. |
| 44 std::vector<GURL> url_chain; |
| 45 |
| 46 // The URL that referred us. |
| 47 GURL referrer_url; |
| 48 |
| 49 // The default path for the download (may be overridden). |
| 50 FilePath suggested_path; |
| 51 |
| 52 // A number that should be added to the suggested path to make it unique. |
| 53 // 0 means no number should be appended. Not actually stored in the db. |
| 54 int path_uniquifier; |
| 55 |
| 56 // The time when the download started. |
| 57 base::Time start_time; |
| 58 |
| 59 // The number of bytes that have been received. |
| 60 int64 received_bytes; |
| 61 |
| 62 // The total download size. |
| 63 int64 total_bytes; |
| 64 |
| 65 // The current state of the download. |
| 66 int32 state; |
| 67 |
| 68 // The (per-session) ID of the download. |
| 69 int32 download_id; |
| 70 |
| 71 // True if the download was initiated by user action. |
| 72 bool has_user_gesture; |
| 73 |
| 74 // The handle to the process information. Used for operations outside the |
| 75 // download system. |
| 76 DownloadProcessHandle process_handle; |
| 77 |
| 78 // The handle of the download in the history database. |
| 79 int64 db_handle; |
| 80 |
| 81 // The content-disposition string from the response header. |
| 82 std::string content_disposition; |
| 83 |
| 84 // The mime type string from the response header (may be overridden). |
| 85 std::string mime_type; |
| 86 |
| 87 // The value of the content type header sent with the downloaded item. It |
| 88 // may be different from |mime_type|, which may be set based on heuristics |
| 89 // which may look at the file extension and first few bytes of the file. |
| 90 std::string original_mime_type; |
| 91 |
| 92 // True if we should display the 'save as...' UI and prompt the user |
| 93 // for the download location. |
| 94 // False if the UI should be supressed and the download performed to the |
| 95 // default location. |
| 96 bool prompt_user_for_save_location; |
| 97 |
| 98 // Whether this download file is potentially dangerous (ex: exe, dll, ...). |
| 99 bool is_dangerous_file; |
| 100 |
| 101 // If safebrowsing believes this URL leads to malware. |
| 102 bool is_dangerous_url; |
| 103 |
| 104 // The original name for a dangerous download. |
| 105 FilePath original_name; |
| 106 |
| 107 // Whether this download is for extension install or not. |
| 108 bool is_extension_install; |
| 109 |
| 110 // The charset of the referring page where the download request comes from. |
| 111 // It's used to construct a suggested filename. |
| 112 std::string referrer_charset; |
| 113 |
| 114 // The download file save info. |
| 115 DownloadSaveInfo save_info; |
| 116 }; |
| 117 |
| 118 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_ |
OLD | NEW |