| 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/download/download_ui_controller.h" |
| 13 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | 14 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
| 14 #include "chrome/browser/history/history_service.h" | 15 #include "chrome/browser/history/history_service.h" |
| 15 #include "chrome/browser/history/history_service_factory.h" | 16 #include "chrome/browser/history/history_service_factory.h" |
| 16 #include "chrome/browser/net/chrome_net_log.h" | 17 #include "chrome/browser/net/chrome_net_log.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "content/public/browser/download_manager.h" | 20 #include "content/public/browser/download_manager.h" |
| 20 | 21 |
| 21 using content::BrowserContext; | 22 using content::BrowserContext; |
| 22 using content::DownloadManager; | 23 using content::DownloadManager; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 if (!profile_->IsOffTheRecord()) { | 55 if (!profile_->IsOffTheRecord()) { |
| 55 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 56 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
| 56 profile_, Profile::EXPLICIT_ACCESS); | 57 profile_, Profile::EXPLICIT_ACCESS); |
| 57 if (hs) | 58 if (hs) |
| 58 download_history_.reset(new DownloadHistory( | 59 download_history_.reset(new DownloadHistory( |
| 59 manager, | 60 manager, |
| 60 scoped_ptr<DownloadHistory::HistoryAdapter>( | 61 scoped_ptr<DownloadHistory::HistoryAdapter>( |
| 61 new DownloadHistory::HistoryAdapter(hs)))); | 62 new DownloadHistory::HistoryAdapter(hs)))); |
| 62 } | 63 } |
| 63 | 64 |
| 65 // Pass an empty delegate when constructing the DownloadUIController. The |
| 66 // default delegate does all the notifications we need. |
| 67 scoped_ptr<DownloadUIController::Delegate> empty_ui_delegate; |
| 68 download_ui_.reset(new DownloadUIController(manager, |
| 69 empty_ui_delegate.Pass())); |
| 70 |
| 64 // Include this download manager in the set monitored by the | 71 // Include this download manager in the set monitored by the |
| 65 // global status updater. | 72 // global status updater. |
| 66 g_browser_process->download_status_updater()->AddManager(manager); | 73 g_browser_process->download_status_updater()->AddManager(manager); |
| 67 | 74 |
| 68 return manager_delegate_.get(); | 75 return manager_delegate_.get(); |
| 69 } | 76 } |
| 70 | 77 |
| 71 DownloadHistory* DownloadService::GetDownloadHistory() { | 78 DownloadHistory* DownloadService::GetDownloadHistory() { |
| 72 if (!download_manager_created_) { | 79 if (!download_manager_created_) { |
| 73 GetDownloadManagerDelegate(); | 80 GetDownloadManagerDelegate(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // code) when the DownloadManager is shutting down. So we shut it down | 132 // code) when the DownloadManager is shutting down. So we shut it down |
| 126 // manually earlier. See http://crbug.com/131692 | 133 // manually earlier. See http://crbug.com/131692 |
| 127 BrowserContext::GetDownloadManager(profile_)->Shutdown(); | 134 BrowserContext::GetDownloadManager(profile_)->Shutdown(); |
| 128 } | 135 } |
| 129 #if !defined(OS_ANDROID) | 136 #if !defined(OS_ANDROID) |
| 130 extension_event_router_.reset(); | 137 extension_event_router_.reset(); |
| 131 #endif | 138 #endif |
| 132 manager_delegate_ = NULL; | 139 manager_delegate_ = NULL; |
| 133 download_history_.reset(); | 140 download_history_.reset(); |
| 134 } | 141 } |
| OLD | NEW |