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 // The DownloadManager object manages the process of downloading, including | 5 // The DownloadManager object manages the process of downloading, including |
6 // updates to the history system and providing the information for displaying | 6 // updates to the history system and providing the information for displaying |
7 // the downloads view in the Destinations tab. There is one DownloadManager per | 7 // the downloads view in the Destinations tab. There is one DownloadManager per |
8 // active profile in Chrome. | 8 // active profile in Chrome. |
9 // | 9 // |
10 // Download observers: | 10 // Download observers: |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Display a new download in the appropriate browser UI. | 197 // Display a new download in the appropriate browser UI. |
198 void ShowDownloadInBrowser(DownloadItem* download); | 198 void ShowDownloadInBrowser(DownloadItem* download); |
199 | 199 |
200 // The number of in progress (including paused) downloads. | 200 // The number of in progress (including paused) downloads. |
201 int in_progress_count() const { | 201 int in_progress_count() const { |
202 return static_cast<int>(in_progress_.size()); | 202 return static_cast<int>(in_progress_.size()); |
203 } | 203 } |
204 | 204 |
205 Profile* profile() { return profile_; } | 205 Profile* profile() { return profile_; } |
206 | 206 |
207 DownloadHistory* download_history() { return download_history_.get(); } | |
208 | |
209 DownloadPrefs* download_prefs() { return download_prefs_.get(); } | 207 DownloadPrefs* download_prefs() { return download_prefs_.get(); } |
210 | 208 |
211 // Creates the download item. Must be called on the UI thread. | 209 // Creates the download item. Must be called on the UI thread. |
212 void CreateDownloadItem(DownloadCreateInfo* info); | 210 void CreateDownloadItem(DownloadCreateInfo* info); |
213 | 211 |
214 // Clears the last download path, used to initialize "save as" dialogs. | 212 // Clears the last download path, used to initialize "save as" dialogs. |
215 void ClearLastDownloadPath(); | 213 void ClearLastDownloadPath(); |
216 | 214 |
217 // Tests if a file type should be opened automatically. | 215 // Tests if a file type should be opened automatically. |
218 bool ShouldOpenFileBasedOnExtension(const FilePath& path) const; | 216 bool ShouldOpenFileBasedOnExtension(const FilePath& path) const; |
219 | 217 |
220 // Overridden from DownloadStatusUpdaterDelegate: | 218 // Overridden from DownloadStatusUpdaterDelegate: |
221 virtual bool IsDownloadProgressKnown(); | 219 virtual bool IsDownloadProgressKnown(); |
222 virtual int64 GetInProgressDownloadCount(); | 220 virtual int64 GetInProgressDownloadCount(); |
223 virtual int64 GetReceivedDownloadBytes(); | 221 virtual int64 GetReceivedDownloadBytes(); |
224 virtual int64 GetTotalDownloadBytes(); | 222 virtual int64 GetTotalDownloadBytes(); |
225 | 223 |
226 // Overridden from SelectFileDialog::Listener: | 224 // Overridden from SelectFileDialog::Listener: |
227 virtual void FileSelected(const FilePath& path, int index, void* params); | 225 virtual void FileSelected(const FilePath& path, int index, void* params); |
228 virtual void FileSelectionCanceled(void* params); | 226 virtual void FileSelectionCanceled(void* params); |
229 | 227 |
230 // Returns true if this download should show the "dangerous file" warning. | 228 // Returns true if this download should show the "dangerous file" warning. |
231 // Various factors are considered, such as the type of the file, whether a | 229 // Various factors are considered, such as the type of the file, whether a |
232 // user action initiated the download, and whether the user has explicitly | 230 // user action initiated the download, and whether the user has explicitly |
233 // marked the file type as "auto open". | 231 // marked the file type as "auto open". |
234 bool IsDangerous(const DownloadItem& download, | 232 bool IsDangerous(const DownloadItem& download, |
235 const DownloadStateInfo& state); | 233 const DownloadStateInfo& state, |
| 234 bool visited_referrer_before); |
236 | 235 |
237 // Called when the user has validated the download of a dangerous file. | 236 // Called when the user has validated the download of a dangerous file. |
238 void DangerousDownloadValidated(DownloadItem* download); | 237 void DangerousDownloadValidated(DownloadItem* download); |
239 | 238 |
240 // Callback function after url is checked with safebrowsing service. | 239 // Callback function after url is checked with safebrowsing service. |
241 void CheckDownloadUrlDone(int32 download_id, bool is_dangerous_url); | 240 void CheckDownloadUrlDone(int32 download_id, bool is_dangerous_url); |
242 | 241 |
| 242 // Callback function after we check whether the referrer URL has been visited |
| 243 // before today. |
| 244 void CheckVisitedReferrerBeforeDone(int32 download_id, |
| 245 bool visited_referrer_before); |
| 246 |
243 // Callback function after download file hash is checked with safebrowsing | 247 // Callback function after download file hash is checked with safebrowsing |
244 // service. | 248 // service. |
245 void CheckDownloadHashDone(int32 download_id, bool is_dangerous_hash); | 249 void CheckDownloadHashDone(int32 download_id, bool is_dangerous_hash); |
246 | 250 |
247 private: | 251 private: |
248 // For testing. | 252 // For testing. |
249 friend class DownloadManagerTest; | 253 friend class DownloadManagerTest; |
250 friend class MockDownloadManager; | 254 friend class MockDownloadManager; |
251 | 255 |
252 // This class is used to let an incognito DownloadManager observe changes to | 256 // This class is used to let an incognito DownloadManager observe changes to |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // The "Save As" dialog box used to ask the user where a file should be | 411 // The "Save As" dialog box used to ask the user where a file should be |
408 // saved. | 412 // saved. |
409 scoped_refptr<SelectFileDialog> select_file_dialog_; | 413 scoped_refptr<SelectFileDialog> select_file_dialog_; |
410 | 414 |
411 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; | 415 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; |
412 | 416 |
413 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 417 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
414 }; | 418 }; |
415 | 419 |
416 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 420 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
OLD | NEW |