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