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_extensions.h" | 21 #include "chrome/browser/download/download_extensions.h" |
22 #include "chrome/browser/download/download_file_picker.h" | 22 #include "chrome/browser/download/download_file_picker.h" |
23 #include "chrome/browser/download/download_history.h" | 23 #include "chrome/browser/download/download_history.h" |
24 #include "chrome/browser/download/download_prefs.h" | 24 #include "chrome/browser/download/download_prefs.h" |
25 #include "chrome/browser/download/download_status_updater.h" | 25 #include "chrome/browser/download/download_status_updater.h" |
26 #include "chrome/browser/download/download_util.h" | 26 #include "chrome/browser/download/download_util.h" |
27 #include "chrome/browser/download/save_package_file_picker.h" | 27 #include "chrome/browser/download/save_package_file_picker.h" |
| 28 #include "chrome/browser/extensions/api/downloads/downloads_api.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" |
31 #include "chrome/browser/prefs/pref_service.h" | 32 #include "chrome/browser/prefs/pref_service.h" |
32 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 34 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
34 #include "chrome/common/chrome_notification_types.h" | 35 #include "chrome/common/chrome_notification_types.h" |
35 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
36 #include "chrome/common/extensions/extension_switch_utils.h" | 37 #include "chrome/common/extensions/extension_switch_utils.h" |
37 #include "chrome/common/extensions/user_script.h" | 38 #include "chrome/common/extensions/user_script.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 111 |
111 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { | 112 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { |
112 } | 113 } |
113 | 114 |
114 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { | 115 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { |
115 download_manager_ = dm; | 116 download_manager_ = dm; |
116 download_history_.reset(new DownloadHistory(profile_)); | 117 download_history_.reset(new DownloadHistory(profile_)); |
117 download_history_->Load( | 118 download_history_->Load( |
118 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, | 119 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, |
119 base::Unretained(dm))); | 120 base::Unretained(dm))); |
| 121 extension_event_router_.reset(new ExtensionDownloadsEventRouter(profile_)); |
120 } | 122 } |
121 | 123 |
122 void ChromeDownloadManagerDelegate::Shutdown() { | 124 void ChromeDownloadManagerDelegate::Shutdown() { |
123 download_history_.reset(); | 125 download_history_.reset(); |
124 download_prefs_.reset(); | 126 download_prefs_.reset(); |
125 } | 127 } |
126 | 128 |
127 DownloadId ChromeDownloadManagerDelegate::GetNextId() { | 129 DownloadId ChromeDownloadManagerDelegate::GetNextId() { |
128 if (!profile_->IsOffTheRecord()) | 130 if (!profile_->IsOffTheRecord()) |
129 return DownloadId(this, next_download_id_++); | 131 return DownloadId(this, next_download_id_++); |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 int32 download_id, int64 db_handle) { | 850 int32 download_id, int64 db_handle) { |
849 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 851 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
850 // call this function with an invalid |db_handle|. For instance, this can | 852 // call this function with an invalid |db_handle|. For instance, this can |
851 // happen when the history database is offline. We cannot have multiple | 853 // happen when the history database is offline. We cannot have multiple |
852 // DownloadItems with the same invalid db_handle, so we need to assign a | 854 // DownloadItems with the same invalid db_handle, so we need to assign a |
853 // unique |db_handle| here. | 855 // unique |db_handle| here. |
854 if (db_handle == DownloadItem::kUninitializedHandle) | 856 if (db_handle == DownloadItem::kUninitializedHandle) |
855 db_handle = download_history_->GetNextFakeDbHandle(); | 857 db_handle = download_history_->GetNextFakeDbHandle(); |
856 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 858 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
857 } | 859 } |
OLD | NEW |