OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 | 149 |
150 bool ChromeDownloadManagerDelegate::ShouldOpenDownload(DownloadItem* item) { | 150 bool ChromeDownloadManagerDelegate::ShouldOpenDownload(DownloadItem* item) { |
151 if (!IsExtensionDownload(item)) | 151 if (!IsExtensionDownload(item)) |
152 return true; | 152 return true; |
153 | 153 |
154 download_crx_util::OpenChromeExtension(profile_, *item); | 154 download_crx_util::OpenChromeExtension(profile_, *item); |
155 return false; | 155 return false; |
156 } | 156 } |
157 | 157 |
158 bool ChromeDownloadManagerDelegate::ShouldCompleteDownload(DownloadItem* item) { | 158 bool ChromeDownloadManagerDelegate::ShouldCompleteDownload(DownloadItem* item) { |
159 if (!IsExtensionDownload(item)) | 159 if (!IsExtensionDownload(item)) { |
160 #if defined(ENABLE_SAFE_BROWSING) | |
161 // Begin the safe browsing download protection check. | |
162 SafeBrowsingService* sb_service = | |
163 g_browser_process->safe_browsing_service(); | |
164 if (sb_service && sb_service->download_protection_service()) { | |
mattm
2011/10/26 23:27:36
I think we need a check here or in CheckClientDown
Brian Ryner
2011/10/27 01:03:04
Done. In the interest of keeping things simple, I
| |
165 using safe_browsing::DownloadProtectionService; | |
166 sb_service->download_protection_service()->CheckClientDownload( | |
167 DownloadProtectionService::DownloadInfo::FromDownloadItem(*item), | |
168 base::Bind( | |
169 &ChromeDownloadManagerDelegate::CheckClientDownloadDone, | |
170 this, item->id())); | |
171 // For now, we won't delay the download for this. | |
172 } | |
173 #else | |
174 // Assume safe. | |
175 #endif | |
176 | |
160 return true; | 177 return true; |
178 } | |
161 | 179 |
162 scoped_refptr<CrxInstaller> crx_installer = | 180 scoped_refptr<CrxInstaller> crx_installer = |
163 download_crx_util::OpenChromeExtension(profile_, *item); | 181 download_crx_util::OpenChromeExtension(profile_, *item); |
164 | 182 |
165 // CRX_INSTALLER_DONE will fire when the install completes. Observe() | 183 // CRX_INSTALLER_DONE will fire when the install completes. Observe() |
166 // will call CompleteDelayedDownload() on this item. If this DownloadItem is | 184 // will call CompleteDelayedDownload() on this item. If this DownloadItem is |
167 // not around when CRX_INSTALLER_DONE fires, Complete() will not be called. | 185 // not around when CRX_INSTALLER_DONE fires, Complete() will not be called. |
168 registrar_.Add(this, | 186 registrar_.Add(this, |
169 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 187 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
170 content::Source<CrxInstaller>(crx_installer.get())); | 188 content::Source<CrxInstaller>(crx_installer.get())); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 DownloadItem* item) { | 238 DownloadItem* item) { |
221 download_history_->UpdateEntry(item); | 239 download_history_->UpdateEntry(item); |
222 } | 240 } |
223 | 241 |
224 void ChromeDownloadManagerDelegate::UpdatePathForItemInPersistentStore( | 242 void ChromeDownloadManagerDelegate::UpdatePathForItemInPersistentStore( |
225 DownloadItem* item, | 243 DownloadItem* item, |
226 const FilePath& new_path) { | 244 const FilePath& new_path) { |
227 download_history_->UpdateDownloadPath(item, new_path); | 245 download_history_->UpdateDownloadPath(item, new_path); |
228 } | 246 } |
229 | 247 |
248 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( | |
249 int32 download_id, | |
250 safe_browsing::DownloadProtectionService::DownloadCheckResult result) { | |
251 // TODO(bryner): notify the user based on this result | |
252 } | |
253 | |
230 void ChromeDownloadManagerDelegate::RemoveItemFromPersistentStore( | 254 void ChromeDownloadManagerDelegate::RemoveItemFromPersistentStore( |
231 DownloadItem* item) { | 255 DownloadItem* item) { |
232 download_history_->RemoveEntry(item); | 256 download_history_->RemoveEntry(item); |
233 } | 257 } |
234 | 258 |
235 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween( | 259 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween( |
236 const base::Time remove_begin, | 260 const base::Time remove_begin, |
237 const base::Time remove_end) { | 261 const base::Time remove_end) { |
238 download_history_->RemoveEntriesBetween(remove_begin, remove_end); | 262 download_history_->RemoveEntriesBetween(remove_begin, remove_end); |
239 } | 263 } |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 // TODO(noelutz): This function currently works as a callback place holder. | 564 // TODO(noelutz): This function currently works as a callback place holder. |
541 // Once we decide the hash check is reliable, we could move the | 565 // Once we decide the hash check is reliable, we could move the |
542 // MaybeCompleteDownload in OnAllDataSaved to this function. | 566 // MaybeCompleteDownload in OnAllDataSaved to this function. |
543 void ChromeDownloadManagerDelegate::CheckDownloadHashDone( | 567 void ChromeDownloadManagerDelegate::CheckDownloadHashDone( |
544 int32 download_id, | 568 int32 download_id, |
545 bool is_dangerous_hash) { | 569 bool is_dangerous_hash) { |
546 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
547 DVLOG(1) << "CheckDownloadHashDone, download_id: " << download_id | 571 DVLOG(1) << "CheckDownloadHashDone, download_id: " << download_id |
548 << " is dangerous_hash: " << is_dangerous_hash; | 572 << " is dangerous_hash: " << is_dangerous_hash; |
549 } | 573 } |
OLD | NEW |