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"
19 // This class handles the task of observing for download notifications and
20 // notifying the UI when a new download should be displayed in the UI.
22 // This class monitors each IN_PROGRESS download that is created (for which
23 // OnDownloadCreated is called) until:
24 // - it is assigned a target path or
26 // Then the NotifyDownloadStarting() method of the Delegate is invoked.
27 class DownloadUIController : public AllDownloadItemNotifier::Observer {
29 // The delegate is responsible for figuring out how to notify the UI.
33 virtual void NotifyDownloadStarting(content::DownloadItem* item) = 0;
36 // |manager| is the download manager to observe for new downloads. If
37 // |delegate.get()| is NULL, then the default delegate is constructed.
39 // On Android the default delegate notifies DownloadControllerAndroid. On
40 // other platforms the target of the notification is a Browser object.
42 // Currently explicit delegates are only used for testing.
43 DownloadUIController(content::DownloadManager* manager,
44 scoped_ptr<Delegate> delegate);
46 virtual ~DownloadUIController();
49 virtual void OnDownloadCreated(content::DownloadManager* manager,
50 content::DownloadItem* item) OVERRIDE;
51 virtual void OnDownloadUpdated(content::DownloadManager* manager,
52 content::DownloadItem* item) OVERRIDE;
54 AllDownloadItemNotifier download_notifier_;
56 scoped_ptr<Delegate> delegate_;
58 DISALLOW_COPY_AND_ASSIGN(DownloadUIController);
61 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_