OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 virtual void CallDownloadsList(const base::ListValue& downloads); | 99 virtual void CallDownloadsList(const base::ListValue& downloads); |
100 virtual void CallDownloadUpdated(const base::ListValue& download); | 100 virtual void CallDownloadUpdated(const base::ListValue& download); |
101 | 101 |
102 // Schedules a call to SendCurrentDownloads() in the next message loop | 102 // Schedules a call to SendCurrentDownloads() in the next message loop |
103 // iteration. Protected rather than private for use in tests. | 103 // iteration. Protected rather than private for use in tests. |
104 void ScheduleSendCurrentDownloads(); | 104 void ScheduleSendCurrentDownloads(); |
105 | 105 |
106 // Protected for testing. | 106 // Protected for testing. |
107 virtual content::DownloadManager* GetMainNotifierManager(); | 107 virtual content::DownloadManager* GetMainNotifierManager(); |
108 | 108 |
| 109 // Actually remove downloads with an ID in |removals_|. This cannot be undone. |
| 110 void FinalizeRemovals(); |
| 111 |
109 private: | 112 private: |
110 // Shorthand for |observing_items_|, which tracks all items that this is | 113 // Shorthand for |observing_items_|, which tracks all items that this is |
111 // observing so that RemoveObserver will be called for all of them. | 114 // observing so that RemoveObserver will be called for all of them. |
112 typedef std::set<content::DownloadItem*> DownloadSet; | 115 typedef std::set<content::DownloadItem*> DownloadSet; |
113 | 116 |
114 // Sends the current list of downloads to the page. | 117 // Sends the current list of downloads to the page. |
115 void SendCurrentDownloads(); | 118 void SendCurrentDownloads(); |
116 | 119 |
117 // Displays a native prompt asking the user for confirmation after accepting | 120 // Displays a native prompt asking the user for confirmation after accepting |
118 // the dangerous download specified by |dangerous|. The function returns | 121 // the dangerous download specified by |dangerous|. The function returns |
(...skipping 24 matching lines...) Expand all Loading... |
143 scoped_ptr<base::ListValue> search_terms_; | 146 scoped_ptr<base::ListValue> search_terms_; |
144 | 147 |
145 // Notifies OnDownload*() and provides safe access to the DownloadManager. | 148 // Notifies OnDownload*() and provides safe access to the DownloadManager. |
146 AllDownloadItemNotifier main_notifier_; | 149 AllDownloadItemNotifier main_notifier_; |
147 | 150 |
148 // If |main_notifier_| observes an incognito profile, then this observes the | 151 // If |main_notifier_| observes an incognito profile, then this observes the |
149 // DownloadManager for the original profile; otherwise, this is NULL. | 152 // DownloadManager for the original profile; otherwise, this is NULL. |
150 scoped_ptr<AllDownloadItemNotifier> original_notifier_; | 153 scoped_ptr<AllDownloadItemNotifier> original_notifier_; |
151 | 154 |
152 // IDs of downloads to remove when this handler gets deleted. | 155 // IDs of downloads to remove when this handler gets deleted. |
153 std::vector<std::set<uint32>> removes_; | 156 std::vector<std::set<uint32>> removals_; |
154 | 157 |
155 // Whether a call to SendCurrentDownloads() is currently scheduled. | 158 // Whether a call to SendCurrentDownloads() is currently scheduled. |
156 bool update_scheduled_; | 159 bool update_scheduled_; |
157 | 160 |
158 base::WeakPtrFactory<DownloadsDOMHandler> weak_ptr_factory_; | 161 base::WeakPtrFactory<DownloadsDOMHandler> weak_ptr_factory_; |
159 | 162 |
160 DISALLOW_COPY_AND_ASSIGN(DownloadsDOMHandler); | 163 DISALLOW_COPY_AND_ASSIGN(DownloadsDOMHandler); |
161 }; | 164 }; |
162 | 165 |
163 #endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ | 166 #endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ |
OLD | NEW |