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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/download/all_download_item_notifier.h"
13 // This class handles the task of observing a single DownloadManager for
14 // notifying the UI when a new download should be displayed in the UI.
15 // It invokes the OnNewDownloadReady() method of hte Delegate when the
16 // target path is available for a new download.
17 class DownloadUIController
: public AllDownloadItemNotifier::Observer
{
19 // The delegate is responsible for figuring out how to notify the UI.
24 // This method is invoked to notify the UI of the new download |item|. Note
25 // that |item| may be in any state by the time this method is invoked.
26 virtual void OnNewDownloadReady(content::DownloadItem
* item
) = 0;
29 // |manager| is the download manager to observe for new downloads. If
30 // |delegate.get()| is NULL, then the default delegate is constructed.
32 // On Android the default delegate notifies DownloadControllerAndroid. On
33 // other platforms the target of the notification is a Browser object.
35 // Currently explicit delegates are only used for testing.
36 DownloadUIController(content::DownloadManager
* manager
,
37 scoped_ptr
<Delegate
> delegate
);
39 ~DownloadUIController() override
;
42 void OnDownloadCreated(content::DownloadManager
* manager
,
43 content::DownloadItem
* item
) override
;
44 void OnDownloadUpdated(content::DownloadManager
* manager
,
45 content::DownloadItem
* item
) override
;
47 AllDownloadItemNotifier download_notifier_
;
49 scoped_ptr
<Delegate
> delegate_
;
51 DISALLOW_COPY_AND_ASSIGN(DownloadUIController
);
54 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_