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 #include "chrome/browser/download/download_service.h" | 5 #include "chrome/browser/download/download_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 9 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
10 #include "chrome/browser/download/download_history.h" | 10 #include "chrome/browser/download/download_history.h" |
11 #include "chrome/browser/download/download_service_factory.h" | 11 #include "chrome/browser/download/download_service_factory.h" |
12 #include "chrome/browser/download/download_status_updater.h" | 12 #include "chrome/browser/download/download_status_updater.h" |
| 13 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
13 #include "chrome/browser/history/history_service.h" | 14 #include "chrome/browser/history/history_service.h" |
14 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
15 #include "chrome/browser/net/chrome_net_log.h" | 16 #include "chrome/browser/net/chrome_net_log.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "content/public/browser/download_manager.h" | 19 #include "content/public/browser/download_manager.h" |
19 | 20 |
20 using content::BrowserContext; | 21 using content::BrowserContext; |
21 using content::DownloadManager; | 22 using content::DownloadManager; |
22 using content::DownloadManagerDelegate; | 23 using content::DownloadManagerDelegate; |
(...skipping 15 matching lines...) Expand all Loading... |
38 } | 39 } |
39 download_manager_created_ = true; | 40 download_manager_created_ = true; |
40 | 41 |
41 // In case the delegate has already been set by | 42 // In case the delegate has already been set by |
42 // SetDownloadManagerDelegateForTesting. | 43 // SetDownloadManagerDelegateForTesting. |
43 if (!manager_delegate_.get()) | 44 if (!manager_delegate_.get()) |
44 manager_delegate_ = new ChromeDownloadManagerDelegate(profile_); | 45 manager_delegate_ = new ChromeDownloadManagerDelegate(profile_); |
45 | 46 |
46 manager_delegate_->SetDownloadManager(manager); | 47 manager_delegate_->SetDownloadManager(manager); |
47 | 48 |
| 49 #if !defined(OS_ANDROID) |
| 50 extension_event_router_.reset(new ExtensionDownloadsEventRouter( |
| 51 profile_, manager)); |
| 52 #endif |
| 53 |
48 if (!profile_->IsOffTheRecord()) { | 54 if (!profile_->IsOffTheRecord()) { |
49 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 55 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
50 profile_, Profile::EXPLICIT_ACCESS); | 56 profile_, Profile::EXPLICIT_ACCESS); |
51 if (hs) | 57 if (hs) |
52 download_history_.reset(new DownloadHistory( | 58 download_history_.reset(new DownloadHistory( |
53 manager, | 59 manager, |
54 scoped_ptr<DownloadHistory::HistoryAdapter>( | 60 scoped_ptr<DownloadHistory::HistoryAdapter>( |
55 new DownloadHistory::HistoryAdapter(hs)))); | 61 new DownloadHistory::HistoryAdapter(hs)))); |
56 } | 62 } |
57 | 63 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 119 |
114 void DownloadService::Shutdown() { | 120 void DownloadService::Shutdown() { |
115 if (download_manager_created_) { | 121 if (download_manager_created_) { |
116 // Normally the DownloadManager would be shutdown later, after the Profile | 122 // Normally the DownloadManager would be shutdown later, after the Profile |
117 // goes away and BrowserContext's destructor runs. But that would be too | 123 // goes away and BrowserContext's destructor runs. But that would be too |
118 // late for us since we need to use the profile (indirectly through history | 124 // late for us since we need to use the profile (indirectly through history |
119 // code) when the DownloadManager is shutting down. So we shut it down | 125 // code) when the DownloadManager is shutting down. So we shut it down |
120 // manually earlier. See http://crbug.com/131692 | 126 // manually earlier. See http://crbug.com/131692 |
121 BrowserContext::GetDownloadManager(profile_)->Shutdown(); | 127 BrowserContext::GetDownloadManager(profile_)->Shutdown(); |
122 } | 128 } |
| 129 #if !defined(OS_ANDROID) |
| 130 extension_event_router_.reset(); |
| 131 #endif |
123 manager_delegate_ = NULL; | 132 manager_delegate_ = NULL; |
124 download_history_.reset(); | 133 download_history_.reset(); |
125 } | 134 } |
OLD | NEW |