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