OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback_forward.h" | |
Randy Smith (Not in Mondays)
2014/04/21 18:21:22
Is this include still needed?
asanka
2014/04/23 05:51:09
Removed.
| |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "chrome/browser/download/all_download_item_notifier.h" | 12 #include "chrome/browser/download/all_download_item_notifier.h" |
12 | 13 |
13 class Profile; | 14 class Profile; |
15 class DownloadHistory; | |
Randy Smith (Not in Mondays)
2014/04/21 18:21:22
Is this forward decl still needed?
asanka
2014/04/23 05:51:09
Removed.
| |
14 | 16 |
15 namespace content { | 17 namespace content { |
16 class WebContents; | 18 class WebContents; |
17 } | 19 } |
18 | 20 |
19 // This class handles the task of observing for download notifications and | 21 // This class handles the task of observing a single DownloadManager for |
20 // notifying the UI when a new download should be displayed in the UI. | 22 // notifying the UI when a new download should be displayed in the UI. |
21 // | 23 // It invokes the OnNewDownloadReady() method of hte Delegate when the |
22 // This class monitors each IN_PROGRESS download that is created (for which | 24 // target path is available for a new download. |
23 // OnDownloadCreated is called) until: | |
24 // - it is assigned a target path or | |
25 // - is interrupted. | |
26 // Then the NotifyDownloadStarting() method of the Delegate is invoked. | |
27 class DownloadUIController : public AllDownloadItemNotifier::Observer { | 25 class DownloadUIController : public AllDownloadItemNotifier::Observer { |
28 public: | 26 public: |
29 // The delegate is responsible for figuring out how to notify the UI. | 27 // The delegate is responsible for figuring out how to notify the UI. |
30 class Delegate { | 28 class Delegate { |
31 public: | 29 public: |
32 virtual ~Delegate(); | 30 virtual ~Delegate(); |
33 virtual void NotifyDownloadStarting(content::DownloadItem* item) = 0; | 31 |
32 // This method is invoked to notify the UI of the new download |item|. Note | |
33 // that |item| may be in any state by the time this method is invoked. | |
34 virtual void OnNewDownloadReady(content::DownloadItem* item) = 0; | |
34 }; | 35 }; |
35 | 36 |
36 // |manager| is the download manager to observe for new downloads. If | 37 // |manager| is the download manager to observe for new downloads. If |
37 // |delegate.get()| is NULL, then the default delegate is constructed. | 38 // |delegate.get()| is NULL, then the default delegate is constructed. |
38 // | 39 // |
39 // On Android the default delegate notifies DownloadControllerAndroid. On | 40 // On Android the default delegate notifies DownloadControllerAndroid. On |
40 // other platforms the target of the notification is a Browser object. | 41 // other platforms the target of the notification is a Browser object. |
41 // | 42 // |
42 // Currently explicit delegates are only used for testing. | 43 // Currently explicit delegates are only used for testing. |
43 DownloadUIController(content::DownloadManager* manager, | 44 DownloadUIController(content::DownloadManager* manager, |
44 scoped_ptr<Delegate> delegate); | 45 scoped_ptr<Delegate> delegate); |
45 | 46 |
46 virtual ~DownloadUIController(); | 47 virtual ~DownloadUIController(); |
47 | 48 |
48 private: | 49 private: |
49 virtual void OnDownloadCreated(content::DownloadManager* manager, | 50 virtual void OnDownloadCreated(content::DownloadManager* manager, |
50 content::DownloadItem* item) OVERRIDE; | 51 content::DownloadItem* item) OVERRIDE; |
51 virtual void OnDownloadUpdated(content::DownloadManager* manager, | 52 virtual void OnDownloadUpdated(content::DownloadManager* manager, |
52 content::DownloadItem* item) OVERRIDE; | 53 content::DownloadItem* item) OVERRIDE; |
53 | 54 |
54 AllDownloadItemNotifier download_notifier_; | 55 AllDownloadItemNotifier download_notifier_; |
55 | 56 |
56 scoped_ptr<Delegate> delegate_; | 57 scoped_ptr<Delegate> delegate_; |
57 | 58 |
58 DISALLOW_COPY_AND_ASSIGN(DownloadUIController); | 59 DISALLOW_COPY_AND_ASSIGN(DownloadUIController); |
59 }; | 60 }; |
60 | 61 |
61 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_ | 62 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_ |
OLD | NEW |