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_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/common/cancelable_request.h" | 12 #include "chrome/browser/common/cancelable_request.h" |
13 #include "chrome/browser/download/download_path_reservation_tracker.h" | 13 #include "chrome/browser/download/download_path_reservation_tracker.h" |
14 #include "chrome/browser/safe_browsing/download_protection_service.h" | 14 #include "chrome/browser/safe_browsing/download_protection_service.h" |
15 #include "content/public/browser/download_danger_type.h" | 15 #include "content/public/browser/download_danger_type.h" |
16 #include "content/public/browser/download_item.h" | 16 #include "content/public/browser/download_item.h" |
17 #include "content/public/browser/download_manager_delegate.h" | 17 #include "content/public/browser/download_manager_delegate.h" |
18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
20 | 20 |
21 class DownloadPrefs; | 21 class DownloadPrefs; |
22 class ExtensionDownloadsEventRouter; | |
23 class Profile; | 22 class Profile; |
24 | 23 |
25 namespace content { | 24 namespace content { |
26 class DownloadManager; | 25 class DownloadManager; |
27 } | 26 } |
28 | 27 |
29 namespace extensions { | 28 namespace extensions { |
30 class CrxInstaller; | 29 class CrxInstaller; |
31 } | 30 } |
32 | 31 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 const FilePath& suggested_path, | 133 const FilePath& suggested_path, |
135 const FileSelectedCallback& callback); | 134 const FileSelectedCallback& callback); |
136 | 135 |
137 // So that test classes that inherit from this for override purposes | 136 // So that test classes that inherit from this for override purposes |
138 // can call back into the DownloadManager. | 137 // can call back into the DownloadManager. |
139 scoped_refptr<content::DownloadManager> download_manager_; | 138 scoped_refptr<content::DownloadManager> download_manager_; |
140 | 139 |
141 private: | 140 private: |
142 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; | 141 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; |
143 | 142 |
| 143 struct ContinueFilenameDeterminationInfo; |
| 144 |
144 // content::NotificationObserver implementation. | 145 // content::NotificationObserver implementation. |
145 virtual void Observe(int type, | 146 virtual void Observe(int type, |
146 const content::NotificationSource& source, | 147 const content::NotificationSource& source, |
147 const content::NotificationDetails& details) OVERRIDE; | 148 const content::NotificationDetails& details) OVERRIDE; |
148 | 149 |
149 // Callback function after url is checked with safebrowsing service. | 150 // Callback function after url is checked with safebrowsing service. |
150 void CheckDownloadUrlDone( | 151 void CheckDownloadUrlDone( |
151 int32 download_id, | 152 int32 download_id, |
152 const content::DownloadTargetCallback& callback, | 153 const content::DownloadTargetCallback& callback, |
153 safe_browsing::DownloadProtectionService::DownloadCheckResult result); | 154 safe_browsing::DownloadProtectionService::DownloadCheckResult result); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // download identified by |download_id| with the |target_path|, target | 193 // download identified by |download_id| with the |target_path|, target |
193 // disposition and |danger_type|. | 194 // disposition and |danger_type|. |
194 void OnPathReservationAvailable( | 195 void OnPathReservationAvailable( |
195 int32 download_id, | 196 int32 download_id, |
196 const content::DownloadTargetCallback& callback, | 197 const content::DownloadTargetCallback& callback, |
197 bool should_prompt, | 198 bool should_prompt, |
198 content::DownloadDangerType danger_type, | 199 content::DownloadDangerType danger_type, |
199 const FilePath& reserved_path, | 200 const FilePath& reserved_path, |
200 bool reserved_path_verified); | 201 bool reserved_path_verified); |
201 | 202 |
| 203 // When an extension opts to change a download's target filename, this |
| 204 // sanitizes it before continuing with the filename determination process. |
| 205 void OnExtensionOverridingFilename( |
| 206 const ContinueFilenameDeterminationInfo& continue_info, |
| 207 const FilePath& changed_filename, |
| 208 bool overwrite); |
| 209 |
| 210 // When extensions either opt not to change a download's target filename, or |
| 211 // the changed filename has been sanitized, this method continues with the |
| 212 // filename determination process, optionally prompting the user to manually |
| 213 // set the filename. |
| 214 void ContinueDeterminingFilename( |
| 215 const ContinueFilenameDeterminationInfo& continue_info, |
| 216 const FilePath& suggested_path, |
| 217 bool is_forced_path); |
| 218 |
202 // Called on the UI thread once the final target path is available. | 219 // Called on the UI thread once the final target path is available. |
203 void OnTargetPathDetermined( | 220 void OnTargetPathDetermined( |
204 int32 download_id, | 221 int32 download_id, |
205 const content::DownloadTargetCallback& callback, | 222 const content::DownloadTargetCallback& callback, |
206 content::DownloadItem::TargetDisposition disposition, | 223 content::DownloadItem::TargetDisposition disposition, |
207 content::DownloadDangerType danger_type, | 224 content::DownloadDangerType danger_type, |
208 const FilePath& target_path); | 225 const FilePath& target_path); |
209 | 226 |
210 #if defined(ENABLE_WEB_INTENTS) | 227 #if defined(ENABLE_WEB_INTENTS) |
211 // Check policy of whether we should open this download with a web intents | 228 // Check policy of whether we should open this download with a web intents |
(...skipping 18 matching lines...) Expand all Loading... |
230 | 247 |
231 // Maps from pending extension installations to DownloadItem IDs. | 248 // Maps from pending extension installations to DownloadItem IDs. |
232 typedef base::hash_map<extensions::CrxInstaller*, | 249 typedef base::hash_map<extensions::CrxInstaller*, |
233 content::DownloadOpenDelayedCallback> CrxInstallerMap; | 250 content::DownloadOpenDelayedCallback> CrxInstallerMap; |
234 CrxInstallerMap crx_installers_; | 251 CrxInstallerMap crx_installers_; |
235 | 252 |
236 CancelableRequestConsumer history_consumer_; | 253 CancelableRequestConsumer history_consumer_; |
237 | 254 |
238 content::NotificationRegistrar registrar_; | 255 content::NotificationRegistrar registrar_; |
239 | 256 |
240 // On Android, GET downloads are not handled by the DownloadManager. | |
241 // Once we have extensions on android, we probably need the EventRouter | |
242 // in ContentViewDownloadDelegate which knows about both GET and POST | |
243 // downloads. | |
244 #if !defined(OS_ANDROID) | |
245 // The ExtensionDownloadsEventRouter dispatches download creation, change, and | |
246 // erase events to extensions. Like ChromeDownloadManagerDelegate, it's a | |
247 // chrome-level concept and its lifetime should match DownloadManager. There | |
248 // should be a separate EDER for on-record and off-record managers. | |
249 // There does not appear to be a separate ExtensionSystem for on-record and | |
250 // off-record profiles, so ExtensionSystem cannot own the EDER. | |
251 scoped_ptr<ExtensionDownloadsEventRouter> extension_event_router_; | |
252 #endif | |
253 | |
254 // The directory most recently chosen by the user in response to a Save As | 257 // The directory most recently chosen by the user in response to a Save As |
255 // dialog for a regular download. | 258 // dialog for a regular download. |
256 FilePath last_download_path_; | 259 FilePath last_download_path_; |
257 | 260 |
258 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); | 261 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); |
259 }; | 262 }; |
260 | 263 |
261 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 264 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
OLD | NEW |