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 { | |
|
Randy Smith (Not in Mondays)
2013/01/14 21:02:29
References to this structure below are references
benjhayden
2013/01/17 02:52:05
Done.
| |
| 139 ContinueFilenameDeterminationInfo(); | |
| 140 ~ContinueFilenameDeterminationInfo(); | |
| 141 | |
| 142 int32 download_id; | |
| 143 content::DownloadTargetCallback callback; | |
| 144 content::DownloadDangerType danger_type; | |
| 145 bool visited_referrer_before; | |
| 146 bool should_prompt; | |
| 147 }; | |
| 148 | |
| 139 // content::NotificationObserver implementation. | 149 // content::NotificationObserver implementation. |
| 140 virtual void Observe(int type, | 150 virtual void Observe(int type, |
| 141 const content::NotificationSource& source, | 151 const content::NotificationSource& source, |
| 142 const content::NotificationDetails& details) OVERRIDE; | 152 const content::NotificationDetails& details) OVERRIDE; |
| 143 | 153 |
| 144 // Callback function after url is checked with safebrowsing service. | 154 // Callback function after url is checked with safebrowsing service. |
| 145 void CheckDownloadUrlDone( | 155 void CheckDownloadUrlDone( |
| 146 int32 download_id, | 156 int32 download_id, |
| 147 const content::DownloadTargetCallback& callback, | 157 const content::DownloadTargetCallback& callback, |
| 148 safe_browsing::DownloadProtectionService::DownloadCheckResult result); | 158 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 | 197 // download identified by |download_id| with the |target_path|, target |
| 188 // disposition and |danger_type|. | 198 // disposition and |danger_type|. |
| 189 void OnPathReservationAvailable( | 199 void OnPathReservationAvailable( |
| 190 int32 download_id, | 200 int32 download_id, |
| 191 const content::DownloadTargetCallback& callback, | 201 const content::DownloadTargetCallback& callback, |
| 192 bool should_prompt, | 202 bool should_prompt, |
| 193 content::DownloadDangerType danger_type, | 203 content::DownloadDangerType danger_type, |
| 194 const FilePath& reserved_path, | 204 const FilePath& reserved_path, |
| 195 bool reserved_path_verified); | 205 bool reserved_path_verified); |
| 196 | 206 |
| 207 // When an extension opts to change a download's target filename, this | |
| 208 // sanitizes it before continuing with the filename determination process. | |
| 209 void OnExtensionsChangingFilename( | |
| 210 const ContinueFilenameDeterminationInfo& continue_info, | |
| 211 const FilePath& changed_filename, | |
| 212 bool overwrite); | |
| 213 | |
| 214 // When extensions either opt not to change a download's target filename, or | |
| 215 // the changed filename has been sanitized, this method continues with the | |
| 216 // filename determination process, optionally prompting the user to manually | |
| 217 // set the filename. | |
| 218 void OnExtensionsDeterminedFilename( | |
| 219 const ContinueFilenameDeterminationInfo& continue_info, | |
| 220 const FilePath& suggested_path, | |
| 221 bool is_forced_path); | |
| 222 | |
|
Randy Smith (Not in Mondays)
2013/01/14 21:02:29
I'm concerned about the names of these two functio
benjhayden
2013/01/17 02:52:05
I didn't put any thought into naming these methods
Randy Smith (Not in Mondays)
2013/01/17 19:15:42
Can we find something that's an imperative? I'm g
benjhayden
2013/01/18 20:59:50
All of the other methods on EDER that dispatch eve
Randy Smith (Not in Mondays)
2013/01/22 19:43:07
Sure.
| |
| 197 // Called on the UI thread once the final target path is available. | 223 // Called on the UI thread once the final target path is available. |
| 198 void OnTargetPathDetermined( | 224 void OnTargetPathDetermined( |
| 199 int32 download_id, | 225 int32 download_id, |
| 200 const content::DownloadTargetCallback& callback, | 226 const content::DownloadTargetCallback& callback, |
| 201 content::DownloadItem::TargetDisposition disposition, | 227 content::DownloadItem::TargetDisposition disposition, |
| 202 content::DownloadDangerType danger_type, | 228 content::DownloadDangerType danger_type, |
| 203 const FilePath& target_path); | 229 const FilePath& target_path); |
| 204 | 230 |
| 205 // Check policy of whether we should open this download with a web intents | 231 // Check policy of whether we should open this download with a web intents |
| 206 // dispatch. | 232 // dispatch. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 223 | 249 |
| 224 // Maps from pending extension installations to DownloadItem IDs. | 250 // Maps from pending extension installations to DownloadItem IDs. |
| 225 typedef base::hash_map<extensions::CrxInstaller*, | 251 typedef base::hash_map<extensions::CrxInstaller*, |
| 226 content::DownloadOpenDelayedCallback> CrxInstallerMap; | 252 content::DownloadOpenDelayedCallback> CrxInstallerMap; |
| 227 CrxInstallerMap crx_installers_; | 253 CrxInstallerMap crx_installers_; |
| 228 | 254 |
| 229 CancelableRequestConsumer history_consumer_; | 255 CancelableRequestConsumer history_consumer_; |
| 230 | 256 |
| 231 content::NotificationRegistrar registrar_; | 257 content::NotificationRegistrar registrar_; |
| 232 | 258 |
| 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_; | |
|
Randy Smith (Not in Mondays)
2013/01/14 21:02:29
So do you remember why we wanted to move EDER to D
benjhayden
2013/01/17 02:52:05
The downloadsInternal API needs to access the EDER
Randy Smith (Not in Mondays)
2013/01/17 19:15:42
Glancing at that file, it looks like it's only acc
benjhayden
2013/01/18 20:59:50
The EDER static methods that downloadsInternal cal
| |
| 245 #endif | |
| 246 | |
| 247 // The directory most recently chosen by the user in response to a Save As | 259 // The directory most recently chosen by the user in response to a Save As |
| 248 // dialog for a regular download. | 260 // dialog for a regular download. |
| 249 FilePath last_download_path_; | 261 FilePath last_download_path_; |
| 250 | 262 |
| 251 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); | 263 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); |
| 252 }; | 264 }; |
| 253 | 265 |
| 254 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 266 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
| OLD | NEW |