Chromium Code Reviews| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 // we need to restore the danger state. | 326 // we need to restore the danger state. |
| 327 content::DownloadDangerType danger_type = item->GetDangerType(); | 327 content::DownloadDangerType danger_type = item->GetDangerType(); |
| 328 if (DownloadItemModel(item).GetDangerLevel() != | 328 if (DownloadItemModel(item).GetDangerLevel() != |
| 329 DownloadFileType::NOT_DANGEROUS && | 329 DownloadFileType::NOT_DANGEROUS && |
| 330 (danger_type == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || | 330 (danger_type == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || |
| 331 danger_type == | 331 danger_type == |
| 332 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT)) { | 332 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT)) { |
| 333 DVLOG(2) << __FUNCTION__ | 333 DVLOG(2) << __FUNCTION__ |
| 334 << "() SB service disabled. Marking download as DANGEROUS FILE"; | 334 << "() SB service disabled. Marking download as DANGEROUS FILE"; |
| 335 item->OnContentCheckCompleted( | 335 item->OnContentCheckCompleted( |
| 336 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE); | 336 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE, |
| 337 base::EmptyString()); | |
|
asanka
2016/06/06 20:39:27
base::EmptyString() shouldn't be used in function
Jialiu Lin
2016/06/07 20:34:01
Fixed.Thanks!
| |
| 337 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 338 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 338 internal_complete_callback); | 339 internal_complete_callback); |
| 339 return false; | 340 return false; |
| 340 } | 341 } |
| 341 } else if (!state->is_complete()) { | 342 } else if (!state->is_complete()) { |
| 342 // Don't complete the download until we have an answer. | 343 // Don't complete the download until we have an answer. |
| 343 state->set_callback(internal_complete_callback); | 344 state->set_callback(internal_complete_callback); |
| 344 return false; | 345 return false; |
| 345 } | 346 } |
| 346 | 347 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 645 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 645 base::PostTaskAndReplyWithResult(BrowserThread::GetBlockingPool(), | 646 base::PostTaskAndReplyWithResult(BrowserThread::GetBlockingPool(), |
| 646 FROM_HERE, | 647 FROM_HERE, |
| 647 base::Bind(&GetMimeType, path), | 648 base::Bind(&GetMimeType, path), |
| 648 callback); | 649 callback); |
| 649 } | 650 } |
| 650 | 651 |
| 651 #if defined(FULL_SAFE_BROWSING) | 652 #if defined(FULL_SAFE_BROWSING) |
| 652 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( | 653 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( |
| 653 uint32_t download_id, | 654 uint32_t download_id, |
| 654 DownloadProtectionService::DownloadCheckResult result) { | 655 DownloadProtectionService::DownloadCheckResult result, |
| 656 const std::string& token) { | |
| 655 DownloadItem* item = download_manager_->GetDownload(download_id); | 657 DownloadItem* item = download_manager_->GetDownload(download_id); |
| 656 if (!item || (item->GetState() != DownloadItem::IN_PROGRESS)) | 658 if (!item || (item->GetState() != DownloadItem::IN_PROGRESS)) |
| 657 return; | 659 return; |
| 658 | 660 |
| 659 DVLOG(2) << __FUNCTION__ << "() download = " << item->DebugString(false) | 661 DVLOG(2) << __FUNCTION__ << "() download = " << item->DebugString(false) |
| 660 << " verdict = " << result; | 662 << " verdict = " << result; |
| 661 // We only mark the content as being dangerous if the download's safety state | 663 // We only mark the content as being dangerous if the download's safety state |
| 662 // has not been set to DANGEROUS yet. We don't want to show two warnings. | 664 // has not been set to DANGEROUS yet. We don't want to show two warnings. |
| 663 if (item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || | 665 if (item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || |
| 664 item->GetDangerType() == | 666 item->GetDangerType() == |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 690 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; | 692 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; |
| 691 break; | 693 break; |
| 692 case DownloadProtectionService::POTENTIALLY_UNWANTED: | 694 case DownloadProtectionService::POTENTIALLY_UNWANTED: |
| 693 danger_type = content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED; | 695 danger_type = content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED; |
| 694 break; | 696 break; |
| 695 } | 697 } |
| 696 DCHECK_NE(danger_type, | 698 DCHECK_NE(danger_type, |
| 697 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT); | 699 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT); |
| 698 | 700 |
| 699 if (danger_type != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) | 701 if (danger_type != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) |
| 700 item->OnContentCheckCompleted(danger_type); | 702 item->OnContentCheckCompleted(danger_type, token); |
| 701 } | 703 } |
| 702 | 704 |
| 703 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( | 705 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( |
| 704 item->GetUserData(&kSafeBrowsingUserDataKey)); | 706 item->GetUserData(&kSafeBrowsingUserDataKey)); |
| 705 state->CompleteDownload(); | 707 state->CompleteDownload(); |
| 706 } | 708 } |
| 707 #endif // FULL_SAFE_BROWSING | 709 #endif // FULL_SAFE_BROWSING |
| 708 | 710 |
| 709 // content::NotificationObserver implementation. | 711 // content::NotificationObserver implementation. |
| 710 void ChromeDownloadManagerDelegate::Observe( | 712 void ChromeDownloadManagerDelegate::Observe( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || | 774 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || |
| 773 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || | 775 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || |
| 774 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || | 776 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || |
| 775 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || | 777 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || |
| 776 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { | 778 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { |
| 777 return true; | 779 return true; |
| 778 } | 780 } |
| 779 #endif | 781 #endif |
| 780 return false; | 782 return false; |
| 781 } | 783 } |
| OLD | NEW |