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 // Each download is represented by a DownloadItem, and all DownloadItems | 5 // Each download is represented by a DownloadItem, and all DownloadItems |
6 // are owned by the DownloadManager which maintains a global list of all | 6 // are owned by the DownloadManager which maintains a global list of all |
7 // downloads. DownloadItems are created when a user initiates a download, | 7 // downloads. DownloadItems are created when a user initiates a download, |
8 // and exist for the duration of the browser life time. | 8 // and exist for the duration of the browser life time. |
9 // | 9 // |
10 // Download observers: | 10 // Download observers: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 // Registers this file extension for automatic opening upon download | 99 // Registers this file extension for automatic opening upon download |
100 // completion if 'open' is true, or prevents the extension from automatic | 100 // completion if 'open' is true, or prevents the extension from automatic |
101 // opening if 'open' is false. | 101 // opening if 'open' is false. |
102 void OpenFilesBasedOnExtension(bool open); | 102 void OpenFilesBasedOnExtension(bool open); |
103 | 103 |
104 // Open the file associated with this download (wait for the download to | 104 // Open the file associated with this download (wait for the download to |
105 // complete if it is in progress). | 105 // complete if it is in progress). |
106 void OpenDownload(); | 106 void OpenDownload(); |
107 | 107 |
| 108 // Callback from the DownloadManager when the item is opened. Sets opened_ |
| 109 // to true and notifies observers. |
| 110 void Opened(); |
| 111 |
108 // Show the download via the OS shell. | 112 // Show the download via the OS shell. |
109 void ShowDownloadInShell(); | 113 void ShowDownloadInShell(); |
110 | 114 |
111 // Called when the user has validated the download of a dangerous file. | 115 // Called when the user has validated the download of a dangerous file. |
112 void DangerousDownloadValidated(); | 116 void DangerousDownloadValidated(); |
113 | 117 |
114 // Received a new chunk of data | 118 // Received a new chunk of data |
115 void Update(int64 bytes_so_far); | 119 void Update(int64 bytes_so_far); |
116 | 120 |
117 // Cancel the download operation. We need to distinguish between cancels at | 121 // Cancel the download operation. We need to distinguish between cancels at |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 FilePath original_name() const { return original_name_; } | 191 FilePath original_name() const { return original_name_; } |
188 bool save_as() const { return save_as_; } | 192 bool save_as() const { return save_as_; } |
189 bool is_otr() const { return is_otr_; } | 193 bool is_otr() const { return is_otr_; } |
190 bool is_extension_install() const { return is_extension_install_; } | 194 bool is_extension_install() const { return is_extension_install_; } |
191 bool name_finalized() const { return name_finalized_; } | 195 bool name_finalized() const { return name_finalized_; } |
192 bool is_temporary() const { return is_temporary_; } | 196 bool is_temporary() const { return is_temporary_; } |
193 bool need_final_rename() const { return need_final_rename_; } | 197 bool need_final_rename() const { return need_final_rename_; } |
194 void set_need_final_rename(bool need_final_rename) { | 198 void set_need_final_rename(bool need_final_rename) { |
195 need_final_rename_ = need_final_rename; | 199 need_final_rename_ = need_final_rename; |
196 } | 200 } |
| 201 void set_opened(bool opened) { opened_ = opened; } |
| 202 bool opened() const { return opened_; } |
197 | 203 |
198 // Returns the file-name that should be reported to the user, which is | 204 // Returns the file-name that should be reported to the user, which is |
199 // file_name_ for safe downloads and original_name_ for dangerous ones with | 205 // file_name_ for safe downloads and original_name_ for dangerous ones with |
200 // the uniquifier number. | 206 // the uniquifier number. |
201 FilePath GetFileName() const; | 207 FilePath GetFileName() const; |
202 | 208 |
203 private: | 209 private: |
204 void Init(bool start_timer); | 210 void Init(bool start_timer); |
205 | 211 |
206 // Internal helper for maintaining consistent received and total sizes. | 212 // Internal helper for maintaining consistent received and total sizes. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 303 |
298 // True if the filename is finalized. | 304 // True if the filename is finalized. |
299 bool name_finalized_; | 305 bool name_finalized_; |
300 | 306 |
301 // True if the item was downloaded temporarily. | 307 // True if the item was downloaded temporarily. |
302 bool is_temporary_; | 308 bool is_temporary_; |
303 | 309 |
304 // True if the file needs final rename. | 310 // True if the file needs final rename. |
305 bool need_final_rename_; | 311 bool need_final_rename_; |
306 | 312 |
| 313 // Did the user open the item either directly or indirectly (such as by |
| 314 // setting always open files of this type)? The shelf also sets this field |
| 315 // when the user closes the shelf before the item has been opened but should |
| 316 // be treated as though the user opened it. |
| 317 bool opened_; |
| 318 |
307 DISALLOW_COPY_AND_ASSIGN(DownloadItem); | 319 DISALLOW_COPY_AND_ASSIGN(DownloadItem); |
308 }; | 320 }; |
309 | 321 |
310 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ | 322 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ |
OLD | NEW |