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 "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/safe_browsing/download_protection_service.h" | 13 #include "chrome/browser/safe_browsing/download_protection_service.h" |
14 #include "chrome/browser/download/download_path_reservation_tracker.h" | 14 #include "chrome/browser/download/download_path_reservation_tracker.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 CrxInstaller; | |
22 class DownloadHistory; | 21 class DownloadHistory; |
23 class DownloadPrefs; | 22 class DownloadPrefs; |
24 class ExtensionDownloadsEventRouter; | 23 class ExtensionDownloadsEventRouter; |
25 class Profile; | 24 class Profile; |
26 | 25 |
27 namespace content { | 26 namespace content { |
28 class DownloadManager; | 27 class DownloadManager; |
29 } | 28 } |
30 | 29 |
| 30 namespace extensions { |
| 31 class CrxInstaller; |
| 32 } |
| 33 |
31 #if defined(COMPILER_GCC) | 34 #if defined(COMPILER_GCC) |
32 namespace BASE_HASH_NAMESPACE { | 35 namespace BASE_HASH_NAMESPACE { |
33 template<> | 36 template<> |
34 struct hash<CrxInstaller*> { | 37 struct hash<extensions::CrxInstaller*> { |
35 std::size_t operator()(CrxInstaller* const& p) const { | 38 std::size_t operator()(extensions::CrxInstaller* const& p) const { |
36 return reinterpret_cast<std::size_t>(p); | 39 return reinterpret_cast<std::size_t>(p); |
37 } | 40 } |
38 }; | 41 }; |
39 } // namespace BASE_HASH_NAMESPACE | 42 } // namespace BASE_HASH_NAMESPACE |
40 #endif | 43 #endif |
41 | 44 |
42 // This is the Chrome side helper for the download system. | 45 // This is the Chrome side helper for the download system. |
43 class ChromeDownloadManagerDelegate | 46 class ChromeDownloadManagerDelegate |
44 : public base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>, | 47 : public base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>, |
45 public content::DownloadManagerDelegate, | 48 public content::DownloadManagerDelegate, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 void ShouldCompleteDownloadInternal( | 194 void ShouldCompleteDownloadInternal( |
192 int download_id, | 195 int download_id, |
193 const base::Closure& user_complete_callback); | 196 const base::Closure& user_complete_callback); |
194 | 197 |
195 Profile* profile_; | 198 Profile* profile_; |
196 int next_download_id_; | 199 int next_download_id_; |
197 scoped_ptr<DownloadPrefs> download_prefs_; | 200 scoped_ptr<DownloadPrefs> download_prefs_; |
198 scoped_ptr<DownloadHistory> download_history_; | 201 scoped_ptr<DownloadHistory> download_history_; |
199 | 202 |
200 // Maps from pending extension installations to DownloadItem IDs. | 203 // Maps from pending extension installations to DownloadItem IDs. |
201 typedef base::hash_map<CrxInstaller*, int> CrxInstallerMap; | 204 typedef base::hash_map<extensions::CrxInstaller*, int> CrxInstallerMap; |
202 CrxInstallerMap crx_installers_; | 205 CrxInstallerMap crx_installers_; |
203 | 206 |
204 content::NotificationRegistrar registrar_; | 207 content::NotificationRegistrar registrar_; |
205 | 208 |
206 // On Android, GET downloads are not handled by the DownloadManager. | 209 // On Android, GET downloads are not handled by the DownloadManager. |
207 // Once we have extensions on android, we probably need the EventRouter | 210 // Once we have extensions on android, we probably need the EventRouter |
208 // in ContentViewDownloadDelegate which knows about both GET and POST | 211 // in ContentViewDownloadDelegate which knows about both GET and POST |
209 // downloads. | 212 // downloads. |
210 #if !defined(OS_ANDROID) | 213 #if !defined(OS_ANDROID) |
211 // The ExtensionDownloadsEventRouter dispatches download creation, change, and | 214 // The ExtensionDownloadsEventRouter dispatches download creation, change, and |
212 // erase events to extensions. Like ChromeDownloadManagerDelegate, it's a | 215 // erase events to extensions. Like ChromeDownloadManagerDelegate, it's a |
213 // chrome-level concept and its lifetime should match DownloadManager. There | 216 // chrome-level concept and its lifetime should match DownloadManager. There |
214 // should be a separate EDER for on-record and off-record managers. | 217 // should be a separate EDER for on-record and off-record managers. |
215 // There does not appear to be a separate ExtensionSystem for on-record and | 218 // There does not appear to be a separate ExtensionSystem for on-record and |
216 // off-record profiles, so ExtensionSystem cannot own the EDER. | 219 // off-record profiles, so ExtensionSystem cannot own the EDER. |
217 scoped_ptr<ExtensionDownloadsEventRouter> extension_event_router_; | 220 scoped_ptr<ExtensionDownloadsEventRouter> extension_event_router_; |
218 #endif | 221 #endif |
219 | 222 |
220 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); | 223 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); |
221 }; | 224 }; |
222 | 225 |
223 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 226 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
OLD | NEW |