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/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/download/download_completion_blocker.h" | 19 #include "chrome/browser/download/download_completion_blocker.h" |
20 #include "chrome/browser/download/download_crx_util.h" | 20 #include "chrome/browser/download/download_crx_util.h" |
| 21 #include "chrome/browser/download/download_extension_api.h" |
21 #include "chrome/browser/download/download_extensions.h" | 22 #include "chrome/browser/download/download_extensions.h" |
22 #include "chrome/browser/download/download_file_picker.h" | 23 #include "chrome/browser/download/download_file_picker.h" |
23 #include "chrome/browser/download/download_history.h" | 24 #include "chrome/browser/download/download_history.h" |
24 #include "chrome/browser/download/download_prefs.h" | 25 #include "chrome/browser/download/download_prefs.h" |
25 #include "chrome/browser/download/download_status_updater.h" | 26 #include "chrome/browser/download/download_status_updater.h" |
26 #include "chrome/browser/download/download_util.h" | 27 #include "chrome/browser/download/download_util.h" |
27 #include "chrome/browser/download/save_package_file_picker.h" | 28 #include "chrome/browser/download/save_package_file_picker.h" |
28 #include "chrome/browser/extensions/crx_installer.h" | 29 #include "chrome/browser/extensions/crx_installer.h" |
29 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/prefs/pref_member.h" | 31 #include "chrome/browser/prefs/pref_member.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingState); | 99 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingState); |
99 }; | 100 }; |
100 | 101 |
101 SafeBrowsingState::~SafeBrowsingState() {} | 102 SafeBrowsingState::~SafeBrowsingState() {} |
102 | 103 |
103 } // namespace | 104 } // namespace |
104 | 105 |
105 ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile) | 106 ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile) |
106 : profile_(profile), | 107 : profile_(profile), |
107 next_download_id_(0), | 108 next_download_id_(0), |
108 download_prefs_(new DownloadPrefs(profile->GetPrefs())) { | 109 download_prefs_(new DownloadPrefs(profile->GetPrefs())), |
| 110 downloads_event_router_(new ExtensionDownloadsEventRouter(profile)) { |
109 } | 111 } |
110 | 112 |
111 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { | 113 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { |
112 } | 114 } |
113 | 115 |
114 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { | 116 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { |
115 download_manager_ = dm; | 117 download_manager_ = dm; |
116 download_history_.reset(new DownloadHistory(profile_)); | 118 download_history_.reset(new DownloadHistory(profile_)); |
117 download_history_->Load( | 119 download_history_->Load( |
118 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, | 120 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 int32 download_id, int64 db_handle) { | 843 int32 download_id, int64 db_handle) { |
842 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 844 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
843 // call this function with an invalid |db_handle|. For instance, this can | 845 // call this function with an invalid |db_handle|. For instance, this can |
844 // happen when the history database is offline. We cannot have multiple | 846 // happen when the history database is offline. We cannot have multiple |
845 // DownloadItems with the same invalid db_handle, so we need to assign a | 847 // DownloadItems with the same invalid db_handle, so we need to assign a |
846 // unique |db_handle| here. | 848 // unique |db_handle| here. |
847 if (db_handle == DownloadItem::kUninitializedHandle) | 849 if (db_handle == DownloadItem::kUninitializedHandle) |
848 db_handle = download_history_->GetNextFakeDbHandle(); | 850 db_handle = download_history_->GetNextFakeDbHandle(); |
849 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 851 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
850 } | 852 } |
OLD | NEW |