Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/download/download_ui_controller.h

Issue 230103002: [Downloads] Ask DownloadHistory if a download was from history. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/download/all_download_item_notifier.h" 11 #include "chrome/browser/download/all_download_item_notifier.h"
12 12
13 class Profile; 13 // This class handles the task of observing a single DownloadManager for
14
15 namespace content {
16 class WebContents;
17 }
18
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. 14 // notifying the UI when a new download should be displayed in the UI.
21 // 15 // It invokes the OnNewDownloadReady() method of hte Delegate when the
22 // This class monitors each IN_PROGRESS download that is created (for which 16 // 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 { 17 class DownloadUIController : public AllDownloadItemNotifier::Observer {
28 public: 18 public:
29 // The delegate is responsible for figuring out how to notify the UI. 19 // The delegate is responsible for figuring out how to notify the UI.
30 class Delegate { 20 class Delegate {
31 public: 21 public:
32 virtual ~Delegate(); 22 virtual ~Delegate();
33 virtual void NotifyDownloadStarting(content::DownloadItem* item) = 0; 23
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;
34 }; 27 };
35 28
36 // |manager| is the download manager to observe for new downloads. If 29 // |manager| is the download manager to observe for new downloads. If
37 // |delegate.get()| is NULL, then the default delegate is constructed. 30 // |delegate.get()| is NULL, then the default delegate is constructed.
38 // 31 //
39 // On Android the default delegate notifies DownloadControllerAndroid. On 32 // On Android the default delegate notifies DownloadControllerAndroid. On
40 // other platforms the target of the notification is a Browser object. 33 // other platforms the target of the notification is a Browser object.
41 // 34 //
42 // Currently explicit delegates are only used for testing. 35 // Currently explicit delegates are only used for testing.
43 DownloadUIController(content::DownloadManager* manager, 36 DownloadUIController(content::DownloadManager* manager,
44 scoped_ptr<Delegate> delegate); 37 scoped_ptr<Delegate> delegate);
45 38
46 virtual ~DownloadUIController(); 39 virtual ~DownloadUIController();
47 40
48 private: 41 private:
49 virtual void OnDownloadCreated(content::DownloadManager* manager, 42 virtual void OnDownloadCreated(content::DownloadManager* manager,
50 content::DownloadItem* item) OVERRIDE; 43 content::DownloadItem* item) OVERRIDE;
51 virtual void OnDownloadUpdated(content::DownloadManager* manager, 44 virtual void OnDownloadUpdated(content::DownloadManager* manager,
52 content::DownloadItem* item) OVERRIDE; 45 content::DownloadItem* item) OVERRIDE;
53 46
54 AllDownloadItemNotifier download_notifier_; 47 AllDownloadItemNotifier download_notifier_;
55 48
56 scoped_ptr<Delegate> delegate_; 49 scoped_ptr<Delegate> delegate_;
57 50
58 DISALLOW_COPY_AND_ASSIGN(DownloadUIController); 51 DISALLOW_COPY_AND_ASSIGN(DownloadUIController);
59 }; 52 };
60 53
61 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_ 54 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UI_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_service.cc ('k') | chrome/browser/download/download_ui_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698