| 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" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 bool ChromeDownloadManagerDelegate::DetermineDownloadTarget( | 232 bool ChromeDownloadManagerDelegate::DetermineDownloadTarget( |
| 233 DownloadItem* download, | 233 DownloadItem* download, |
| 234 const content::DownloadTargetCallback& callback) { | 234 const content::DownloadTargetCallback& callback) { |
| 235 #if defined(FULL_SAFE_BROWSING) | 235 #if defined(FULL_SAFE_BROWSING) |
| 236 DownloadProtectionService* service = GetDownloadProtectionService(); | 236 DownloadProtectionService* service = GetDownloadProtectionService(); |
| 237 if (service) { | 237 if (service) { |
| 238 VLOG(2) << __FUNCTION__ << "() Start SB URL check for download = " | 238 VLOG(2) << __FUNCTION__ << "() Start SB URL check for download = " |
| 239 << download->DebugString(false); | 239 << download->DebugString(false); |
| 240 service->CheckDownloadUrl( | 240 service->CheckDownloadUrl( |
| 241 DownloadProtectionService::DownloadInfo::FromDownloadItem(*download), | 241 *download, |
| 242 base::Bind( | 242 base::Bind( |
| 243 &ChromeDownloadManagerDelegate::CheckDownloadUrlDone, | 243 &ChromeDownloadManagerDelegate::CheckDownloadUrlDone, |
| 244 this, | 244 this, |
| 245 download->GetId(), | 245 download->GetId(), |
| 246 callback)); | 246 callback)); |
| 247 return true; | 247 return true; |
| 248 } | 248 } |
| 249 #endif | 249 #endif |
| 250 CheckDownloadUrlDone(download->GetId(), callback, | 250 CheckDownloadUrlDone(download->GetId(), callback, |
| 251 DownloadProtectionService::SAFE); | 251 DownloadProtectionService::SAFE); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 if (!state) { | 320 if (!state) { |
| 321 // Begin the safe browsing download protection check. | 321 // Begin the safe browsing download protection check. |
| 322 DownloadProtectionService* service = GetDownloadProtectionService(); | 322 DownloadProtectionService* service = GetDownloadProtectionService(); |
| 323 if (service) { | 323 if (service) { |
| 324 VLOG(2) << __FUNCTION__ << "() Start SB download check for download = " | 324 VLOG(2) << __FUNCTION__ << "() Start SB download check for download = " |
| 325 << item->DebugString(false); | 325 << item->DebugString(false); |
| 326 state = new SafeBrowsingState(); | 326 state = new SafeBrowsingState(); |
| 327 state->set_callback(internal_complete_callback); | 327 state->set_callback(internal_complete_callback); |
| 328 item->SetUserData(&safe_browsing_id, state); | 328 item->SetUserData(&safe_browsing_id, state); |
| 329 service->CheckClientDownload( | 329 service->CheckClientDownload( |
| 330 DownloadProtectionService::DownloadInfo::FromDownloadItem(*item), | 330 item, |
| 331 base::Bind( | 331 base::Bind( |
| 332 &ChromeDownloadManagerDelegate::CheckClientDownloadDone, | 332 &ChromeDownloadManagerDelegate::CheckClientDownloadDone, |
| 333 this, | 333 this, |
| 334 item->GetId())); | 334 item->GetId())); |
| 335 return false; | 335 return false; |
| 336 } | 336 } |
| 337 } else if (!state->is_complete()) { | 337 } else if (!state->is_complete()) { |
| 338 // Don't complete the download until we have an answer. | 338 // Don't complete the download until we have an answer. |
| 339 state->set_callback(internal_complete_callback); | 339 state->set_callback(internal_complete_callback); |
| 340 return false; | 340 return false; |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 IsDangerousFile(*download, suggested_path, visited_referrer_before)) { | 685 IsDangerousFile(*download, suggested_path, visited_referrer_before)) { |
| 686 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; | 686 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE; |
| 687 } | 687 } |
| 688 | 688 |
| 689 #if defined(FULL_SAFE_BROWSING) | 689 #if defined(FULL_SAFE_BROWSING) |
| 690 DownloadProtectionService* service = GetDownloadProtectionService(); | 690 DownloadProtectionService* service = GetDownloadProtectionService(); |
| 691 // If this type of files is handled by the enhanced SafeBrowsing download | 691 // If this type of files is handled by the enhanced SafeBrowsing download |
| 692 // protection, mark it as potentially dangerous content until we are done | 692 // protection, mark it as potentially dangerous content until we are done |
| 693 // with scanning it. | 693 // with scanning it. |
| 694 if (service && service->enabled()) { | 694 if (service && service->enabled()) { |
| 695 DownloadProtectionService::DownloadInfo info = | |
| 696 DownloadProtectionService::DownloadInfo::FromDownloadItem(*download); | |
| 697 info.target_file = suggested_path; | |
| 698 // TODO(noelutz): if the user changes the extension name in the UI to | 695 // TODO(noelutz): if the user changes the extension name in the UI to |
| 699 // something like .exe SafeBrowsing will currently *not* check if the | 696 // something like .exe SafeBrowsing will currently *not* check if the |
| 700 // download is malicious. | 697 // download is malicious. |
| 701 if (service->IsSupportedDownload(info)) | 698 if (service->IsSupportedDownload(*download, suggested_path)) |
| 702 danger_type = content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT; | 699 danger_type = content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT; |
| 703 } | 700 } |
| 704 #endif | 701 #endif |
| 705 } else { | 702 } else { |
| 706 // Currently we only expect this case. | 703 // Currently we only expect this case. |
| 707 DCHECK_EQ(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL, danger_type); | 704 DCHECK_EQ(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL, danger_type); |
| 708 } | 705 } |
| 709 | 706 |
| 710 #if defined (OS_CHROMEOS) | 707 #if defined (OS_CHROMEOS) |
| 711 drive::DriveDownloadHandler* drive_download_handler = | 708 drive::DriveDownloadHandler* drive_download_handler = |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 // TODO(asanka): This logic is a hack. DownloadFilePicker should give us a | 809 // TODO(asanka): This logic is a hack. DownloadFilePicker should give us a |
| 813 // directory to persist. Or perhaps, if the Drive path | 810 // directory to persist. Or perhaps, if the Drive path |
| 814 // substitution logic is moved here, then we would have a | 811 // substitution logic is moved here, then we would have a |
| 815 // persistable path after the DownloadFilePicker is done. | 812 // persistable path after the DownloadFilePicker is done. |
| 816 if (disposition == DownloadItem::TARGET_DISPOSITION_PROMPT && | 813 if (disposition == DownloadItem::TARGET_DISPOSITION_PROMPT && |
| 817 !download->IsTemporary()) | 814 !download->IsTemporary()) |
| 818 last_download_path_ = target_path.DirName(); | 815 last_download_path_ = target_path.DirName(); |
| 819 } | 816 } |
| 820 callback.Run(target_path, disposition, danger_type, intermediate_path); | 817 callback.Run(target_path, disposition, danger_type, intermediate_path); |
| 821 } | 818 } |
| OLD | NEW |