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