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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 // of downloads. | 79 // of downloads. |
80 virtual void ModelChanged() = 0; | 80 virtual void ModelChanged() = 0; |
81 | 81 |
82 // Called when the DownloadManager is being destroyed to prevent Observers | 82 // Called when the DownloadManager is being destroyed to prevent Observers |
83 // from calling back to a stale pointer. | 83 // from calling back to a stale pointer. |
84 virtual void ManagerGoingDown() {} | 84 virtual void ManagerGoingDown() {} |
85 | 85 |
86 // Called immediately after the DownloadManager puts up a select file | 86 // Called immediately after the DownloadManager puts up a select file |
87 // dialog. | 87 // dialog. |
88 // |id| indicates which download opened the dialog. | 88 // |id| indicates which download opened the dialog. |
89 virtual void SelectFileDialogDisplayed(int32 id) {} | 89 // |suggested_path| indicates the path suggested in the dialog. |
90 virtual void SelectFileDialogDisplayed( | |
91 int32 id, const FilePath& suggested_path) {} | |
90 | 92 |
91 protected: | 93 protected: |
92 virtual ~Observer() {} | 94 virtual ~Observer() {} |
93 }; | 95 }; |
94 | 96 |
95 // Return all temporary downloads that reside in the specified directory. | 97 // Return all temporary downloads that reside in the specified directory. |
96 void GetTemporaryDownloads(const FilePath& dir_path, | 98 void GetTemporaryDownloads(const FilePath& dir_path, |
97 std::vector<DownloadItem*>* result); | 99 std::vector<DownloadItem*>* result); |
98 | 100 |
99 // Return all non-temporary downloads in the specified directory that are | 101 // Return all non-temporary downloads in the specified directory that are |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 bool visited_referrer_before); | 246 bool visited_referrer_before); |
245 | 247 |
246 // Callback function after download file hash is checked with safebrowsing | 248 // Callback function after download file hash is checked with safebrowsing |
247 // service. | 249 // service. |
248 void CheckDownloadHashDone(int32 download_id, bool is_dangerous_hash); | 250 void CheckDownloadHashDone(int32 download_id, bool is_dangerous_hash); |
249 | 251 |
250 // Assert the named download item is in no queues in the DownloadManager. | 252 // Assert the named download item is in no queues in the DownloadManager. |
251 // For debugging. | 253 // For debugging. |
252 void AssertNotInQueues(DownloadItem* download); | 254 void AssertNotInQueues(DownloadItem* download); |
253 | 255 |
256 // Chooses a writable directory from |website_save_dir|, |download_save_dir| | |
257 // and |default_download_dir| in this order of priority. | |
258 // If none of them is writable, creates |download_save_dir| and | |
259 // chooses |download_save_dir|. The choosed directory is stored to |save_dir|. | |
260 // Returns true if neither |website_save_dir| nor |download_save_dir| | |
261 // is writable, which indicates the select file dialog should be displayed. | |
262 static bool ChooseSavableDirectory(const FilePath& website_save_dir, | |
Paweł Hajdan Jr.
2011/06/15 09:31:33
Let's avoid having static methods in DownloadManag
haraken1
2011/06/15 10:39:45
Actually, I also prefer download_util.cc to downlo
Randy Smith (Not in Mondays)
2011/06/15 19:48:59
Pawel: Why do you prefer not to have static method
Paweł Hajdan Jr.
2011/06/16 17:41:31
No, actually I'm fine with static methods per se.
haraken1
2011/06/22 18:01:58
Randy:
| |
263 const FilePath& download_save_dir, | |
264 const FilePath& default_download_dir, | |
265 FilePath* save_dir); | |
266 | |
254 private: | 267 private: |
255 // For testing. | 268 // For testing. |
256 friend class DownloadManagerTest; | 269 friend class DownloadManagerTest; |
257 friend class MockDownloadManager; | 270 friend class MockDownloadManager; |
258 | 271 |
259 // This class is used to let an incognito DownloadManager observe changes to | 272 // This class is used to let an incognito DownloadManager observe changes to |
260 // a normal DownloadManager, to propagate ModelChanged() calls from the parent | 273 // a normal DownloadManager, to propagate ModelChanged() calls from the parent |
261 // DownloadManager to the observers of the incognito DownloadManager. | 274 // DownloadManager to the observers of the incognito DownloadManager. |
262 class OtherDownloadManagerObserver : public Observer { | 275 class OtherDownloadManagerObserver : public Observer { |
263 public: | 276 public: |
(...skipping 17 matching lines...) Expand all Loading... | |
281 friend class DeleteTask<DownloadManager>; | 294 friend class DeleteTask<DownloadManager>; |
282 friend class OtherDownloadManagerObserver; | 295 friend class OtherDownloadManagerObserver; |
283 | 296 |
284 virtual ~DownloadManager(); | 297 virtual ~DownloadManager(); |
285 | 298 |
286 // Called on the download thread to check whether the suggested file path | 299 // Called on the download thread to check whether the suggested file path |
287 // exists. We don't check if the file exists on the UI thread to avoid UI | 300 // exists. We don't check if the file exists on the UI thread to avoid UI |
288 // stalls from interacting with the file system. | 301 // stalls from interacting with the file system. |
289 void CheckIfSuggestedPathExists(int32 download_id, | 302 void CheckIfSuggestedPathExists(int32 download_id, |
290 DownloadStateInfo state, | 303 DownloadStateInfo state, |
291 const FilePath& default_path); | 304 const FilePath& download_save_dir, |
305 const FilePath& default_download_dir); | |
292 | 306 |
293 // Called on the UI thread once the DownloadManager has determined whether the | 307 // Called on the UI thread once the DownloadManager has determined whether the |
294 // suggested file path exists. | 308 // suggested file path exists. |
295 void OnPathExistenceAvailable(int32 download_id, | 309 void OnPathExistenceAvailable(int32 download_id, |
296 DownloadStateInfo new_state); | 310 DownloadStateInfo new_state); |
297 | 311 |
298 // Called back after a target path for the file to be downloaded to has been | 312 // Called back after a target path for the file to be downloaded to has been |
299 // determined, either automatically based on the suggested file name, or by | 313 // determined, either automatically based on the suggested file name, or by |
300 // the user in a Save As dialog box. | 314 // the user in a Save As dialog box. |
301 void ContinueDownloadWithPath(DownloadItem* download, | 315 void ContinueDownloadWithPath(DownloadItem* download, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 // The "Save As" dialog box used to ask the user where a file should be | 420 // The "Save As" dialog box used to ask the user where a file should be |
407 // saved. | 421 // saved. |
408 scoped_refptr<SelectFileDialog> select_file_dialog_; | 422 scoped_refptr<SelectFileDialog> select_file_dialog_; |
409 | 423 |
410 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; | 424 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; |
411 | 425 |
412 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 426 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
413 }; | 427 }; |
414 | 428 |
415 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 429 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
OLD | NEW |