Chromium Code Reviews| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 | 218 |
| 219 void ChromeDownloadManagerDelegate::UpdateItemInPersistentStore( | 219 void ChromeDownloadManagerDelegate::UpdateItemInPersistentStore( |
| 220 DownloadItem* item) { | 220 DownloadItem* item) { |
| 221 download_history_->UpdateEntry(item); | 221 download_history_->UpdateEntry(item); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void ChromeDownloadManagerDelegate::UpdatePathForItemInPersistentStore( | 224 void ChromeDownloadManagerDelegate::UpdatePathForItemInPersistentStore( |
| 225 DownloadItem* item, | 225 DownloadItem* item, |
| 226 const FilePath& new_path) { | 226 const FilePath& new_path) { |
| 227 download_history_->UpdateDownloadPath(item, new_path); | 227 download_history_->UpdateDownloadPath(item, new_path); |
| 228 | |
| 229 // Begin the safe browsing download protection check. | |
|
noelutz
2011/10/19 16:12:49
Should you also add '#if defined(ENABLE_SAFE_BROWS
Brian Ryner
2011/10/19 18:06:59
Good catch, done. Will also make sure to run this
| |
| 230 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); | |
| 231 if (sb_service && sb_service->download_protection_service()) { | |
| 232 safe_browsing::DownloadProtectionService::DownloadInfo download_info; | |
| 233 download_info.local_file = new_path; | |
| 234 download_info.download_url_chain = item->url_chain(); | |
| 235 download_info.referrer_url = item->referrer_url(); | |
| 236 // TODO(bryner): Fill in the hash (we shouldn't compute it again) | |
| 237 download_info.total_bytes = item->total_bytes(); | |
| 238 // TODO(bryner): Populate user_initiated | |
| 239 if (sb_service->download_protection_service()->CheckClientDownload( | |
| 240 download_info, base::Bind( | |
| 241 &ChromeDownloadManagerDelegate::CheckClientDownloadDone, | |
| 242 base::Unretained(this), | |
|
noelutz
2011/10/19 16:12:49
Not sure you need base::Unretained because this is
Brian Ryner
2011/10/19 18:06:59
I think you're right -- changed. I'm not sure abo
| |
| 243 item))) { | |
| 244 CheckClientDownloadDone(item, | |
| 245 safe_browsing::DownloadProtectionService::SAFE); | |
| 246 } // otherwise we will be notified asynchronously | |
| 247 } | |
| 248 } | |
| 249 | |
| 250 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( | |
| 251 DownloadItem* item, | |
| 252 safe_browsing::DownloadProtectionService::DownloadCheckResult result) { | |
| 253 // TODO(bryner): notify the user based on this result | |
| 228 } | 254 } |
| 229 | 255 |
| 230 void ChromeDownloadManagerDelegate::RemoveItemFromPersistentStore( | 256 void ChromeDownloadManagerDelegate::RemoveItemFromPersistentStore( |
| 231 DownloadItem* item) { | 257 DownloadItem* item) { |
| 232 download_history_->RemoveEntry(item); | 258 download_history_->RemoveEntry(item); |
| 233 } | 259 } |
| 234 | 260 |
| 235 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween( | 261 void ChromeDownloadManagerDelegate::RemoveItemsFromPersistentStoreBetween( |
| 236 const base::Time remove_begin, | 262 const base::Time remove_begin, |
| 237 const base::Time remove_end) { | 263 const base::Time remove_end) { |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 // TODO(noelutz): This function currently works as a callback place holder. | 566 // TODO(noelutz): This function currently works as a callback place holder. |
| 541 // Once we decide the hash check is reliable, we could move the | 567 // Once we decide the hash check is reliable, we could move the |
| 542 // MaybeCompleteDownload in OnAllDataSaved to this function. | 568 // MaybeCompleteDownload in OnAllDataSaved to this function. |
| 543 void ChromeDownloadManagerDelegate::CheckDownloadHashDone( | 569 void ChromeDownloadManagerDelegate::CheckDownloadHashDone( |
| 544 int32 download_id, | 570 int32 download_id, |
| 545 bool is_dangerous_hash) { | 571 bool is_dangerous_hash) { |
| 546 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 572 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 547 DVLOG(1) << "CheckDownloadHashDone, download_id: " << download_id | 573 DVLOG(1) << "CheckDownloadHashDone, download_id: " << download_id |
| 548 << " is dangerous_hash: " << is_dangerous_hash; | 574 << " is dangerous_hash: " << is_dangerous_hash; |
| 549 } | 575 } |
| OLD | NEW |