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